ONE - On-device Neural Engine
Loading...
Searching...
No Matches
ndarray::Shape Class Reference

#include <Shape.h>

Public Member Functions

 Shape (size_t rank) noexcept
 
 Shape (std::initializer_list< size_t > list) noexcept
 
size_t dim (int i) const noexcept
 
size_t & dim (int i) noexcept
 
size_t element_count () const noexcept
 
size_t rank () const noexcept
 

Detailed Description

Definition at line 29 of file Shape.h.

Constructor & Destructor Documentation

◆ Shape() [1/2]

ndarray::Shape::Shape ( size_t  rank)
inlineexplicitnoexcept

Definition at line 34 of file Shape.h.

34 : _dims{}, _rank(rank)
35 {
36 std::fill(_dims.begin(), _dims.end(), 0);
37 }
size_t rank() const noexcept
Definition Shape.h:57

◆ Shape() [2/2]

ndarray::Shape::Shape ( std::initializer_list< size_t >  list)
inlinenoexcept

Definition at line 39 of file Shape.h.

39 : _dims{}, _rank(list.size())
40 {
41 std::copy(list.begin(), list.end(), _dims.begin());
42 }

Member Function Documentation

◆ dim() [1/2]

size_t ndarray::Shape::dim ( int  i) const
inlinenoexcept

◆ dim() [2/2]

size_t & ndarray::Shape::dim ( int  i)
inlinenoexcept

Definition at line 46 of file Shape.h.

46{ return _dims.at(i); }

◆ element_count()

size_t ndarray::Shape::element_count ( ) const
inlinenoexcept

Definition at line 48 of file Shape.h.

49 {
50 uint32_t res = 1;
51 for (size_t i = 0; i < rank(); ++i)
52 res *= dim(i);
53 assert(res <= 0xffffffff);
54 return res;
55 }
size_t dim(int i) const noexcept
Definition Shape.h:44

References dim(), and rank().

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

◆ rank()

size_t ndarray::Shape::rank ( ) const
inlinenoexcept

Definition at line 57 of file Shape.h.

57{ return _rank; }

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


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