注意

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

span: 一维非拥有的视图#

#include <raft/core/span.hpp>

using element_type = T#
using value_type = typename std::remove_cv<T>::type#
using size_type = std::size_t#
using difference_type = std::ptrdiff_t#
using pointer = T*#
using const_pointer = T const*#
using reference = T&#
using const_reference = T const&#
using iterator = pointer#
using const_iterator = const_pointer#
using reverse_iterator = thrust::reverse_iterator<iterator>#
using const_reverse_iterator = thrust::reverse_iterator<const_iterator>#
constexpr span() noexcept = default#

默认构造函数,构造一个大小为 0 且指针为空的 span。

inline constexpr span(pointer ptr, size_type count) noexcept#

构造一个 span,它是范围 [first, first + count) 的视图。

inline constexpr span(pointer first, pointer last) noexcept#

构造一个 span,它是范围 [first, last) 的视图

template<std::size_t N>
inline constexpr span(element_type (&arr)[N]) noexcept#

构造一个 span,它是数组 arr 的视图。

template<class U, std::size_t OtherExtent, class = typename std::enable_if<detail::is_allowed_element_type_conversion_t<U, T>::value && detail::is_allowed_extent_conversion_t<OtherExtent, Extent>::value>>
inline constexpr span(const span<U, is_device, OtherExtent> &other) noexcept#

从另一个 span 类初始化一个 span 类,该类的底层类型可转换为 element_type

constexpr span(span const &other) noexcept = default#
constexpr span(span &&other) noexcept = default#
span &=default operator= (span const &other) noexcept
span &=default operator= (span &&other) noexcept
inline iterator begin() const noexcept#
inline iterator end() const noexcept#
inline const_iterator cbegin() const noexcept#
inline const_iterator cend() const noexcept#
inline _RAFT_HOST_DEVICE constexpr auto rbegin () const noexcept -> reverse_iterator
inline _RAFT_HOST_DEVICE constexpr auto rend () const noexcept -> reverse_iterator
inline _RAFT_HOST_DEVICE constexpr auto crbegin () const noexcept -> const_reverse_iterator
inline _RAFT_HOST_DEVICE constexpr auto crend () const noexcept -> const_reverse_iterator
inline reference front() const#
inline reference back() const#
template<typename Index>
inline reference operator[](Index _idx) const#
inline pointer data() const noexcept#
inline size_type size() const noexcept#
inline size_type size_bytes() const noexcept#
inline auto empty() const noexcept#
template<std::size_t Count>
inline span<element_type, is_device, Count> first() const#
inline span<element_type, is_device, dynamic_extent> first(std::size_t _count) const#
template<std::size_t Count>
inline span<element_type, is_device, Count> last() const#
inline span<element_type, is_device, dynamic_extent> last(std::size_t _count) const#
template<std::size_t Offset, std::size_t Count = dynamic_extent>
inline span<element_type, is_device, detail::extent_value_t<Extent, Offset, Count>::value> subspan() const#

如果 Count 是 std::dynamic_extent,则 r.size() == this->size() - Offset;否则 r.size() == Count。

inline span<element_type, is_device, dynamic_extent> subspan(size_type _offset, size_type _count = dynamic_extent) const#
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
bool operator==(span<T, is_device, X> l, span<U, is_device, Y> r)#
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
auto operator!=(span<T, is_device, X> l, span<U, is_device, Y> r)#
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
auto operator<(span<T, is_device, X> l, span<U, is_device, Y> r)#
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
auto operator<=(span<T, is_device, X> l, span<U, is_device, Y> r)#
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
auto operator>(span<T, is_device, X> l, span<U, is_device, Y> r)#
template<class T, std::size_t X, class U, std::size_t Y, bool is_device>
auto operator>=(span<T, is_device, X> l, span<U, is_device, Y> r)#
template<class T, bool is_device, std::size_t E>
span<const std::byte, is_device, detail::extent_as_bytes_value_t<T, E>::value> as_bytes(span<T, is_device, E> s) noexcept#

将 span 转换为对其底层字节的视图。

template<class T, bool is_device, std::size_t E>
span<std::byte, is_device, detail::extent_as_bytes_value_t<T, E>::value> as_writable_bytes(span<T, is_device, E> s) noexcept#

将 span 转换为对其底层字节的可变视图。

template<typename T, bool is_device, std::size_t Extent = dynamic_extent>
class span#
#include <span.hpp>

在 ISO C++20 中定义的 span 类。迭代器定义为普通指针,并且大多数方法在调试构建中都带有边界检查。

rmm::device_uvector<float> uvec(10, rmm::cuda_stream_default);
auto view = device_span<float>{uvec.data(), uvec.size()};

#include <raft/core/device_span.hpp>

template<typename T, size_t extent = std::experimental::dynamic_extent>
using device_span = span<T, true, extent>#

用于设备指针的 span 类。

#include <raft/core/host_span.hpp>

template<typename T, size_t extent = std::experimental::dynamic_extent>
using host_span = span<T, false, extent>#

用于主机指针的 span 类。