ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ndarray::Array< T > Class Template Reference

#include <Array.h>

Public Member Functions

 Array (T *data, Shape shape) noexcept
 
 Array (const Array &)=delete
 
 Array (Array &&a) noexcept
 
template<typename... Ts>
T & at (Ts... x) const noexcept
 
template<typename... Ts>
ContiguousSpan< T, std::is_const< T >::value > slice (Ts... x) noexcept
 returns last dimension as ContigniousSpan
 
template<typename... Ts>
ContiguousSpan< T, true > slice (Ts... x) const noexcept
 returns last dimension as ContigniousSpan
 
ContiguousSpan< T, std::is_const< T >::value > flat () noexcept
 
ContiguousSpan< T, true > flat () const noexcept
 
const Shapeshape () const noexcept
 

Detailed Description

template<typename T>
class ndarray::Array< T >

Definition at line 87 of file Array.h.

Constructor & Destructor Documentation

◆ Array() [1/3]

template<typename T >
ndarray::Array< T >::Array ( T *  data,
Shape  shape 
)
inlinenoexcept

Definition at line 90 of file Array.h.

90: _data(data), _shape(shape), _strides(shape) {}
const Shape & shape() const noexcept
Definition Array.h:130

◆ Array() [2/3]

template<typename T >
ndarray::Array< T >::Array ( const Array< T > &  )
delete

◆ Array() [3/3]

template<typename T >
ndarray::Array< T >::Array ( Array< T > &&  a)
inlinenoexcept

Definition at line 94 of file Array.h.

94 : _data(a._data), _shape(a._shape), _strides(a._strides)
95 {
96 a._data = nullptr;
97 }

Member Function Documentation

◆ at()

template<typename T >
template<typename... Ts>
T & ndarray::Array< T >::at ( Ts...  x) const
inlinenoexcept

Definition at line 99 of file Array.h.

99{ return _at(static_cast<size_t>(x)...); }

Referenced by ndarray::Array< T >::slice(), and ndarray::Array< T >::slice().

◆ flat() [1/2]

template<typename T >
ContiguousSpan< T, true > ndarray::Array< T >::flat ( ) const
inlinenoexcept

Definition at line 128 of file Array.h.

128{ return {_data, _shape.element_count()}; }
size_t element_count() const noexcept
Definition Shape.h:48

References ndarray::Shape::element_count().

◆ flat() [2/2]

template<typename T >
ContiguousSpan< T, std::is_const< T >::value > ndarray::Array< T >::flat ( )
inlinenoexcept

Definition at line 123 of file Array.h.

124 {
125 return {_data, _shape.element_count()};
126 }

References ndarray::Shape::element_count().

Referenced by ndarray::array_cast().

◆ shape()

template<typename T >
const Shape & ndarray::Array< T >::shape ( ) const
inlinenoexcept

◆ slice() [1/2]

template<typename T >
template<typename... Ts>
ContiguousSpan< T, true > ndarray::Array< T >::slice ( Ts...  x) const
inlinenoexcept

returns last dimension as ContigniousSpan

Parameters
xindices of slice to take. See tests for usage details
Returns
slice at given position

Definition at line 117 of file Array.h.

118 {
119 assert(sizeof...(Ts) == _shape.rank() - 1);
120 return {&at(x..., 0ul), _shape.dim(_shape.rank() - 1)};
121 }
T & at(Ts... x) const noexcept
Definition Array.h:99
size_t dim(int i) const noexcept
Definition Shape.h:44
size_t rank() const noexcept
Definition Shape.h:57

References ndarray::Array< T >::at(), ndarray::Shape::dim(), and ndarray::Shape::rank().

◆ slice() [2/2]

template<typename T >
template<typename... Ts>
ContiguousSpan< T, std::is_const< T >::value > ndarray::Array< T >::slice ( Ts...  x)
inlinenoexcept

returns last dimension as ContigniousSpan

Parameters
xindices of slice to take. See tests for usage details
Returns
slice at given position

Definition at line 106 of file Array.h.

107 {
108 assert(sizeof...(Ts) == _shape.rank() - 1);
109 return {&at(x..., 0ul), _shape.dim(_shape.rank() - 1)};
110 }

References ndarray::Array< T >::at(), ndarray::Shape::dim(), and ndarray::Shape::rank().

Referenced by gather_array(), and main().


The documentation for this class was generated from the following file: