注意

RAFT 中的向量搜索和聚类算法正在迁移到名为 cuVS 的新向量搜索专用库。在迁移期间,我们将继续支持 RAFT 中的向量搜索算法,但在 RAPIDS 24.06(六月)版本之后将不再更新它们。我们计划在 RAPIDS 24.10(十月)版本之前完成迁移,并在 24.12(十二月)版本中将它们完全从 RAFT 中移除。

稀疏类型#

#include <raft/core/sparse_types.hpp>

enum SparsityType#

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)#

稀疏度已知时的构造函数

参数:
  • n_rows – 矩阵中的总行数

  • n_cols – 矩阵中的总列数

  • nnz – 矩阵的稀疏度

inline sparse_structure(row_type n_rows, col_type n_cols)#

稀疏度未知时的构造函数

参数:
  • n_rows – 矩阵中的总行数

  • n_cols – 矩阵中的总列数

inline nnz_type get_nnz()#

返回矩阵的稀疏度(稀疏度未知时为 0)

返回值:

矩阵的稀疏度

inline row_type get_n_rows()#

返回矩阵中的总行数

返回值:

矩阵中的总行数

inline col_type get_n_cols()#

返回矩阵中的总列数

返回值:

总列数

inline virtual void initialize_sparsity(nnz_type nnz)#

在构造时稀疏度未知的情况下初始化矩阵稀疏度。

参数:

nnz

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

返回此矩阵的基础结构的视图

返回值:

inline span<element_type, is_device> get_elements()#

返回矩阵的非零元素的 span

返回值:

矩阵的非零元素的 span

inline sparse_matrix(raft::resources const &handle, row_type n_rows, col_type n_cols, nnz_type nnz = 0)#
inline sparse_matrix(raft::resources const &handle, structure_type structure)#
constexpr sparse_matrix(sparse_matrix const&) = default#
constexpr sparse_matrix(sparse_matrix&&) = default#
sparse_matrix &=default operator= (sparse_matrix const &)
sparse_matrix &=default operator= (sparse_matrix &&)
~sparse_matrix() = default#
inline void initialize_sparsity(nnz_type nnz)
inline raft::span<ElementType, is_device> get_elements()
virtual structure_view_type structure_view() = 0

返回此矩阵的基础结构的视图

返回值:

inline view_type view()#

返回此稀疏矩阵的保留稀疏度的视图

返回值:

此稀疏矩阵的视图

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

维护有关稀疏矩阵结构和稀疏度的元数据。

模板参数:
  • RowType

  • ColType

  • NZType

  • is_device

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>

稀疏矩阵的非拥有视图,包含与元素/权重耦合的结构组件

模板参数:
  • 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: 需要支持以下类型的配置

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

    • 这是一种不可变视图类型,任何内容都不能更改。

  2. liquid: sparse_matrix<ElementType, const StructureType>

    • sparse_matrix 拥有容器,其中 StructureType=不可变视图?

  3. gas: sparse_matrix<ElementType, StructureType>

    • sparse_matrix 拥有容器,其中 StructureType 是拥有容器?稀疏矩阵的拥有容器,包含与元素/权重耦合的结构组件

模板参数:
  • ElementType

  • sparse_structure

  • ContainerPolicy