注意
向量搜索和聚类算法正在从 RAFT 迁移到一个专门用于向量搜索的新库,名为 cuVS。在迁移过程中,我们将继续支持 RAFT 中的向量搜索算法,但在 RAPIDS 24.06 (六月) 版本后将不再更新。我们计划在 RAPIDS 24.10 (十月) 版本前完成迁移,并在 24.12 (十二月) 版本中将它们完全从 RAFT 中移除。
temporary_device_buffer: 临时 raft::device_mdspan 生成对象#
#include <raft/core/temporary_device_buffer.hpp>
-
template<typename ElementType, typename Extents, typename LayoutPolicy = layout_c_contiguous, template<typename> typename ContainerPolicy = device_uvector_policy>
class temporary_device_buffer# - #include <temporary_device_buffer.hpp>
一个对象,用于在设备上临时访问来自主机或设备指针的内存。此对象提供一个
view()
方法,该方法将提供一个raft::device_mdspan
,其是否为只读取决于输入指针的 const 限定性质。- 模板参数:
ElementType – 输入的类型
Extents – raft::extents
LayoutPolicy – 输入的布局
ContainerPolicy – 需要时用于拥有设备内存的容器
公共函数
-
inline temporary_device_buffer(resources const &handle, ElementType *data, Extents extents, bool write_back = false)#
构造一个新的临时设备缓冲区对象。
- 参数:
handle – raft::resources
data – 输入指针
extents – 输入数组的维度
write_back – 如果为 true,对此对象的
view()
的任何写入操作,如果原始指针在主机内存中,将被复制回主机。
-
inline view_type view()#
返回一个
raft::device_mdspan
- 返回值:
工厂#
-
template<typename ElementType, typename IndexType = std::uint32_t, typename LayoutPolicy = layout_c_contiguous, template<typename> typename ContainerPolicy = device_uvector_policy, size_t... Extents>
auto make_temporary_device_buffer(raft::resources const &handle, ElementType *data, raft::extents<IndexType, Extents...> extents, bool write_back = false)# 用于创建
raft::temporary_device_buffer
的工厂#include <raft/core/resources.hpp> raft::resources handle; // Initialize raft::device_mdarray and raft::extents // Can be either raft::device_mdarray or raft::host_mdarray auto exts = raft::make_extents<int>(5); auto array = raft::make_device_mdarray<int, int>(handle, exts); auto d_buf = raft::make_temporary_device_buffer(handle, array.data_handle(), exts);
- 模板参数:
ElementType – 输入的类型
IndexType –
raft::extents
的索引类型LayoutPolicy – 输入的布局
ContainerPolicy – 需要时用于拥有设备内存的容器
Extents –
raft::extents
的可变参数维度
- 参数:
handle – raft::resources
data – 输入指针
extents – 输入数组的维度
write_back – 如果为 true,对此对象的
view()
的任何写入操作,如果原始指针在主机内存中,将被复制回主机。
- 返回值:
-
template <
typename ElementType,
typename IndexType=
std::
uint32_t,
typename LayoutPolicy=
layout_c_contiguous,
template <
typename >
typename ContainerPolicy=
device_uvector_policy,
size_t...
Extents>
auto make_readonly_temporary_device_buffer(raft::resources const &handle, ElementType *data, raft::extents<IndexType, Extents...> extents)# 用于创建
raft::temporary_device_buffer
的工厂,该工厂通过view()
方法生成一个只读的raft::device_mdspan
,且write_back=false
。#include <raft/core/resources.hpp> raft::resources handle; // Initialize raft::device_mdarray and raft::extents // Can be either raft::device_mdarray or raft::host_mdarray auto exts = raft::make_extents<int>(5); auto array = raft::make_device_mdarray<int, int>(handle, exts); auto d_buf = raft::make_readonly_temporary_device_buffer(handle, array.data_handle(), exts);
- 模板参数:
ElementType – 输入的类型
IndexType –
raft::extents
的索引类型LayoutPolicy – 输入的布局
ContainerPolicy – 需要时用于拥有设备内存的容器
Extents –
raft::extents
的可变参数维度
- 参数:
handle – raft::resources
data – 输入指针
extents – 输入数组的维度
- 返回值:
-
template <
typename ElementType,
typename IndexType=
std::
uint32_t,
typename LayoutPolicy=
layout_c_contiguous,
template <
typename >
typename ContainerPolicy=
device_uvector_policy,
size_t...
Extents,
typename =
std::
enable_if_t<
not std::
is_const_v<
ElementType>
>
>
auto make_writeback_temporary_device_buffer(raft::resources const &handle, ElementType *data, raft::extents<IndexType, Extents...> extents)# 用于创建
raft::temporary_device_buffer
的工厂,该工厂通过view()
方法生成一个可写的raft::device_mdspan
,且write_back=true
。#include <raft/core/resources.hpp> raft::resources handle; // Initialize raft::host_mdarray and raft::extents // Can be either raft::device_mdarray or raft::host_mdarray auto exts = raft::make_extents<int>(5); auto array = raft::make_host_mdarray<int, int>(handle, exts); auto d_buf = raft::make_writeback_temporary_device_buffer(handle, array.data_handle(), exts);
- 模板参数:
ElementType – 输入的类型
IndexType –
raft::extents
的索引类型LayoutPolicy – 输入的布局
ContainerPolicy – 需要时用于拥有设备内存的容器
Extents –
raft::extents
的可变参数维度
- 参数:
handle – raft::resources
data – 输入指针
extents – 输入数组的维度
- 返回值: