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

#include <Tensor.h>

Public Member Functions

 Shape (int rank)
 
 Shape (std::initializer_list< int32_t > dims)
 
int num_dims () const
 
int32_t dim (int i) const
 
int32_t & dim (int i)
 
int32_t num_elements () const
 
int64_t large_num_elements () const
 
bool operator== (const Shape &other) const
 
bool operator!= (const Shape &other) const
 

Detailed Description

Definition at line 32 of file Tensor.h.

Constructor & Destructor Documentation

◆ Shape() [1/2]

luci_interpreter::Shape::Shape ( int  rank)
inlineexplicit

Definition at line 35 of file Tensor.h.

35: _dims(rank, 0) {}

◆ Shape() [2/2]

luci_interpreter::Shape::Shape ( std::initializer_list< int32_t >  dims)
inline

Definition at line 37 of file Tensor.h.

37: _dims(dims.begin(), dims.end()) {}
std::vector< int > dims(const std::string &src)
Definition Utils.h:35

Member Function Documentation

◆ dim() [1/2]

int32_t & luci_interpreter::Shape::dim ( int  i)
inline

Definition at line 47 of file Tensor.h.

48 {
49 assert(i >= 0 && i < static_cast<int>(_dims.size()));
50 return _dims[i];
51 }
T must_cast(loco::Node *node)

References luci::must_cast().

◆ dim() [2/2]

int32_t luci_interpreter::Shape::dim ( int  i) const
inline

◆ large_num_elements()

int64_t luci_interpreter::Shape::large_num_elements ( ) const
inline

Definition at line 64 of file Tensor.h.

65 {
66 int64_t result = 1;
67 for (const int32_t dim : _dims)
68 {
69 result *= dim;
70 }
71 return result;
72 }
int32_t dim(int i) const
Definition Tensor.h:41
result
Definition infer.py:103

References dim(), and luci::must_cast().

◆ num_dims()

int luci_interpreter::Shape::num_dims ( ) const
inline

Definition at line 39 of file Tensor.h.

39{ return _dims.size(); }

Referenced by luci_interpreter::kernels::calculateShapeForBroadcast(), luci_interpreter::kernels::ArgMax::configure(), luci_interpreter::kernels::BatchToSpaceND::configure(), luci_interpreter::kernels::BroadcastTo::configure(), luci_interpreter::kernels::ExpandDims::configure(), luci_interpreter::kernels::Mean::configure(), luci_interpreter::kernels::MirrorPad::configure(), luci_interpreter::kernels::OneHot::configure(), luci_interpreter::kernels::Pack::configure(), luci_interpreter::kernels::Pad::configure(), luci_interpreter::kernels::PadV2::configure(), luci_interpreter::kernels::PRelu::configure(), luci_interpreter::kernels::ReduceMax::configure(), luci_interpreter::kernels::ReduceProd::configure(), luci_interpreter::kernels::RmsNorm::configure(), luci_interpreter::kernels::Select::configure(), luci_interpreter::kernels::SpaceToBatchND::configure(), luci_interpreter::kernels::Split::configure(), luci_interpreter::kernels::SplitV::configure(), luci_interpreter::kernels::Squeeze::configure(), luci_interpreter::kernels::StridedSlice::configure(), luci_interpreter::kernels::Sum::configure(), luci_interpreter::kernels::Transpose::configure(), luci_interpreter::kernels::Unpack::configure(), luci_interpreter::kernels::testing::dequantizeTensorData(), luci_interpreter::kernels::Pad::execute(), luci_interpreter::kernels::PadV2::execute(), luci_interpreter::kernels::StridedSlice::execute(), luci_interpreter::kernels::getTensorShape(), and luci_interpreter::kernels::testing::makeInputTensor().

◆ num_elements()

◆ operator!=()

bool luci_interpreter::Shape::operator!= ( const Shape other) const
inline

Definition at line 76 of file Tensor.h.

76{ return !operator==(other); }
bool operator==(const Shape &other) const
Definition Tensor.h:74

References luci::must_cast(), and operator==().

◆ operator==()

bool luci_interpreter::Shape::operator== ( const Shape other) const
inline

Definition at line 74 of file Tensor.h.

74{ return _dims == other._dims; }

References luci::must_cast().

Referenced by operator!=().


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