ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert_micro::core::OMRuntimeShape Class Reference

#include <OMRuntimeShape.h>

Public Member Functions

 OMRuntimeShape (const OMRuntimeShape &other)
 
 OMRuntimeShape (const circle::Tensor *tensor)
 
int flatSize () const
 
int32_t * dimsData ()
 
const int32_t * dimsData () const
 
 OMRuntimeShape ()
 
 OMRuntimeShape (int dimensions_count)
 
 OMRuntimeShape (int dimensions_count, const int32_t *dims_data)
 
 OMRuntimeShape (int new_shape_size, const OMRuntimeShape &shape, int pad_value)
 
 OMRuntimeShape (int shape_size, int32_t value)
 
bool operator== (const OMRuntimeShape &comp) const
 
int32_t dimensionsCount () const
 
int32_t dims (int i) const
 
void setDim (int i, int32_t val)
 
void resize (int dimensions_count)
 

Static Public Member Functions

static OMRuntimeShape extendedShape (int new_shape_size, const OMRuntimeShape &shape)
 

Detailed Description

Definition at line 33 of file OMRuntimeShape.h.

Constructor & Destructor Documentation

◆ OMRuntimeShape() [1/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( const OMRuntimeShape other)
inline

Definition at line 40 of file OMRuntimeShape.h.

40 : _size(other.dimensionsCount())
41 {
42 std::memcpy(dimsData(), other.dimsData(), sizeof(int32_t) * _size);
43 }

References dimsData().

◆ OMRuntimeShape() [2/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( const circle::Tensor *  tensor)
inline

Definition at line 45 of file OMRuntimeShape.h.

46 {
47 if (tensor == nullptr)
48 return;
49
50 // Shape is scalar
51 if (tensor->shape() == nullptr or tensor->shape()->size() == 0)
52 {
53 _size = 1;
54 _dims[0] = 1;
55 return;
56 }
57
58 _size = tensor->shape()->size();
59 std::memcpy(_dims, tensor->shape()->data(), sizeof(int32_t) * _size);
60 }

◆ OMRuntimeShape() [3/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( )
inline

Definition at line 80 of file OMRuntimeShape.h.

80: _size(0) {}

Referenced by extendedShape().

◆ OMRuntimeShape() [4/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( int  dimensions_count)
inlineexplicit

Definition at line 82 of file OMRuntimeShape.h.

82 : _size(dimensions_count)
83 {
84 assert(dimensions_count <= maxTensorShapeSize);
85 assert(dimensions_count >= 0);
86 }

◆ OMRuntimeShape() [5/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( int  dimensions_count,
const int32_t *  dims_data 
)
inline

Definition at line 88 of file OMRuntimeShape.h.

88 : _size(0)
89 {
90 resize(dimensions_count);
91 int32_t *dst_dims = dimsData();
92 std::memcpy(dst_dims, dims_data, dimensions_count * sizeof(int32_t));
93 }
void resize(int dimensions_count)

References dimsData(), and resize().

◆ OMRuntimeShape() [6/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( int  new_shape_size,
const OMRuntimeShape shape,
int  pad_value 
)
inline

Definition at line 95 of file OMRuntimeShape.h.

95 : _size(0)
96 {
97 resize(new_shape_size);
98 const int size_increase = new_shape_size - shape.dimensionsCount();
99 for (int i = 0; i < size_increase; ++i)
100 {
101 setDim(i, pad_value);
102 }
103 std::memcpy(dimsData() + size_increase, shape.dimsData(),
104 sizeof(int32_t) * shape.dimensionsCount());
105 }
void setDim(int i, int32_t val)

References dimensionsCount(), dimsData(), resize(), and setDim().

◆ OMRuntimeShape() [7/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( int  shape_size,
int32_t  value 
)
inline

Definition at line 107 of file OMRuntimeShape.h.

107 : _size(0)
108 {
109 resize(shape_size);
110 for (int i = 0; i < shape_size; ++i)
111 {
112 setDim(i, value);
113 }
114 }

References resize(), and setDim().

Member Function Documentation

◆ dimensionsCount()

◆ dims()

int32_t onert_micro::core::OMRuntimeShape::dims ( int  i) const
inline

Definition at line 129 of file OMRuntimeShape.h.

130 {
131 assert(i <= _size);
132 assert(i >= 0);
133 return _dims[i];
134 }

Referenced by onert_micro::execute::pal::ArgMinMax(), onert_micro::execute::pal::AveragePool(), onert_micro::execute::pal::AveragePool(), onert_micro::execute::pal::BatchToSpaceND(), onert_micro::execute::pal::BroadcastArithmeticOp4DSlow(), onert_micro::execute::pal::BroadcastBinaryOp4DSlow(), onert_micro::train::pal::Conv2DBiasGrad(), onert_micro::train::pal::Conv2DInputGrad(), onert_micro::train::pal::Conv2DWeightGrad(), onert_micro::execute::pal::ConvFloat(), onert_micro::execute::pal::ConvPerChannel(), onert_micro::execute::pal::copyDimsToDesc(), onert_micro::execute::pal::DepthwiseConv2D< float >(), onert_micro::execute::pal::DepthwiseConvPerChannel(), onert_micro::execute::pal::Floor(), onert_micro::execute::pal::FullyConnected(), onert_micro::execute::pal::FullyConnected(), onert_micro::execute::pal::FullyConnected(), onert_micro::execute::pal::FullyConnected< int8_t >(), onert_micro::train::pal::FullyConnectedInputGrad(), onert_micro::train::pal::FullyConnectedWeightGrad(), onert_micro::execute::pal::GatherND(), onert_micro::execute::pal::GRU(), onert_micro::train::pal::GRUWeightGrads(), onert_micro::execute::pal::L2Pool(), onert_micro::execute::pal::MatchingDim(), onert_micro::execute::pal::MaxPool(), onert_micro::execute::pal::MaxPool(), onert_micro::train::pal::MaxPool2D(), onert_micro::execute::pal::Slice(), onert_micro::train::pal::SoftmaxInputGrad(), onert_micro::execute::pal::SpaceToBatchND(), onert_micro::execute::pal::SpaceToDepth(), onert_micro::execute::pal::Split(), onert_micro::execute::pal::StridedSlice(), onert_micro::execute::pal::SVDF(), onert_micro::execute::pal::TransposeConv< float >(), onert_micro::execute::pal::Unpack(), onert_micro::train::optimizers::Adam::updateWeights(), and onert_micro::train::optimizers::SGD::updateWeights().

◆ dimsData() [1/2]

◆ dimsData() [2/2]

const int32_t * onert_micro::core::OMRuntimeShape::dimsData ( ) const
inline

Definition at line 78 of file OMRuntimeShape.h.

78{ return _dims; }

◆ extendedShape()

◆ flatSize()

int onert_micro::core::OMRuntimeShape::flatSize ( ) const
inline

Definition at line 64 of file OMRuntimeShape.h.

65 {
66 if (_size == 0)
67 return 0;
68 int buffer_size = 1;
69 const int *dims_data = reinterpret_cast<const int *>(dimsData());
70 for (int i = 0; i < _size; i++)
71 {
72 buffer_size *= dims_data[i];
73 }
74 return buffer_size;
75 }

References dimsData().

Referenced by onert_micro::execute::pal::Abs(), onert_micro::core::memory::OMRuntimeAllocator::allocate(), onert_micro::core::memory::OMRuntimeAllocator::allocateGraphInputs(), onert_micro::execute::pal::Cast(), onert_micro::execute::pal::Ceil(), onert_micro::core::memory::OMRuntimeAllocator::clearAllTensorsData(), onert_micro::import::helpers::configure_arg_kernel_common(), onert_micro::train::pal::Conv2DBiasGrad(), onert_micro::train::pal::Conv2DInputGrad(), onert_micro::train::pal::Conv2DWeightGrad(), onert_micro::execute::pal::Cos(), onert_micro::execute::evalComparisonGeneric(), onert_micro::execute::evalQuantizedComparisonGeneric(), onert_micro::core::train::OMTrainingHandler::evaluateMetric(), onert_micro::execute::execute_relu_common(), onert_micro::execute::execute_reshape_common(), onert_micro::execute::pal::Exp(), onert_micro::execute::pal::Floor(), onert_micro::execute::pal::GatherND(), onert_micro::core::OMRuntimeGraph::getInputSizeAt(), onert_micro::core::OMRuntimeGraph::getOutputSizeAt(), onert_micro::train::pal::GRUWeightGrads(), onert_micro::train::optimizers::Adam::handle(), onert_micro::train::optimizers::SGD::handle(), onert_micro::core::train::OMTrainingHandler::handleError(), onert_micro::execute::pal::Log(), onert_micro::execute::pal::Neg(), onert_micro::execute::pal::processBroadcastShapes(), onert_micro::train::pal::ReluInputGrad(), onert_micro::execute::pal::Round< float >(), onert_micro::execute::pal::Sin(), onert_micro::execute::pal::SISOOperation(), onert_micro::execute::pal::Sqrt(), onert_micro::execute::pal::Square(), onert_micro::execute::pal::Tanh(), onert_micro::execute::pal::UnaryOp(), onert_micro::train::optimizers::Adam::updateWeights(), and onert_micro::train::optimizers::SGD::updateWeights().

◆ operator==()

bool onert_micro::core::OMRuntimeShape::operator== ( const OMRuntimeShape comp) const
inline

Definition at line 121 of file OMRuntimeShape.h.

122 {
123 return this->_size == comp._size &&
124 std::memcmp(dimsData(), comp.dimsData(), _size * sizeof(int32_t)) == 0;
125 }

References dimsData().

◆ resize()

void onert_micro::core::OMRuntimeShape::resize ( int  dimensions_count)
inline

Definition at line 143 of file OMRuntimeShape.h.

144 {
145 assert(dimensions_count <= maxTensorShapeSize);
146 assert(dimensions_count >= 0);
147 _size = dimensions_count;
148 }

Referenced by OMRuntimeShape(), OMRuntimeShape(), and OMRuntimeShape().

◆ setDim()

void onert_micro::core::OMRuntimeShape::setDim ( int  i,
int32_t  val 
)
inline

Definition at line 136 of file OMRuntimeShape.h.

137 {
138 assert(i <= _size);
139 assert(i >= 0);
140 _dims[i] = val;
141 }

Referenced by onert_micro::execute::pal::GRU(), onert_micro::train::pal::GRUWeightGrads(), OMRuntimeShape(), and OMRuntimeShape().


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