Attention

The vector search and clustering algorithms in RAFT are being migrated to a new library dedicated to vector search called cuVS. We will continue to support the vector search algorithms in RAFT during this move, but will no longer update them after the RAPIDS 24.06 (June) release. We plan to complete the migration by RAPIDS 24.10 (October) release and they will be removed from RAFT altogether in the 24.12 (December) release.

Sparse Types#

#include <raft/core/sparse_types.hpp>

enum SparsityType#

Values:

enumerator OWNING#
enumerator PRESERVING#
using row_type = RowType#
using col_type = ColType#
using nnz_type = NZType#
using element_type = ElementType
using structure_view_type = typename StructureType::view_type#
using view_type = ViewType#
using element_type = typename view_type::element_type
using structure_type = StructureType#
using row_type = typename structure_type::row_type
using col_type = typename structure_type::col_type
using nnz_type = typename structure_type::nnz_type
using structure_view_type = typename structure_type::view_type
using container_policy_type = ContainerPolicy<element_type>#
using container_type = typename container_policy_type::container_type#
inline sparse_structure(row_type n_rows, col_type n_cols, nnz_type nnz)#

Constructor when sparsity is already known

Parameters:
  • n_rows – total number of rows in matrix

  • n_cols – total number of columns in matrix

  • nnz – sparsity of matrix

inline sparse_structure(row_type n_rows, col_type n_cols)#

Constructor when sparsity is not yet known

Parameters:
  • n_rows – total number of rows in matrix

  • n_cols – total number of columns in matrix

inline nnz_type get_nnz()#

Return the sparsity of the matrix (this will be 0 when sparsity is not yet known)

Returns:

sparsity of matrix

inline row_type get_n_rows()#

Return the total number of rows in the matrix

Returns:

total number of rows in the matriz

inline col_type get_n_cols()#

Return the total number of columns in the matrix

Returns:

total number of columns

inline virtual void initialize_sparsity(nnz_type nnz)#

Initialize the matrix sparsity when it was not known upon construction.

Parameters:

nnz

inline sparse_matrix_view(raft::span<ElementType, is_device> element_span, structure_view_type structure_view)#
inline structure_view_type structure_view()#

Return a view of the structure underlying this matrix

Returns:

inline span<element_type, is_device> get_elements()#

Return a span of the nonzero elements of the matrix

Returns:

span of the nonzero elements of the matrix

inline sparse_matrix(raft::resources const &handle, row_type n_rows, col_type n_cols, nnz_type nnz = 0) noexcept(std::is_nothrow_default_constructible_v<container_type>)#
inline sparse_matrix(raft::resources const &handle, structure_type structure) noexcept(std::is_nothrow_default_constructible_v<container_type>)#
constexpr sparse_matrix(sparse_matrix const&) noexcept(std::is_nothrow_copy_constructible_v<container_type>) = default#
constexpr sparse_matrix(sparse_matrix&&) noexcept(std::is_nothrow_move_constructible<container_type>::value) = default#
constexpr auto operator=(sparse_matrix const&) noexcept(std::is_nothrow_copy_assignable<container_type>::value) -> sparse_matrix& = default#
constexpr auto operator=(sparse_matrix&&) noexcept(std::is_nothrow_move_assignable<container_type>::value) -> sparse_matrix& = default#
~sparse_matrix() noexcept(std::is_nothrow_destructible<container_type>::value) = default#
inline void initialize_sparsity(nnz_type nnz)
inline raft::span<ElementType, is_device> get_elements()
virtual structure_view_type structure_view() = 0

Return a view of the structure underlying this matrix

Returns:

inline view_type view()#

Return a sparsity-preserving view of this sparse matrix

Returns:

view of this sparse matrix

template<typename RowType, typename ColType, typename NZType, int is_device>
class sparse_structure#
#include <sparse_types.hpp>

Maintains metadata about the structure and sparsity of a sparse matrix.

Template Parameters:
  • RowType

  • ColType

  • NZType

  • is_device

Subclassed by raft::coordinate_structure_t< RowType, ColType, NZType, is_device >

template<typename ElementType, typename StructureType, bool is_device>
class sparse_matrix_view#
#include <sparse_types.hpp>

A non-owning view of a sparse matrix, which includes a structure component coupled with its elements/weights

Template Parameters:
  • ElementType

  • sparse_structure

template<typename ElementType, typename StructureType, typename ViewType, bool is_device, template<typename T> typename ContainerPolicy>
class sparse_matrix#
#include <sparse_types.hpp>

TODO: Need to support the following types of configurations:

  1. solid: immutable_sparse_matrix_view<const ElementType, const StructureType>

    • This is an immutable view type, nothing can change.

  2. liquid: sparse_matrix<ElementType, const StructureType>

    • sparse_matrix owning container w/ StructureType=immutable view?

  3. gas: sparse_matrix<ElementType, StructureType>

    • sparse_matrix owning container w/ StructureType owning container? An owning container for a sparse matrix, which includes a structure component coupled with its elements/weights

Template Parameters:
  • ElementType

  • sparse_structure

  • ContainerPolicy