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.

span: One-dimensional Non-owning View#

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

Default constructor that constructs a span with size 0 and nullptr.

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

Constructs a span that is a view over the range [first, first + count);.

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

Constructs a span that is a view over the range [first, last)

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

Constructs a span that is a view over the array 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#

Initialize a span class from another one who’s underlying type is convertible to 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#

If Count is std::dynamic_extent, r.size() == this->size() - Offset; Otherwise 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#

Converts a span into a view of its underlying bytes.

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#

Converts a span into a mutable view of its underlying bytes.

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

The span class defined in ISO C++20. Iterator is defined as plain pointer and most of the methods have bound check on debug build.

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

A span class for device pointer.

#include <raft/core/host_span.hpp>

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

A span class for host pointer.