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

#include <OMRuntimeShape.h>

Public Member Functions

 OMRuntimeShape ()=default
 
 OMRuntimeShape (const OMRuntimeShape &other)
 
 OMRuntimeShape (size_t dimensions_count)
 
template<size_t DimsCount>
 OMRuntimeShape (const std::array< int32_t, DimsCount > &source_dims)
 
 OMRuntimeShape (const circle::Tensor *tensor)
 
 OMRuntimeShape (size_t new_shape_size, const OMRuntimeShape &shape, int32_t pad_value)
 
 OMRuntimeShape (size_t shape_size, int32_t value)
 
bool operator== (const OMRuntimeShape &other) const
 
size_t flatSize () const
 
bool isScalar () const noexcept
 
int32_t * dimsData ()
 
const int32_t * dimsData () const
 
size_t dimensionsCount () const noexcept
 
int32_t dims (size_t i) const
 
void setDim (size_t i, int32_t val)
 
void resize (size_t dimensions_count)
 

Static Public Member Functions

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

Detailed Description

Definition at line 30 of file OMRuntimeShape.h.

Constructor & Destructor Documentation

◆ OMRuntimeShape() [1/7]

onert_micro::core::OMRuntimeShape::OMRuntimeShape ( )
default

Referenced by extendedShape().

◆ OMRuntimeShape() [2/7]

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

Definition at line 44 of file OMRuntimeShape.h.

45 : _size(other._size)
46 , _dims(other._dims)
47 {}

◆ OMRuntimeShape() [3/7]

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

Definition at line 49 of file OMRuntimeShape.h.

50 {
51 resize(dimensions_count);
52 }
void resize(size_t dimensions_count)

References resize().

◆ OMRuntimeShape() [4/7]

template<size_t DimsCount>
onert_micro::core::OMRuntimeShape::OMRuntimeShape ( const std::array< int32_t, DimsCount > &  source_dims)
inlineexplicit

Definition at line 55 of file OMRuntimeShape.h.

56 {
57 resize(DimsCount);
58 std::copy(source_dims.cbegin(), source_dims.cend(), _dims.begin());
59 }

References resize().

◆ OMRuntimeShape() [5/7]

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

Definition at line 63 of file OMRuntimeShape.h.

64 {
65 if (tensor == nullptr)
66 return;
67
68 auto shape = tensor->shape();
69
70 if (shape == nullptr || shape->size() == 0)
71 {
72 _is_scalar = true;
73 _size = 1;
74 _dims[0] = 1;
75
76 return;
77 }
78
79 _size = shape->size();
80 std::copy(shape->cbegin(), shape->cend(), _dims.begin());
81 }

◆ OMRuntimeShape() [6/7]

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

Definition at line 83 of file OMRuntimeShape.h.

84 {
85 assert(new_shape_size >= shape._size);
86 resize(new_shape_size);
87
88 const size_t size_increase = new_shape_size - shape._size;
89
90 for (auto i = 0u; i < size_increase; ++i)
91 {
92 setDim(i, pad_value);
93 }
94
95 auto from = shape._dims.cbegin();
96 auto to = _dims.begin() + size_increase;
97
98 std::copy(from, from + shape._size, to);
99 }
void setDim(size_t i, int32_t val)

References resize(), and setDim().

◆ OMRuntimeShape() [7/7]

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

Definition at line 101 of file OMRuntimeShape.h.

102 {
103 resize(shape_size);
104
105 for (auto i = 0u; i < shape_size; ++i)
106 {
107 setDim(i, value);
108 }
109 }

References resize(), and setDim().

Member Function Documentation

◆ dimensionsCount()

size_t onert_micro::core::OMRuntimeShape::dimensionsCount ( ) const
inlinenoexcept

Definition at line 148 of file OMRuntimeShape.h.

149 {
150 return _size;
151 }

Referenced by onert_micro::execute::pal::ArgMinMax(), onert_micro::execute::pal::BatchToSpaceND(), onert_micro::import::helpers::configure_arg_kernel_common(), onert_micro::import::configure_kernel_CircleConcatenation(), onert_micro::import::configure_kernel_CircleConv2D(), onert_micro::import::configure_kernel_CircleDepthwiseConv2D(), onert_micro::import::configure_kernel_CircleExpandDims(), onert_micro::import::configure_kernel_CircleFill(), onert_micro::import::configure_kernel_CircleFullyConnected(), onert_micro::import::configure_kernel_CircleGather(), onert_micro::import::configure_kernel_CircleGatherND(), onert_micro::import::configure_kernel_CircleGRU(), onert_micro::import::configure_kernel_CircleLogicalAnd(), onert_micro::import::configure_kernel_CircleLogicalOr(), onert_micro::import::configure_kernel_CirclePack(), onert_micro::import::configure_kernel_CircleSoftmax(), onert_micro::import::configure_kernel_CircleSplit(), onert_micro::import::configure_kernel_CircleSplitV(), onert_micro::import::configure_kernel_CircleSVDF(), onert_micro::import::configure_kernel_CircleTranspose(), onert_micro::import::configure_kernel_CircleTransposeConv(), onert_micro::import::configure_kernel_CircleUnpack(), onert_micro::import::helpers::configure_pooling_kernel_common(), onert_micro::import::helpers::configure_spaces_batches_nd_kernel_common(), onert_micro::train::pal::Conv2DBiasGrad(), onert_micro::core::OMBaseContext::DimsCount(), onert_micro::execute::execute_kernel_CircleGather(), onert_micro::execute::execute_kernel_CircleL2Normalize(), onert_micro::execute::execute_kernel_CircleLogSoftmax(), onert_micro::execute::execute_kernel_CirclePad(), onert_micro::execute::execute_kernel_CircleShape(), onert_micro::execute::execute_kernel_CircleSlice(), onert_micro::execute::execute_kernel_CircleSoftmax(), onert_micro::execute::execute_kernel_CircleSplit(), onert_micro::execute::execute_kernel_CircleSplitV(), onert_micro::execute::execute_kernel_CircleStridedSlice(), onert_micro::execute::execute_kernel_CircleTranspose(), 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::execute::pal::GatherND(), onert_micro::train::pal::GRUWeightGrads(), onert_micro::execute::pal::processBroadcastShapes(), onert_micro::execute::pal::ReduceDimensionsForBroadcast(), onert_micro::train::pal::SoftmaxInputGrad(), onert_micro::execute::pal::SpaceToBatchND(), onert_micro::execute::pal::Split(), onert_micro::execute::pal::TransposeImpl(), and onert_micro::execute::pal::Unpack().

◆ dims()

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

Definition at line 153 of file OMRuntimeShape.h.

154 {
155 assert(i <= _size);
156 return _dims[i];
157 }

Referenced by onert_micro::execute::pal::ArgMinMax(), onert_micro::execute::pal::AveragePool(), onert_micro::execute::pal::AveragePool(), onert_micro::execute::pal::BatchMatMul(), onert_micro::execute::pal::BatchToSpaceND(), onert_micro::execute::pal::BroadcastArithmeticOp4DSlow(), onert_micro::execute::pal::BroadcastBinaryOp4DSlow(), onert_micro::import::configure_kernel_CircleConv2D(), onert_micro::import::configure_kernel_CircleDepthwiseConv2D(), onert_micro::import::configure_kernel_CircleFullyConnected(), onert_micro::import::configure_kernel_CircleGather(), onert_micro::import::configure_kernel_CircleGatherND(), onert_micro::import::configure_kernel_CircleGRU(), onert_micro::import::configure_kernel_CircleSpaceToDepth(), onert_micro::import::configure_kernel_CircleSVDF(), onert_micro::import::configure_kernel_CircleTranspose(), onert_micro::import::configure_kernel_CircleUnpack(), 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::execute_kernel_CircleConv2D(), onert_micro::execute::execute_kernel_CircleDepthwiseConv2D(), onert_micro::execute::execute_kernel_CircleGather(), onert_micro::execute::execute_kernel_CircleGRU(), onert_micro::execute::execute_kernel_CircleL2Normalize(), onert_micro::execute::execute_kernel_CircleLogSoftmax(), onert_micro::execute::execute_kernel_CircleShape(), onert_micro::execute::execute_kernel_CircleSoftmax(), onert_micro::execute::execute_kernel_CircleSVDF(), onert_micro::execute::execute_kernel_CircleTranspose(), onert_micro::execute::execute_kernel_CircleTransposeConv(), onert_micro::execute::execute_pooling_common(), 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::MeanROWH(), onert_micro::execute::pal::QuantizedBroadcastArithmeticOp4DSlow(), 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 143 of file OMRuntimeShape.h.

144 {
145 return _dims.data();
146 }

◆ extendedShape()

◆ flatSize()

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

Definition at line 121 of file OMRuntimeShape.h.

122 {
123 if (_size == 0)
124 return 0;
125
126 auto it = _dims.cbegin();
127
128 return std::accumulate(it, it + _size, 1u, std::multiplies<size_t>());
129 }

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::import::configure_kernel_CircleConv2D(), onert_micro::import::configure_kernel_CircleFill(), onert_micro::import::configure_kernel_CircleFullyConnected(), onert_micro::import::configure_kernel_CircleLogicalAnd(), onert_micro::import::configure_kernel_CircleLogicalOr(), onert_micro::import::configure_kernel_CircleReshape(), 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_kernel_CircleAdd(), onert_micro::execute::execute_kernel_CircleDiv(), onert_micro::execute::execute_kernel_CircleElu(), onert_micro::execute::execute_kernel_CircleFloorDiv(), onert_micro::execute::execute_kernel_CircleFloorMod(), onert_micro::execute::execute_kernel_CircleGRU(), onert_micro::execute::execute_kernel_CircleLogicalAnd(), onert_micro::execute::execute_kernel_CircleLogicalNot(), onert_micro::execute::execute_kernel_CircleLogicalOr(), onert_micro::execute::execute_kernel_CircleMaximum(), onert_micro::execute::execute_kernel_CircleMinimum(), onert_micro::execute::execute_kernel_CircleMul(), onert_micro::execute::execute_kernel_CircleSelectV2(), onert_micro::execute::execute_kernel_CircleSquaredDifference(), onert_micro::execute::execute_kernel_CircleSub(), onert_micro::execute::execute_kernel_CircleSVDF(), onert_micro::execute::execute_kernel_CircleWhile(), onert_micro::execute::execute_kernel_CircleZerosLike(), 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::core::OMTensorData< T >::OMTensorData(), onert_micro::execute::pal::processBroadcastShapes(), onert_micro::execute::pal::QuantizedTanh(), onert_micro::train::pal::ReluInputGrad(), onert_micro::execute::pal::Round< float >(), onert_micro::execute::pal::Select(), onert_micro::core::OMBaseContext::ShapeFlatSize(), onert_micro::execute::pal::Sin(), onert_micro::execute::pal::SISOOperation(), 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().

◆ isScalar()

bool onert_micro::core::OMRuntimeShape::isScalar ( ) const
inlinenoexcept

Definition at line 133 of file OMRuntimeShape.h.

134 {
135 return _is_scalar;
136 }

◆ operator==()

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

Definition at line 116 of file OMRuntimeShape.h.

117 {
118 return _size == other._size && _dims == other._dims;
119 }

◆ resize()

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

Definition at line 165 of file OMRuntimeShape.h.

166 {
167 assert(dimensions_count <= kMaxDimsCount);
168 _size = dimensions_count;
169 }

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

◆ setDim()

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

Definition at line 159 of file OMRuntimeShape.h.

160 {
161 assert(i <= _size);
162 _dims[i] = val;
163 }

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: