Multi-dimensional Representation#
Data Layouts#
#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#
Shapes#
#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::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)# Flatten raft::mdspan into a 1-dim array view.
- Template Parameters:
mdspan_type – Expected type raft::host_mdspan or raft::device_mdspan
- Parameters:
mds – raft::host_mdspan or raft::device_mdspan object
- Returns:
raft::host_mdspan or raft::device_mdspan with vector_extent depending on AccessoryPolicy
-
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)# Reshape raft::host_mdspan or raft::device_mdspan.
- Template Parameters:
mdspan_type – Expected type raft::host_mdspan or raft::device_mdspan
IndexType – the index type of the extents
Extents – raft::extents for dimensions
- Parameters:
mds – raft::host_mdspan or raft::device_mdspan object
new_shape – Desired new shape of the input
- Returns:
raft::host_mdspan or raft::device_mdspan, depending on AccessorPolicy
-
template<class ElementType>
std::experimental::default_accessor<std::add_const_t<ElementType>> accessor_of_const(std::experimental::default_accessor<ElementType> a)# Const accessor specialization for default_accessor.
- Template Parameters:
ElementType –
- Parameters:
a –
- Returns:
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)# Const accessor specialization for host_device_accessor.
- Template Parameters:
ElementType – the data type of the mdspan elements
MemType – the type of memory where the elements are stored.
- Parameters:
- Returns:
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)# Flatten object implementing raft::array_interface into a 1-dim array view.
- Template Parameters:
array_interface_type – Expected type implementing raft::array_interface
- Parameters:
mda – raft::array_interace implementing object
- Returns:
Either raft::host_mdspan or raft::device_mdspan with vector_extent depending on the underlying ContainerPolicy
-
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)# Reshape object implementing raft::array_interface.
- Template Parameters:
array_interface_type – Expected type implementing raft::array_interface
Extents – raft::extents for dimensions
IndexType – the index type of the extents
- Parameters:
mda – raft::array_interace implementing object
new_shape – Desired new shape of the input
- Returns:
raft::host_mdspan or raft::device_mdspan, depending on the underlying ContainerPolicy
Accessors#
#include <raft/core/host_device_accessor.hpp>
-
template<typename AccessorPolicy, memory_type MemType>
struct host_device_accessor : public AccessorPolicy# A mixin to distinguish host and device memory. This is the primary accessor used throughout RAFT’s APIs to denote whether an underlying pointer is accessible from device, host, or both.
-
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>#