NDArray is a class that can be used in both host and device code. NDArray is automatically divided into multiple NDArrayViews for each task.
More...
#include "mu/ndarray/ndarray.hpp"
|
| static constexpr std::int64_t | MAX_DIMS = 10 |
| |
template<typename T>
class mu::NDArray< T >
NDArray is a class that can be used in both host and device code. NDArray is automatically divided into multiple NDArrayViews for each task.
Definition at line 22 of file ndarray.hpp.
◆ ShapeArray
◆ StridesArray
◆ NDArray() [1/4]
◆ NDArray() [2/4]
Definition at line 30 of file ndarray.hpp.
31 : data_(
const_cast<void*
>(
reinterpret_cast<const void*
>(
data))),
35 std::fill(shape_.begin(), shape_.end(), 0);
36 std::fill(strides_.begin(), strides_.end(), 0);
37 std::copy(
shape.begin(),
shape.end(), shape_.begin());
38 calculateSizeAndStrides();
const ShapeArray & shape() const
◆ NDArray() [3/4]
Definition at line 41 of file ndarray.hpp.
42 : data_(
const_cast<void*
>(
reinterpret_cast<const void*
>(
data))),
46 std::fill(shape_.begin(), shape_.end(), 0);
47 std::fill(strides_.begin(), strides_.end(), 0);
48 for (std::size_t i = 0; i <
MAX_DIMS; ++i)
56 calculateSizeAndStrides();
static constexpr std::int64_t MAX_DIMS
◆ NDArray() [4/4]
Definition at line 59 of file ndarray.hpp.
64 std::fill(shape_.begin(), shape_.end(), 0);
65 std::fill(strides_.begin(), strides_.end(), 0);
66 for (std::size_t i = 0; i <
MAX_DIMS; ++i)
74 calculateSizeAndStrides();
std::int64_t elemSize() const
◆ ~NDArray()
◆ at() [1/2]
template<typename T >
template<typename... Idxs>
Definition at line 190 of file ndarray.hpp.
192 return const_cast<T&
>(
static_cast<const NDArray&
>(*this).at(idxs...));
◆ at() [2/2]
template<typename T >
template<typename... Idxs>
Definition at line 196 of file ndarray.hpp.
198 std::array<std::int64_t, MAX_DIMS> indices = {idxs...};
199 if (
sizeof...(Idxs) !=
static_cast<std::size_t
>(dims_))
202 return *
reinterpret_cast<const T*
>(data_);
204 for (std::size_t i = 0; i < indices.size(); ++i)
206 if (indices[i] < 0 || indices[i] >= shape_[i])
209 return *
reinterpret_cast<const T*
>(data_);
T & operator()(Idxs... idxs)
◆ data() [1/2]
Definition at line 79 of file ndarray.hpp.
81 return reinterpret_cast<T*
>(data_);
◆ data() [2/2]
Definition at line 83 of file ndarray.hpp.
85 return reinterpret_cast<const T*
>(data_);
◆ dims()
◆ elemSize()
◆ numElements()
◆ operator const T &()
Definition at line 162 of file ndarray.hpp.
167 return *
reinterpret_cast<const T*
>(data_);
169 return *
reinterpret_cast<const T*
>(data_);
◆ operator typename std::enable_if_t< std::is_same_v< U, std::remove_const_t< T >>, T & >()
template<typename T >
template<typename U = T>
| mu::NDArray< T >::operator typename std::enable_if_t< std::is_same_v< U, std::remove_const_t< T >>, T & > |
( |
| ) |
|
|
inline |
Definition at line 152 of file ndarray.hpp.
157 return *
reinterpret_cast<T*
>(data_);
159 return *
reinterpret_cast<T*
>(data_);
◆ operator()() [1/2]
template<typename T >
template<typename... Idxs>
Definition at line 119 of file ndarray.hpp.
121 return const_cast<T&
>(
static_cast<const NDArray&
>(*this)(idxs...));
◆ operator()() [2/2]
template<typename T >
template<typename... Idxs>
| const T& mu::NDArray< T >::operator() |
( |
Idxs... |
idxs | ) |
const |
|
inline |
Definition at line 125 of file ndarray.hpp.
127 return reinterpret_cast<const T*
>(data_)[computeOffset({idxs...})];
◆ operator[]() [1/2]
Definition at line 131 of file ndarray.hpp.
133 auto const_result =
static_cast<const NDArray&
>(*this)[idx];
135 const_cast<T*
>(const_result.data()),
136 const_result.shape());
◆ operator[]() [2/2]
Definition at line 139 of file ndarray.hpp.
142 std::fill(new_shape.begin(), new_shape.end(), 0);
143 std::copy(shape_.begin() + 1, shape_.end(), new_shape.begin());
145 return NDArray<const T>(
146 reinterpret_cast<const T*
>(data_) + idx * strides_[0],
std::array< std::int64_t, MAX_DIMS > ShapeArray
◆ scalar() [1/2]
Definition at line 173 of file ndarray.hpp.
175 return const_cast<T&
>(
static_cast<const NDArray&
>(*this).scalar());
◆ scalar() [2/2]
Definition at line 178 of file ndarray.hpp.
183 return *
reinterpret_cast<const T*
>(data_);
185 return *
reinterpret_cast<const T*
>(data_);
◆ setData()
◆ shape()
◆ size()
◆ strides()
◆ MAX_DIMS
The documentation for this class was generated from the following files: