Dense Array Views

View as Markdown

Dense array views describe memory owned somewhere else. They carry the pointer, shape, layout, memory-space accessor, and constness needed by NVIDIA cuVS C++ APIs without allocating or freeing data.

raft::mdspan

Source header: raft/core/mdspan.hpp

Generic multi-dimensional non-owning view.

1template <typename ElementType, typename Extents, typename LayoutPolicy,
2 typename AccessorPolicy>
3class mdspan;

raft::mdspan::data_handle

Returns the pointer held by the non-owning view.

1element_type* data_handle() const;

Returns

element_type*

raft::mdspan::extents

Returns the extents object that describes the view shape.

1extents_type extents() const;

Returns

extents_type

raft::mdspan::extent

Returns the size of one rank of the view.

1index_type extent(std::size_t r) const noexcept;

Parameters

NameTypeDescription
rstd::size_tRank to query.

Returns

index_type

raft::mdspan::stride

Returns the stride for one rank of a strided view.

1index_type stride(std::size_t r) const;

Parameters

NameTypeDescription
rstd::size_tRank to query.

Returns

index_type

raft::mdspan::size

Returns the total number of elements described by the view.

1size_type size() const;

Returns

size_type

raft::mdspan::empty

Reports whether the view describes zero elements.

1bool empty() const;

Returns

bool

raft::mdspan::operator()

Indexes into the view with one coordinate per rank.

1template <typename... IndexType>
2reference operator()(IndexType... indices) const;

Parameters

NameTypeDescription
indicesIndexType...Coordinates into the view, one per rank.

Returns

reference

raft::device_mdspan

Source header: raft/core/device_mdspan.hpp

Non-owning view over device-accessible memory.

1template <typename ElementType,
2 typename Extents,
3 typename LayoutPolicy = layout_c_contiguous,
4 typename AccessorPolicy = cuda::std::default_accessor<ElementType>>
5using device_mdspan =
6 mdspan<ElementType, Extents, LayoutPolicy, device_accessor<AccessorPolicy>>;

raft::host_mdspan

Source header: raft/core/host_mdspan.hpp

Non-owning view over host memory.

1template <typename ElementType,
2 typename Extents,
3 typename LayoutPolicy = layout_c_contiguous,
4 typename AccessorPolicy = cuda::std::default_accessor<ElementType>>
5using host_mdspan =
6 mdspan<ElementType, Extents, LayoutPolicy, host_accessor<AccessorPolicy>>;

raft::device_matrix_view

Source header: raft/core/device_mdspan.hpp

Common device view alias for matrix arguments.

1template <typename ElementType,
2 typename IndexType = std::uint32_t,
3 typename LayoutPolicy = layout_c_contiguous>
4using device_matrix_view =
5 device_mdspan<ElementType, matrix_extent<IndexType>, LayoutPolicy>;

raft::device_vector_view

Source header: raft/core/device_mdspan.hpp

Common device view alias for vector arguments.

1template <typename ElementType,
2 typename IndexType = std::uint32_t,
3 typename LayoutPolicy = layout_c_contiguous>
4using device_vector_view =
5 device_mdspan<ElementType, vector_extent<IndexType>, LayoutPolicy>;

raft::device_scalar_view

Source header: raft/core/device_mdspan.hpp

Common device view alias for scalar arguments.

1template <typename ElementType, typename IndexType = std::uint32_t>
2using device_scalar_view = device_mdspan<ElementType, scalar_extent<IndexType>>;

raft::host_matrix_view

Source header: raft/core/host_mdspan.hpp

Common host view alias for matrix arguments.

1template <typename ElementType,
2 typename IndexType = std::uint32_t,
3 typename LayoutPolicy = layout_c_contiguous>
4using host_matrix_view =
5 host_mdspan<ElementType, matrix_extent<IndexType>, LayoutPolicy>;

raft::host_vector_view

Source header: raft/core/host_mdspan.hpp

Common host view alias for vector arguments.

1template <typename ElementType,
2 typename IndexType = std::uint32_t,
3 typename LayoutPolicy = layout_c_contiguous>
4using host_vector_view =
5 host_mdspan<ElementType, vector_extent<IndexType>, LayoutPolicy>;

raft::host_scalar_view

Source header: raft/core/host_mdspan.hpp

Common host view alias for scalar arguments.

1template <typename ElementType, typename IndexType = std::uint32_t>
2using host_scalar_view = host_mdspan<ElementType, scalar_extent<IndexType>>;

raft::span

Source header: raft/core/span.hpp

Lightweight one-dimensional non-owning view. NVIDIA cuVS public APIs usually prefer device_vector_view and host_vector_view for one-dimensional buffers.

1template <typename ElementType, std::size_t Extent>
2class span;

raft::span::data

Returns the pointer held by the span.

1element_type* data() const;

Returns

element_type*

raft::span::size

Returns the number of elements in the span.

1size_type size() const;

Returns

size_type

raft::span::empty

Reports whether the span contains zero elements.

1bool empty() const;

Returns

bool

raft::span::operator[]

Indexes into the span.

1reference operator[](size_type idx) const;

Parameters

NameTypeDescription
idxsize_typeElement index.

Returns

reference

raft::span::begin

Returns an iterator to the first element.

1iterator begin() const;

Returns

iterator

raft::span::end

Returns an iterator one past the last element.

1iterator end() const;

Returns

iterator