注意

RAFT 中的向量搜索和聚类算法正在迁移到一个专门用于向量搜索的新库,名为 cuVS。在此迁移期间,我们将继续支持 RAFT 中的向量搜索算法,但在 RAPIDS 24.06 (6 月) 版本发布后将不再更新它们。我们计划在 RAPIDS 24.10 (10 月) 版本发布时完成迁移,并在 24.12 (12 月) 版本中将其从 RAFT 中完全移除。

多维表示#

数据布局#

#include <raft/core/mdspan_types.hpp>

using layout_c_contiguous = layout_right#
using row_major = layout_right#
using layout_f_contiguous = layout_left#
using col_major = layout_left#

形状#

#include <raft/core/mdspan.hpp>

template<typename IndexType>
using raft::matrix_extent = std::experimental::extents<IndexType, dynamic_extent, dynamic_extent>#
template<typename IndexType>
using raft::vector_extent = std::experimental::extents<IndexType, dynamic_extent>#
template<typename IndexType>
using raft::scalar_extent = std::experimental::extents<IndexType, 1>#
template<typename IndexType>
using raft::extent_3d = std::experimental::extents<IndexType, dynamic_extent, dynamic_extent, dynamic_extent>#
template<typename IndexType>
using raft::extent_4d = std::experimental::extents<IndexType, dynamic_extent, dynamic_extent, dynamic_extent, dynamic_extent>#
template<typename IndexType>
using raft::extent_5d = std::experimental::extents<IndexType, dynamic_extent, dynamic_extent, dynamic_extent, dynamic_extent, dynamic_extent>#
template<typename mdspan_type, typename = enable_if_mdspan<mdspan_type>>
auto flatten(mdspan_type mds)#

将 raft::mdspan 展平为一维数组视图。

模板参数:

mdspan_type – 期望类型 raft::host_mdspanraft::device_mdspan

参数:

mdsraft::host_mdspanraft::device_mdspan 对象

返回值:

取决于 AccessoryPolicy 的 raft::host_mdspanraft::device_mdspan,其形状为 vector_extent

template<typename mdspan_type, typename IndexType = std::uint32_t, size_t... Extents, typename = enable_if_mdspan<mdspan_type>>
auto reshape(mdspan_type mds, extents<IndexType, Extents...> new_shape)#

重塑 raft::host_mdspan 或 raft::device_mdspan。

模板参数:
参数:
返回值:

取决于 AccessorPolicy 的 raft::host_mdspanraft::device_mdspan

template<class ElementType>
std::experimental::default_accessor<std::add_const_t<ElementType>> accessor_of_const(std::experimental::default_accessor<ElementType> a)#

default_accessor 的 const 访问器特化。

模板参数:

ElementType

参数:

a

返回值:

std::experimental::default_accessor<std::add_const_t<ElementType>>

template<class ElementType, memory_type MemType>
host_device_accessor<std::experimental::default_accessor<std::add_const_t<ElementType>>, MemType> accessor_of_const(host_device_accessor<std::experimental::default_accessor<ElementType>, MemType> a)#

host_device_accessor 的 const 访问器特化。

模板参数:
  • ElementType – mdspan 元素的数据类型

  • MemType – 元素存储的内存类型。

参数:

ahost_device_accessor

返回值:

host_device_accessor<std::experimental::default_accessor<std::add_const_t<ElementType>>, MemType>

template<typename array_interface_type, std::enable_if_t<is_array_interface_v<array_interface_type>>* = nullptr>
auto flatten(const array_interface_type &mda)#

将实现 raft::array_interface 的对象展平为一维数组视图。

模板参数:

array_interface_type – 期望的实现 raft::array_interface 的类型

参数:

mda – 实现 raft::array_interface 的对象

返回值:

取决于底层 ContainerPolicy 的 raft::host_mdspanraft::device_mdspan,其形状为 vector_extent

template<typename array_interface_type, typename IndexType = std::uint32_t, size_t... Extents, std::enable_if_t<is_array_interface_v<array_interface_type>>* = nullptr>
auto reshape(const array_interface_type &mda, extents<IndexType, Extents...> new_shape)#

重塑实现 raft::array_interface 的对象。

模板参数:
  • array_interface_type – 期望的实现 raft::array_interface 的类型

  • Extents – 维度的 raft::extents

  • IndexType – extents 的索引类型

参数:
  • mda – 实现 raft::array_interface 的对象

  • new_shape – 输入期望的新形状

返回值:

取决于底层 ContainerPolicy 的 raft::host_mdspanraft::device_mdspan

访问器#

#include <raft/core/host_device_accessor.hpp>

template<typename AccessorPolicy, memory_type MemType>
struct host_device_accessor : public AccessorPolicy#

用于区分主机内存和设备内存的 mixin。这是 RAFT API 中用于指示底层指针是可从设备、主机还是两者访问的主要访问器。

template<typename AccessorPolicy>
using raft::host_accessor = host_device_accessor<AccessorPolicy, memory_type::host>#
template<typename AccessorPolicy>
using raft::device_accessor = host_device_accessor<AccessorPolicy, memory_type::device>#
template<typename AccessorPolicy>
using raft::managed_accessor = host_device_accessor<AccessorPolicy, memory_type::managed>#