under the restriction of C++11, a simple alternative to std::vector<T> + std::mdspan. In source_base/module_container/ATen/tensor.h, tensor class provides a cross-device container, but std::string is not supported. Therefore, this class is to provide a general (but CPU-only) container for multi-dimensional data. It can easily convert to container::Tensor.
More...
#include <ndarray.h>
|
| | NDArray ()=delete |
| | Construct a new NDArray object.
|
| |
| | NDArray (std::initializer_list< size_t > il) |
| |
| | NDArray (std::initializer_list< int > il) |
| |
| template<typename... Args> |
| | NDArray (const size_t idx, Args... args) |
| |
| template<typename... Args> |
| | NDArray (const int &idx, Args... args) |
| |
| | NDArray (const NDArray &other) |
| |
| | NDArray (NDArray &&other) |
| |
| | ~NDArray () |
| |
| NDArray & | operator= (const NDArray &other) |
| | = operator, copy assignment
|
| |
| NDArray & | operator= (NDArray &&other) |
| | = operator, move assignment
|
| |
| bool | operator== (const NDArray &other) const |
| | == operator
|
| |
| bool | operator!= (const NDArray &other) const |
| | != operator
|
| |
| template<typename... Args> |
| T & | at (const size_t idx, Args... args) |
| | at function
|
| |
| template<typename... Args> |
| const T & | at (const size_t idx, Args... args) const |
| |
| template<typename... Args> |
| T & | operator() (const size_t idx, Args... args) |
| | [] operator
|
| |
| template<typename... Args> |
| const T & | operator() (const size_t idx, Args... args) const |
| |
| T & | front () |
| |
| const T & | front () const |
| |
| T & | back () |
| |
| const T & | back () const |
| |
| T * | data () |
| |
| const T * | data () const |
| |
| T * | begin () |
| |
| T * | end () |
| |
| const T * | cbegin () const |
| |
| const T * | cend () const |
| |
| size_t | size () const |
| |
| size_t | size (const size_t &dim) const |
| |
| bool | empty () const |
| |
| const std::vector< size_t > & | shape () const |
| |
| template<typename... Args> |
| void | reshape (Args... args) |
| |
| template<typename... Args> |
| size_t | index (const size_t idx, Args... args) const |
| | SFINAE (Substitution Failure Is Not An Error) to_tensor function, only if T is int, double, float, std::complex<float>, std::complex<double>, otherwise there is no such function.
|
| |
template<typename
T>
class NDArray< T >
under the restriction of C++11, a simple alternative to std::vector<T> + std::mdspan. In source_base/module_container/ATen/tensor.h, tensor class provides a cross-device container, but std::string is not supported. Therefore, this class is to provide a general (but CPU-only) container for multi-dimensional data. It can easily convert to container::Tensor.
- Template Parameters
-
◆ NDArray() [1/7]
◆ NDArray() [2/7]
◆ NDArray() [3/7]
◆ NDArray() [4/7]
template<typename... Args>
◆ NDArray() [5/7]
template<typename... Args>
◆ NDArray() [6/7]
◆ NDArray() [7/7]
◆ ~NDArray()
◆ at() [1/2]
template<typename... Args>
| T & NDArray< T >::at |
( |
const size_t |
idx, |
|
|
Args... |
args |
|
) |
| |
|
inline |
at function
- Template Parameters
-
- Parameters
-
| args | indices of the element |
- Returns
- T& or const T&
◆ at() [2/2]
template<typename... Args>
| const T & NDArray< T >::at |
( |
const size_t |
idx, |
|
|
Args... |
args |
|
) |
| const |
|
inline |
◆ back() [1/2]
◆ back() [2/2]
◆ begin()
◆ cbegin()
◆ cend()
◆ data() [1/2]
◆ data() [2/2]
◆ empty()
◆ end()
◆ front() [1/2]
◆ front() [2/2]
◆ index()
template<typename... Args>
| size_t NDArray< T >::index |
( |
const size_t |
idx, |
|
|
Args... |
args |
|
) |
| const |
|
inline |
SFINAE (Substitution Failure Is Not An Error) to_tensor function, only if T is int, double, float, std::complex<float>, std::complex<double>, otherwise there is no such function.
- Returns
- container::Tensor, only if T is int, double, float, std::complex<float>, std::complex<double>
◆ operator!=()
!= operator
- Parameters
-
- Returns
- true if the data and shape are different
-
false otherwise
◆ operator()() [1/2]
template<typename... Args>
| T & NDArray< T >::operator() |
( |
const size_t |
idx, |
|
|
Args... |
args |
|
) |
| |
|
inline |
[] operator
- Template Parameters
-
- Parameters
-
| args | indices of the element |
- Returns
- T& or const T&
◆ operator()() [2/2]
template<typename... Args>
| const T & NDArray< T >::operator() |
( |
const size_t |
idx, |
|
|
Args... |
args |
|
) |
| const |
|
inline |
◆ operator=() [1/2]
= operator, copy assignment
- Parameters
-
- Returns
- NDArray&
◆ operator=() [2/2]
= operator, move assignment
◆ operator==()
== operator
- Parameters
-
- Returns
- true if the data and shape are the same
-
false otherwise
◆ reshape()
template<typename... Args>
| void NDArray< T >::reshape |
( |
Args... |
args | ) |
|
|
inline |
◆ shape()
| const std::vector< size_t > & NDArray< T >::shape |
( |
| ) |
const |
|
inline |
◆ size() [1/2]
◆ size() [2/2]
| size_t NDArray< T >::size |
( |
const size_t & |
dim | ) |
const |
|
inline |
◆ data_
◆ shape_
| std::vector<size_t> NDArray< T >::shape_ |
|
private |
The documentation for this class was generated from the following file:
- /home/runner/work/abacus-develop/abacus-develop/source/source_base/ndarray.h