ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::cker::reference Namespace Reference

Functions

void BatchMatMul (const BatchMatMulParams &params, const float *lhs_data, const float *rhs_data, float *output_data)
 
template<typename T >
void BinaryArithmeticOp (const BinaryArithmeticOpParam &params, const Shape &input1_shape, const T *input1_data, const Shape &input2_shape, const T *input2_data, const Shape &output_shape, T *output_data, const std::function< T(const T &, const T &)> &fn)
 
template<>
void BinaryArithmeticOp (const BinaryArithmeticOpParam &params, const Shape &input1_shape, const float *input1_data, const Shape &input2_shape, const float *input2_data, const Shape &output_shape, float *output_data, const std::function< float(const float &, const float &)> &fn)
 
template<>
void BinaryArithmeticOp (const BinaryArithmeticOpParam &, const Shape &input1_shape, const bool *input1_data, const Shape &input2_shape, const bool *input2_data, const Shape &output_shape, bool *output_data, const std::function< bool(const bool &, const bool &)> &fn)
 
template<>
void BinaryArithmeticOp (const BinaryArithmeticOpParam &params, const Shape &input1_shape, const int64_t *input1_data, const Shape &input2_shape, const int64_t *input2_data, const Shape &output_shape, int64_t *output_data, const std::function< int64_t(const int64_t &, const int64_t &)> &fn)
 
template<typename T >
std::enable_if_t< is_quant8< T >::value > BroadcastBinaryArithmeticOpSlow (const BinaryArithmeticOpParam &params, const Shape &input1_shape, const T *input1_data, const Shape &input2_shape, const T *input2_data, const Shape &output_shape, T *output_data, const std::function< T(const BinaryArithmeticOpParam &params, const T &, const T &)> &fn)
 
template<typename T >
void BroadcastBinaryArithmeticOpSlow (const BinaryArithmeticOpParam &params, const Shape &input1_shape, const T *input1_data, const Shape &input2_shape, const T *input2_data, const Shape &output_shape, T *output_data, const std::function< T(const T &, const T &)> &fn)
 
template<>
void BroadcastBinaryArithmeticOpSlow (const BinaryArithmeticOpParam &params, const Shape &input1_shape, const float *input1_data, const Shape &input2_shape, const float *input2_data, const Shape &output_shape, float *output_data, const std::function< float(const float &, const float &)> &fn)
 
template<>
void BroadcastBinaryArithmeticOpSlow (const BinaryArithmeticOpParam &, const Shape &input1_shape, const bool *input1_data, const Shape &input2_shape, const bool *input2_data, const Shape &output_shape, bool *output_data, const std::function< bool(const bool &, const bool &)> &fn)
 
template<>
void BroadcastBinaryArithmeticOpSlow (const BinaryArithmeticOpParam &params, const Shape &input1_shape, const int64_t *input1_data, const Shape &input2_shape, const int64_t *input2_data, const Shape &output_shape, int64_t *output_data, const std::function< int64_t(const int64_t &, const int64_t &)> &fn)
 
void Conv (const ConvParams &params, const Shape &input_shape, const float *input_data, const Shape &filter_shape, const float *filter_data, const Shape &bias_shape, const float *bias_data, const Shape &output_shape, float *output_data)
 
void Conv (const ConvParams &params, const Shape &input_shape, const uint8_t *input_data, const Shape &filter_shape, const uint8_t *filter_data, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, uint8_t *output_data)
 
template<typename T , bool is_asymmetric>
void Conv (const ConvParams &params, const int32_t *output_multiplier, const int32_t *output_shift, const Shape &input_shape, const T *input_data, const Shape &filter_shape, const T *filter_data, const int32_t *filter_zeropoint, const Shape &bias_shape, const int32_t *bias_data, const Shape &output_shape, T *output_data)
 
void HybridConvPerChannel (const ConvParams &params, float *scaling_factors_ptr, const Shape &input_shape, const int8_t *input_data, const Shape &filter_shape, const int8_t *filter_data, const Shape &bias_shape, const float *bias_data, const Shape &output_shape, float *output_data, const float *per_channel_scale, const int32_t *input_offset)
 
void Softmax (const SoftmaxParams &params, const Shape &input_shape, const float *input_data, const Shape &output_shape, float *output_data)
 
template<typename T >
void TransposeImpl (const TransposeParams &params, const Shape &unextended_input_shape, const T *input_data, const Shape &unextended_output_shape, T *output_data)
 
template<typename T >
void Transpose (const TransposeParams &params, const Shape &unextended_input_shape, const T *input_data, const Shape &unextended_output_shape, T *output_data)
 

Variables

constexpr int kMaxBroadcastDim = 6
 

Function Documentation

◆ BatchMatMul()

void nnfw::cker::reference::BatchMatMul ( const BatchMatMulParams params,
const float *  lhs_data,
const float *  rhs_data,
float *  output_data 
)
inline

Definition at line 32 of file BatchMatMul.h.

34{
35 for (int b0 = 0; b0 < params.batch_dim0; ++b0)
36 {
37 const float *lhs_ptr0 = lhs_data + (b0 * params.lhs_ext0);
38 const float *rhs_ptr0 = rhs_data + (b0 * params.rhs_ext0);
39 for (int b1 = 0; b1 < params.batch_dim1; ++b1)
40 {
41 const float *lhs_ptr1 = lhs_ptr0 + b1 * params.lhs_ext1;
42 const float *rhs_ptr1 = rhs_ptr0 + b1 * params.rhs_ext1;
43 for (int b2 = 0; b2 < params.batch_dim2; ++b2)
44 {
45 const float *lhs_ptr2 = lhs_ptr1 + b2 * params.lhs_ext2;
46 const float *rhs_ptr2 = rhs_ptr1 + b2 * params.rhs_ext2;
47 float *out_ptr = output_data + ((b0 * params.batch_dim1 * params.batch_dim2) +
48 b1 * params.batch_dim2 + b2) *
49 params.lhs_rows * params.rhs_cols;
50 for (int j = 0; j < params.rhs_cols; ++j)
51 {
52 for (int i = 0; i < params.lhs_rows; ++i)
53 {
54 float total = 0.f;
55 for (int k = 0; k < params.accum_depth; ++k)
56 {
57 total += lhs_ptr2[params.accum_depth * i + k] * rhs_ptr2[j * params.accum_depth + k];
58 }
59 int idx = params.lhs_rows * j + i;
60 out_ptr[idx] = total;
61 }
62 }
63 }
64 }
65 }
66}

References nnfw::cker::BatchMatMulParams::accum_depth, nnfw::cker::BatchMatMulParams::batch_dim0, nnfw::cker::BatchMatMulParams::batch_dim1, nnfw::cker::BatchMatMulParams::batch_dim2, nnfw::cker::BatchMatMulParams::lhs_ext0, nnfw::cker::BatchMatMulParams::lhs_ext1, nnfw::cker::BatchMatMulParams::lhs_ext2, nnfw::cker::BatchMatMulParams::lhs_rows, nnfw::cker::BatchMatMulParams::rhs_cols, nnfw::cker::BatchMatMulParams::rhs_ext0, nnfw::cker::BatchMatMulParams::rhs_ext1, and nnfw::cker::BatchMatMulParams::rhs_ext2.

Referenced by nnfw::cker::BatchMatMul::operator()().

◆ BinaryArithmeticOp() [1/4]

template<>
void nnfw::cker::reference::BinaryArithmeticOp ( const BinaryArithmeticOpParam ,
const Shape input1_shape,
const bool *  input1_data,
const Shape input2_shape,
const bool *  input2_data,
const Shape output_shape,
bool *  output_data,
const std::function< bool(const bool &, const bool &)> &  fn 
)
inline

Definition at line 68 of file BinaryArithmeticOps.h.

73{
74 const int size = MatchingElementsSize(input1_shape, input2_shape, output_shape);
75 for (int i = 0; i < size; i++)
76 {
77 output_data[i] = fn(input1_data[i], input2_data[i]);
78 }
79}
const luci_interpreter::RuntimeShape output_shape
int MatchingElementsSize(const Shape &shape, const Shape &check_shape_0, const Shape &check_shape_1)
Definition Shape.h:448
int32_t size[5]
Definition Slice.cpp:35

References nnfw::cker::MatchingElementsSize(), output_shape, and size.

◆ BinaryArithmeticOp() [2/4]

template<>
void nnfw::cker::reference::BinaryArithmeticOp ( const BinaryArithmeticOpParam params,
const Shape input1_shape,
const float *  input1_data,
const Shape input2_shape,
const float *  input2_data,
const Shape output_shape,
float *  output_data,
const std::function< float(const float &, const float &)> &  fn 
)
inline

Definition at line 53 of file BinaryArithmeticOps.h.

58{
59 const int size = MatchingElementsSize(input1_shape, input2_shape, output_shape);
60 for (int i = 0; i < size; i++)
61 {
62 output_data[i] = ActivationFunctionWithMinMax(
63 fn(input1_data[i], input2_data[i]), params.float_activation_min, params.float_activation_max);
64 }
65}
T ActivationFunctionWithMinMax(T x, T output_activation_min, T output_activation_max)
Definition Utils.h:43

References nnfw::cker::ActivationFunctionWithMinMax(), nnfw::cker::BinaryArithmeticOpParam::float_activation_max, nnfw::cker::BinaryArithmeticOpParam::float_activation_min, nnfw::cker::MatchingElementsSize(), output_shape, and size.

◆ BinaryArithmeticOp() [3/4]

template<>
void nnfw::cker::reference::BinaryArithmeticOp ( const BinaryArithmeticOpParam params,
const Shape input1_shape,
const int64_t *  input1_data,
const Shape input2_shape,
const int64_t *  input2_data,
const Shape output_shape,
int64_t *  output_data,
const std::function< int64_t(const int64_t &, const int64_t &)> &  fn 
)
inline

Definition at line 82 of file BinaryArithmeticOps.h.

87{
88 const int flat_size = MatchingElementsSize(input1_shape, input2_shape, output_shape);
89 for (int i = 0; i < flat_size; ++i)
90 {
91 output_data[i] = ActivationFunctionWithMinMax(
92 fn(input1_data[i], input2_data[i]), params.int64_activation_min, params.int64_activation_max);
93 }
94}

References nnfw::cker::ActivationFunctionWithMinMax(), nnfw::cker::BinaryArithmeticOpParam::int64_activation_max, nnfw::cker::BinaryArithmeticOpParam::int64_activation_min, nnfw::cker::MatchingElementsSize(), and output_shape.

◆ BinaryArithmeticOp() [4/4]

template<typename T >
void nnfw::cker::reference::BinaryArithmeticOp ( const BinaryArithmeticOpParam params,
const Shape input1_shape,
const T *  input1_data,
const Shape input2_shape,
const T *  input2_data,
const Shape output_shape,
T *  output_data,
const std::function< T(const T &, const T &)> &  fn 
)
inline

Definition at line 38 of file BinaryArithmeticOps.h.

42{
43 const int32_t flat_size = MatchingElementsSize(input1_shape, input2_shape, output_shape);
44 for (int i = 0; i < flat_size; ++i)
45 {
46 output_data[i] = ActivationFunctionWithMinMax(fn(input1_data[i], input2_data[i]),
49 }
50}

References nnfw::cker::ActivationFunctionWithMinMax(), nnfw::cker::MatchingElementsSize(), output_shape, nnfw::cker::BinaryArithmeticOpParam::quantized_activation_max, and nnfw::cker::BinaryArithmeticOpParam::quantized_activation_min.

Referenced by nnfw::cker::BinaryArithmeticOp(), and nnfw::cker::optimized::Div().

◆ BroadcastBinaryArithmeticOpSlow() [1/5]

template<>
void nnfw::cker::reference::BroadcastBinaryArithmeticOpSlow ( const BinaryArithmeticOpParam ,
const Shape input1_shape,
const bool *  input1_data,
const Shape input2_shape,
const bool *  input2_data,
const Shape output_shape,
bool *  output_data,
const std::function< bool(const bool &, const bool &)> &  fn 
)
inline

Definition at line 231 of file BinaryArithmeticOps.h.

235{
238 NdArrayDescsForElementwiseBroadcast(input1_shape, input2_shape, &desc1, &desc2);
239 const Shape extended_output_shape = Shape::ExtendedShape(kMaxBroadcastDim, output_shape);
240
241 for (int d0 = 0; d0 < extended_output_shape.Dims(0); ++d0)
242 {
243 for (int d1 = 0; d1 < extended_output_shape.Dims(1); ++d1)
244 {
245 for (int d2 = 0; d2 < extended_output_shape.Dims(2); ++d2)
246 {
247 for (int d3 = 0; d3 < extended_output_shape.Dims(3); ++d3)
248 {
249 for (int d4 = 0; d4 < extended_output_shape.Dims(4); ++d4)
250 {
251 for (int d5 = 0; d5 < extended_output_shape.Dims(5); ++d5)
252 {
253 output_data[Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
254 fn(input1_data[SubscriptToIndex(desc1, d0, d1, d2, d3, d4, d5)],
255 input2_data[SubscriptToIndex(desc2, d0, d1, d2, d3, d4, d5)]);
256 }
257 }
258 }
259 }
260 }
261 }
262}
void NdArrayDescsForElementwiseBroadcast(const Dims< N > &input0_dims, const Dims< N > &input1_dims, NdArrayDesc< N > *desc0_out, NdArrayDesc< N > *desc1_out)
Definition NDArray.h:89
int SubscriptToIndex(const NdArrayDesc< 4 > &desc, int i0, int i1, int i2, int i3)
Definition NDArray.h:54
int Offset(const Dims< 4 > &dims, int i0, int i1, int i2, int i3)
Definition Dims.h:64
int32_t Dims(int i) const
Definition Shape.h:106
NdArrayDesc< 4 > desc1
NdArrayDesc< 4 > desc2

References desc1, desc2, nnfw::cker::Shape::Dims(), kMaxBroadcastDim, nnfw::cker::NdArrayDescsForElementwiseBroadcast(), nnfw::cker::Offset(), output_shape, and nnfw::cker::SubscriptToIndex().

◆ BroadcastBinaryArithmeticOpSlow() [2/5]

template<>
void nnfw::cker::reference::BroadcastBinaryArithmeticOpSlow ( const BinaryArithmeticOpParam params,
const Shape input1_shape,
const float *  input1_data,
const Shape input2_shape,
const float *  input2_data,
const Shape output_shape,
float *  output_data,
const std::function< float(const float &, const float &)> &  fn 
)
inline

Definition at line 195 of file BinaryArithmeticOps.h.

199{
202 NdArrayDescsForElementwiseBroadcast(input1_shape, input2_shape, &desc1, &desc2);
203 const Shape extended_output_shape = Shape::ExtendedShape(kMaxBroadcastDim, output_shape);
204
205 for (int d0 = 0; d0 < extended_output_shape.Dims(0); ++d0)
206 {
207 for (int d1 = 0; d1 < extended_output_shape.Dims(1); ++d1)
208 {
209 for (int d2 = 0; d2 < extended_output_shape.Dims(2); ++d2)
210 {
211 for (int d3 = 0; d3 < extended_output_shape.Dims(3); ++d3)
212 {
213 for (int d4 = 0; d4 < extended_output_shape.Dims(4); ++d4)
214 {
215 for (int d5 = 0; d5 < extended_output_shape.Dims(5); ++d5)
216 {
217 output_data[Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
219 fn(input1_data[SubscriptToIndex(desc1, d0, d1, d2, d3, d4, d5)],
220 input2_data[SubscriptToIndex(desc2, d0, d1, d2, d3, d4, d5)]),
222 }
223 }
224 }
225 }
226 }
227 }
228}

References nnfw::cker::ActivationFunctionWithMinMax(), desc1, desc2, nnfw::cker::Shape::Dims(), nnfw::cker::BinaryArithmeticOpParam::float_activation_max, nnfw::cker::BinaryArithmeticOpParam::float_activation_min, kMaxBroadcastDim, nnfw::cker::NdArrayDescsForElementwiseBroadcast(), nnfw::cker::Offset(), output_shape, and nnfw::cker::SubscriptToIndex().

◆ BroadcastBinaryArithmeticOpSlow() [3/5]

template<>
void nnfw::cker::reference::BroadcastBinaryArithmeticOpSlow ( const BinaryArithmeticOpParam params,
const Shape input1_shape,
const int64_t *  input1_data,
const Shape input2_shape,
const int64_t *  input2_data,
const Shape output_shape,
int64_t *  output_data,
const std::function< int64_t(const int64_t &, const int64_t &)> &  fn 
)
inline

Definition at line 265 of file BinaryArithmeticOps.h.

269{
272 NdArrayDescsForElementwiseBroadcast(input1_shape, input2_shape, &desc1, &desc2);
273 const Shape extended_output_shape = Shape::ExtendedShape(kMaxBroadcastDim, output_shape);
274
275 for (int d0 = 0; d0 < extended_output_shape.Dims(0); ++d0)
276 {
277 for (int d1 = 0; d1 < extended_output_shape.Dims(1); ++d1)
278 {
279 for (int d2 = 0; d2 < extended_output_shape.Dims(2); ++d2)
280 {
281 for (int d3 = 0; d3 < extended_output_shape.Dims(3); ++d3)
282 {
283 for (int d4 = 0; d4 < extended_output_shape.Dims(4); ++d4)
284 {
285 for (int d5 = 0; d5 < extended_output_shape.Dims(5); ++d5)
286 {
287 output_data[Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
289 fn(input1_data[SubscriptToIndex(desc1, d0, d1, d2, d3, d4, d5)],
290 input2_data[SubscriptToIndex(desc2, d0, d1, d2, d3, d4, d5)]),
292 }
293 }
294 }
295 }
296 }
297 }
298}

References nnfw::cker::ActivationFunctionWithMinMax(), desc1, desc2, nnfw::cker::Shape::Dims(), nnfw::cker::BinaryArithmeticOpParam::int64_activation_max, nnfw::cker::BinaryArithmeticOpParam::int64_activation_min, kMaxBroadcastDim, nnfw::cker::NdArrayDescsForElementwiseBroadcast(), nnfw::cker::Offset(), output_shape, and nnfw::cker::SubscriptToIndex().

◆ BroadcastBinaryArithmeticOpSlow() [4/5]

template<typename T >
std::enable_if_t< is_quant8< T >::value > nnfw::cker::reference::BroadcastBinaryArithmeticOpSlow ( const BinaryArithmeticOpParam params,
const Shape input1_shape,
const T *  input1_data,
const Shape input2_shape,
const T *  input2_data,
const Shape output_shape,
T *  output_data,
const std::function< T(const BinaryArithmeticOpParam &params, const T &, const T &)> &  fn 
)
inline

Definition at line 97 of file BinaryArithmeticOps.h.

101{
104 NdArrayDescsForElementwiseBroadcast(input1_shape, input2_shape, &desc1, &desc2);
105 const Shape extended_output_shape = Shape::ExtendedShape(kMaxBroadcastDim, output_shape);
106
107 // Comment from tensorflow lite:
108 //
109 // In Tensorflow, the dimensions are canonically named (batch_number, row,
110 // col, channel), with extents (batches, height, width, depth), with the
111 // trailing dimension changing most rapidly (channels has the smallest stride,
112 // typically 1 element).
113 //
114 // In generated C code, we store arrays with the dimensions reversed. The
115 // first dimension has smallest stride.
116 //
117 // We name our variables by their Tensorflow convention, but generate C code
118 // nesting loops such that the innermost loop has the smallest stride for the
119 // best cache behavior.
120 for (int d0 = 0; d0 < extended_output_shape.Dims(0); ++d0)
121 {
122 for (int d1 = 0; d1 < extended_output_shape.Dims(1); ++d1)
123 {
124 for (int d2 = 0; d2 < extended_output_shape.Dims(2); ++d2)
125 {
126 for (int d3 = 0; d3 < extended_output_shape.Dims(3); ++d3)
127 {
128 for (int d4 = 0; d4 < extended_output_shape.Dims(4); ++d4)
129 {
130 for (int d5 = 0; d5 < extended_output_shape.Dims(5); ++d5)
131 {
132 output_data[Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
133 ActivationFunctionWithMinMax<T>(
134 fn(params, input1_data[SubscriptToIndex(desc1, d0, d1, d2, d3, d4, d5)],
135 input2_data[SubscriptToIndex(desc2, d0, d1, d2, d3, d4, d5)]),
137 }
138 }
139 }
140 }
141 }
142 }
143}

References desc1, desc2, nnfw::cker::Shape::Dims(), kMaxBroadcastDim, nnfw::cker::NdArrayDescsForElementwiseBroadcast(), nnfw::cker::Offset(), output_shape, nnfw::cker::BinaryArithmeticOpParam::quantized_activation_max, nnfw::cker::BinaryArithmeticOpParam::quantized_activation_min, and nnfw::cker::SubscriptToIndex().

Referenced by nnfw::cker::optimized::BroadcastAddDispatch(), nnfw::cker::optimized::BroadcastAddDispatch(), nnfw::cker::BroadcastBinaryArithmeticOp(), nnfw::cker::optimized::BroadcastDivDispatch(), nnfw::cker::optimized::BroadcastMulDispatch(), nnfw::cker::optimized::BroadcastMulDispatch(), and nnfw::cker::optimized::BroadcastSubDispatch().

◆ BroadcastBinaryArithmeticOpSlow() [5/5]

template<typename T >
void nnfw::cker::reference::BroadcastBinaryArithmeticOpSlow ( const BinaryArithmeticOpParam params,
const Shape input1_shape,
const T *  input1_data,
const Shape input2_shape,
const T *  input2_data,
const Shape output_shape,
T *  output_data,
const std::function< T(const T &, const T &)> &  fn 
)
inline

Definition at line 145 of file BinaryArithmeticOps.h.

150{
153 NdArrayDescsForElementwiseBroadcast(input1_shape, input2_shape, &desc1, &desc2);
154 const Shape extended_output_shape = Shape::ExtendedShape(kMaxBroadcastDim, output_shape);
155
156 // Comment from tensorflow lite:
157 //
158 // In Tensorflow, the dimensions are canonically named (batch_number, row,
159 // col, channel), with extents (batches, height, width, depth), with the
160 // trailing dimension changing most rapidly (channels has the smallest stride,
161 // typically 1 element).
162 //
163 // In generated C code, we store arrays with the dimensions reversed. The
164 // first dimension has smallest stride.
165 //
166 // We name our variables by their Tensorflow convention, but generate C code
167 // nesting loops such that the innermost loop has the smallest stride for the
168 // best cache behavior.
169 for (int d0 = 0; d0 < extended_output_shape.Dims(0); ++d0)
170 {
171 for (int d1 = 0; d1 < extended_output_shape.Dims(1); ++d1)
172 {
173 for (int d2 = 0; d2 < extended_output_shape.Dims(2); ++d2)
174 {
175 for (int d3 = 0; d3 < extended_output_shape.Dims(3); ++d3)
176 {
177 for (int d4 = 0; d4 < extended_output_shape.Dims(4); ++d4)
178 {
179 for (int d5 = 0; d5 < extended_output_shape.Dims(5); ++d5)
180 {
181 output_data[Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
182 ActivationFunctionWithMinMax<T>(
183 fn(input1_data[SubscriptToIndex(desc1, d0, d1, d2, d3, d4, d5)],
184 input2_data[SubscriptToIndex(desc2, d0, d1, d2, d3, d4, d5)]),
186 }
187 }
188 }
189 }
190 }
191 }
192}

References desc1, desc2, nnfw::cker::Shape::Dims(), kMaxBroadcastDim, nnfw::cker::NdArrayDescsForElementwiseBroadcast(), nnfw::cker::Offset(), output_shape, nnfw::cker::BinaryArithmeticOpParam::quantized_activation_max, nnfw::cker::BinaryArithmeticOpParam::quantized_activation_min, and nnfw::cker::SubscriptToIndex().

◆ Conv() [1/3]

template<typename T , bool is_asymmetric>
void nnfw::cker::reference::Conv ( const ConvParams params,
const int32_t *  output_multiplier,
const int32_t *  output_shift,
const Shape input_shape,
const T *  input_data,
const Shape filter_shape,
const T *  filter_data,
const int32_t *  filter_zeropoint,
const Shape bias_shape,
const int32_t *  bias_data,
const Shape output_shape,
T *  output_data 
)
inline

Definition at line 195 of file Conv.h.

200{
201 // Get parameters.
202 const int32_t input_offset = params.input_offset; // r = s(q - Z)
203 const int stride_width = params.stride_width;
204 const int stride_height = params.stride_height;
205 const int dilation_width_factor = params.dilation_width_factor;
206 const int dilation_height_factor = params.dilation_height_factor;
207 const int pad_width = params.padding_values.width;
208 const int pad_height = params.padding_values.height;
209 const int32_t output_offset = params.output_offset;
210
211 // Set min and max value of the output.
212 const int32_t output_activation_min = params.quantized_activation_min;
213 const int32_t output_activation_max = params.quantized_activation_max;
214
215 // Consistency check.
216 assert(output_activation_min < output_activation_max);
217 assert(input_shape.DimensionsCount() == 4);
218 assert(filter_shape.DimensionsCount() == 4);
219 assert(output_shape.DimensionsCount() == 4);
220 const int batches = MatchingDim(input_shape, 0, output_shape, 0);
221 const int input_depth = MatchingDim(input_shape, 3, filter_shape, 3);
222 const int output_depth = MatchingDim(filter_shape, 0, output_shape, 3);
223 if (bias_data)
224 {
225 assert(bias_shape.FlatSize() == output_depth);
226 }
227
228 // Check dimensions of the tensors.
229 const int input_height = input_shape.Dims(1);
230 const int input_width = input_shape.Dims(2);
231 const int filter_height = filter_shape.Dims(1);
232 const int filter_width = filter_shape.Dims(2);
233 const int output_height = output_shape.Dims(1);
234 const int output_width = output_shape.Dims(2);
235 for (int batch = 0; batch < batches; ++batch)
236 {
237 for (int out_y = 0; out_y < output_height; ++out_y)
238 {
239 const int in_y_origin = (out_y * stride_height) - pad_height;
240 for (int out_x = 0; out_x < output_width; ++out_x)
241 {
242 const int in_x_origin = (out_x * stride_width) - pad_width;
243 for (int out_channel = 0; out_channel < output_depth; ++out_channel)
244 {
245 int32_t acc = 0;
246 for (int filter_y = 0; filter_y < filter_height; ++filter_y)
247 {
248 const int in_y = in_y_origin + dilation_height_factor * filter_y;
249 for (int filter_x = 0; filter_x < filter_width; ++filter_x)
250 {
251 const int in_x = in_x_origin + dilation_width_factor * filter_x;
252
253 // Zero padding by omitting the areas outside the image.
254 const bool is_point_inside_image =
255 (in_x >= 0) && (in_x < input_width) && (in_y >= 0) && (in_y < input_height);
256
257 if (!is_point_inside_image)
258 {
259 continue;
260 }
261
262 for (int in_channel = 0; in_channel < input_depth; ++in_channel)
263 {
264 const T input_val = input_data[Offset(input_shape, batch, in_y, in_x, in_channel)];
265 const T filter_val =
266 filter_data[Offset(filter_shape, out_channel, filter_y, filter_x, in_channel)];
267 if (is_asymmetric)
268 {
269 const int32_t filter_offset = -filter_zeropoint[out_channel];
270 acc += (filter_val + filter_offset) * (input_val + input_offset);
271 }
272 else
273 {
274 // Accumulate with 32 bits accumulator.
275 // In the nudging process during model quantization, we force
276 // real value of 0.0 be represented by a quantized value. This
277 // guarantees that the input_offset is a int8_t, even though
278 // it is represented using int32_t. int32_t += int8_t *
279 // (int8_t - int8_t) so the highest value we can get from each
280 // accumulation is [-127, 127] * ([-128, 127] -
281 // [-128, 127]), which is [-32512, 32512]. log2(32512)
282 // = 14.98, which means we can accumulate at least 2^16
283 // multiplications without overflow. The accumulator is
284 // applied to a filter so the accumulation logic will hold as
285 // long as the filter size (filter_y * filter_x * in_channel)
286 // does not exceed 2^16, which is the case in all the models
287 // we have seen so far.
288 // TODO(jianlijianli): Add a check to make sure the
289 // accumulator depth is smaller than 2^16.
290 acc += filter_val * (input_val + input_offset);
291 }
292 }
293 }
294 }
295
296 if (bias_data)
297 {
298 acc += bias_data[out_channel];
299 }
300 acc = MultiplyByQuantizedMultiplier(acc, output_multiplier[out_channel],
301 output_shift[out_channel]);
302 acc += output_offset;
303 acc = std::max(acc, output_activation_min);
304 acc = std::min(acc, output_activation_max);
305 output_data[Offset(output_shape, batch, out_y, out_x, out_channel)] = static_cast<T>(acc);
306 }
307 }
308 }
309 }
310}
int32_t DimensionsCount() const
Definition Shape.h:103
int FlatSize() const
Definition Shape.h:256
int32_t MultiplyByQuantizedMultiplier(int32_t x, int32_t quantized_multiplier, int shift)
int16_t stride_height
Definition Types.h:146
PaddingValues padding_values
Definition Types.h:143
int32_t output_offset
Definition Types.h:153
int16_t dilation_width_factor
Definition Types.h:147
int32_t quantized_activation_max
Definition Types.h:158
int16_t dilation_height_factor
Definition Types.h:148
int32_t quantized_activation_min
Definition Types.h:157

References nnfw::cker::ConvParams::dilation_height_factor, nnfw::cker::ConvParams::dilation_width_factor, nnfw::cker::Shape::DimensionsCount(), nnfw::cker::Shape::Dims(), nnfw::cker::PaddingValues::height, nnfw::cker::ConvParams::input_offset, nnfw::cker::MatchingDim(), nnfw::cker::MultiplyByQuantizedMultiplier(), nnfw::cker::Offset(), nnfw::cker::ConvParams::output_offset, output_shape, nnfw::cker::ConvParams::padding_values, nnfw::cker::ConvParams::quantized_activation_max, nnfw::cker::ConvParams::quantized_activation_min, nnfw::cker::ConvParams::stride_height, nnfw::cker::ConvParams::stride_width, and nnfw::cker::PaddingValues::width.

◆ Conv() [2/3]

void nnfw::cker::reference::Conv ( const ConvParams params,
const Shape input_shape,
const float *  input_data,
const Shape filter_shape,
const float *  filter_data,
const Shape bias_shape,
const float *  bias_data,
const Shape output_shape,
float *  output_data 
)
inline

Definition at line 33 of file Conv.h.

37{
38 const int stride_width = params.stride_width;
39 const int stride_height = params.stride_height;
40 const int dilation_width_factor = params.dilation_width_factor;
41 const int dilation_height_factor = params.dilation_height_factor;
42 const int pad_width = params.padding_values.width;
43 const int pad_height = params.padding_values.height;
44 const float output_activation_min = params.float_activation_min;
45 const float output_activation_max = params.float_activation_max;
46 assert(input_shape.DimensionsCount() == 4);
47 assert(filter_shape.DimensionsCount() == 4);
48 assert(output_shape.DimensionsCount() == 4);
49
50 const int batches = MatchingDim(input_shape, 0, output_shape, 0);
51 const int input_depth = MatchingDim(input_shape, 3, filter_shape, 3);
52 const int output_depth = MatchingDim(filter_shape, 0, output_shape, 3);
53 if (bias_data)
54 {
55 assert(bias_shape.FlatSize() == output_depth);
56 }
57 const int input_height = input_shape.Dims(1);
58 const int input_width = input_shape.Dims(2);
59 const int filter_height = filter_shape.Dims(1);
60 const int filter_width = filter_shape.Dims(2);
61 const int output_height = output_shape.Dims(1);
62 const int output_width = output_shape.Dims(2);
63 for (int batch = 0; batch < batches; ++batch)
64 {
65 for (int out_y = 0; out_y < output_height; ++out_y)
66 {
67 for (int out_x = 0; out_x < output_width; ++out_x)
68 {
69 for (int out_channel = 0; out_channel < output_depth; ++out_channel)
70 {
71 const int in_x_origin = (out_x * stride_width) - pad_width;
72 const int in_y_origin = (out_y * stride_height) - pad_height;
73 float total = 0.f;
74 for (int filter_y = 0; filter_y < filter_height; ++filter_y)
75 {
76 for (int filter_x = 0; filter_x < filter_width; ++filter_x)
77 {
78 const int in_x = in_x_origin + dilation_width_factor * filter_x;
79 const int in_y = in_y_origin + dilation_height_factor * filter_y;
80 // If the location is outside the bounds of the input image,
81 // use zero as a default value.
82 if ((in_x >= 0) && (in_x < input_width) && (in_y >= 0) && (in_y < input_height))
83 {
84 const int in_offset = Offset(input_shape, batch, in_y, in_x, 0);
85 const int filter_offset = Offset(filter_shape, out_channel, filter_y, filter_x, 0);
86 for (int in_channel = 0; in_channel < input_depth; ++in_channel)
87 {
88 float input_value = input_data[in_offset + in_channel];
89 float filter_value = filter_data[filter_offset + in_channel];
90 total += (input_value * filter_value);
91 }
92 }
93 }
94 }
95 float bias_value = 0.0f;
96 if (bias_data)
97 {
98 bias_value = bias_data[out_channel];
99 }
100 output_data[Offset(output_shape, batch, out_y, out_x, out_channel)] =
101 ActivationFunctionWithMinMax(total + bias_value, output_activation_min,
102 output_activation_max);
103 }
104 }
105 }
106 }
107}
float float_activation_max
Definition Types.h:161
float float_activation_min
Definition Types.h:160

References nnfw::cker::ActivationFunctionWithMinMax(), nnfw::cker::ConvParams::dilation_height_factor, nnfw::cker::ConvParams::dilation_width_factor, nnfw::cker::Shape::DimensionsCount(), nnfw::cker::Shape::Dims(), nnfw::cker::ConvParams::float_activation_max, nnfw::cker::ConvParams::float_activation_min, nnfw::cker::PaddingValues::height, nnfw::cker::MatchingDim(), nnfw::cker::Offset(), output_shape, nnfw::cker::ConvParams::padding_values, nnfw::cker::ConvParams::stride_height, nnfw::cker::ConvParams::stride_width, and nnfw::cker::PaddingValues::width.

Referenced by nnfw::cker::Conv::operator()().

◆ Conv() [3/3]

void nnfw::cker::reference::Conv ( const ConvParams params,
const Shape input_shape,
const uint8_t *  input_data,
const Shape filter_shape,
const uint8_t *  filter_data,
const Shape bias_shape,
const int32_t *  bias_data,
const Shape output_shape,
uint8_t *  output_data 
)
inline

Definition at line 109 of file Conv.h.

113{
114 const int stride_width = params.stride_width;
115 const int stride_height = params.stride_height;
116 const int dilation_width_factor = params.dilation_width_factor;
117 const int dilation_height_factor = params.dilation_height_factor;
118 const int pad_width = params.padding_values.width;
119 const int pad_height = params.padding_values.height;
120 const int32_t input_offset = params.input_offset;
121 const int32_t filter_offset = params.weights_offset;
122 const int32_t output_offset = params.output_offset;
123 const int32_t output_multiplier = params.output_multiplier;
124 const int output_shift = params.output_shift;
125 const int32_t output_activation_min = params.quantized_activation_min;
126 const int32_t output_activation_max = params.quantized_activation_max;
127 assert(output_activation_min <= output_activation_max);
128
129 assert(input_shape.DimensionsCount() == 4);
130 assert(filter_shape.DimensionsCount() == 4);
131 assert(output_shape.DimensionsCount() == 4);
132 const int batches = MatchingDim(input_shape, 0, output_shape, 0);
133 const int input_depth = MatchingDim(input_shape, 3, filter_shape, 3);
134 const int output_depth = MatchingDim(filter_shape, 0, output_shape, 3);
135 if (bias_data)
136 {
137 assert(bias_shape.FlatSize() == output_depth);
138 }
139 const int input_height = input_shape.Dims(1);
140 const int input_width = input_shape.Dims(2);
141 const int filter_height = filter_shape.Dims(1);
142 const int filter_width = filter_shape.Dims(2);
143 const int output_height = output_shape.Dims(1);
144 const int output_width = output_shape.Dims(2);
145 for (int batch = 0; batch < batches; ++batch)
146 {
147 for (int out_y = 0; out_y < output_height; ++out_y)
148 {
149 for (int out_x = 0; out_x < output_width; ++out_x)
150 {
151 for (int out_channel = 0; out_channel < output_depth; ++out_channel)
152 {
153 const int in_x_origin = (out_x * stride_width) - pad_width;
154 const int in_y_origin = (out_y * stride_height) - pad_height;
155 int32_t acc = 0;
156 for (int filter_y = 0; filter_y < filter_height; ++filter_y)
157 {
158 for (int filter_x = 0; filter_x < filter_width; ++filter_x)
159 {
160 const int in_x = in_x_origin + dilation_width_factor * filter_x;
161 const int in_y = in_y_origin + dilation_height_factor * filter_y;
162 // If the location is outside the bounds of the input image,
163 // use zero as a default value.
164 if ((in_x >= 0) && (in_x < input_width) && (in_y >= 0) && (in_y < input_height))
165 {
166 const int in_base = Offset(input_shape, batch, in_y, in_x, 0);
167 const int filter_base = Offset(filter_shape, out_channel, filter_y, filter_x, 0);
168 for (int in_channel = 0; in_channel < input_depth; in_channel++)
169 {
170 int32_t input_val = input_data[in_channel + in_base];
171 int32_t filter_val = filter_data[in_channel + filter_base];
172 acc += (filter_val + filter_offset) * (input_val + input_offset);
173 }
174 }
175 }
176 }
177 if (bias_data)
178 {
179 acc += bias_data[out_channel];
180 }
181 acc = MultiplyByQuantizedMultiplier(acc, output_multiplier, output_shift);
182 acc += output_offset;
183 acc = std::max(acc, output_activation_min);
184 acc = std::min(acc, output_activation_max);
185 output_data[Offset(output_shape, batch, out_y, out_x, out_channel)] =
186 static_cast<uint8_t>(acc);
187 }
188 }
189 }
190 }
191}
int32_t output_multiplier
Definition Types.h:154
int32_t weights_offset
Definition Types.h:152

References nnfw::cker::ConvParams::dilation_height_factor, nnfw::cker::ConvParams::dilation_width_factor, nnfw::cker::Shape::DimensionsCount(), nnfw::cker::Shape::Dims(), nnfw::cker::PaddingValues::height, nnfw::cker::ConvParams::input_offset, nnfw::cker::MatchingDim(), nnfw::cker::MultiplyByQuantizedMultiplier(), nnfw::cker::Offset(), nnfw::cker::ConvParams::output_multiplier, nnfw::cker::ConvParams::output_offset, output_shape, nnfw::cker::ConvParams::output_shift, nnfw::cker::ConvParams::padding_values, nnfw::cker::ConvParams::quantized_activation_max, nnfw::cker::ConvParams::quantized_activation_min, nnfw::cker::ConvParams::stride_height, nnfw::cker::ConvParams::stride_width, nnfw::cker::ConvParams::weights_offset, and nnfw::cker::PaddingValues::width.

◆ HybridConvPerChannel()

void nnfw::cker::reference::HybridConvPerChannel ( const ConvParams params,
float *  scaling_factors_ptr,
const Shape input_shape,
const int8_t *  input_data,
const Shape filter_shape,
const int8_t *  filter_data,
const Shape bias_shape,
const float *  bias_data,
const Shape output_shape,
float *  output_data,
const float *  per_channel_scale,
const int32_t *  input_offset 
)
inline

Definition at line 314 of file Conv.h.

321{
322 const int stride_width = params.stride_width;
323 const int stride_height = params.stride_height;
324 const int dilation_width_factor = params.dilation_width_factor;
325 const int dilation_height_factor = params.dilation_height_factor;
326 const int pad_width = params.padding_values.width;
327 const int pad_height = params.padding_values.height;
328 const float output_activation_min = params.float_activation_min;
329 const float output_activation_max = params.float_activation_max;
330 assert(input_shape.DimensionsCount() == 4);
331 assert(filter_shape.DimensionsCount() == 4);
332 assert(output_shape.DimensionsCount() == 4);
333 const int batches = MatchingDim(input_shape, 0, output_shape, 0);
334 const int input_depth = input_shape.Dims(3);
335 const int output_depth = MatchingDim(filter_shape, 0, output_shape, 3);
336 if (bias_data)
337 {
338 assert(bias_shape.FlatSize() == output_depth);
339 }
340 const int input_height = input_shape.Dims(1);
341 const int input_width = input_shape.Dims(2);
342 const int filter_height = filter_shape.Dims(1);
343 const int filter_width = filter_shape.Dims(2);
344 const int filter_input_depth = filter_shape.Dims(3);
345 const int groups = input_depth / filter_input_depth;
346 assert(input_depth % filter_input_depth == 0);
347 const int filters_per_group = output_depth / groups;
348 const int output_height = output_shape.Dims(1);
349 const int output_width = output_shape.Dims(2);
350 for (int batch = 0; batch < batches; ++batch)
351 {
352 for (int out_y = 0; out_y < output_height; ++out_y)
353 {
354 for (int out_x = 0; out_x < output_width; ++out_x)
355 {
356 for (int out_channel = 0; out_channel < output_depth; ++out_channel)
357 {
358 auto group = out_channel / filters_per_group;
359 const int in_x_origin = (out_x * stride_width) - pad_width;
360 const int in_y_origin = (out_y * stride_height) - pad_height;
361 int32_t acc = 0;
362 for (int filter_y = 0; filter_y < filter_height; ++filter_y)
363 {
364 for (int filter_x = 0; filter_x < filter_width; ++filter_x)
365 {
366 for (int in_channel = 0; in_channel < filter_input_depth; ++in_channel)
367 {
368 const int in_x = in_x_origin + dilation_width_factor * filter_x;
369 const int in_y = in_y_origin + dilation_height_factor * filter_y;
370 // If the location is outside the bounds of the input image,
371 // use zero as a default value.
372 if ((in_x >= 0) && (in_x < input_width) && (in_y >= 0) && (in_y < input_height))
373 {
374 int32_t input_val = input_data[Offset(input_shape, batch, in_y, in_x,
375 in_channel + group * filter_input_depth)];
376 int32_t filter_val =
377 filter_data[Offset(filter_shape, out_channel, filter_y, filter_x, in_channel)];
378 acc += filter_val * (input_val - input_offset[batch]);
379 }
380 }
381 }
382 }
383 float acc_float = acc * per_channel_scale[out_channel] * scaling_factors_ptr[batch];
384 if (bias_data)
385 {
386 acc_float += bias_data[out_channel];
387 }
388 output_data[Offset(output_shape, batch, out_y, out_x, out_channel)] =
389 ActivationFunctionWithMinMax(acc_float, output_activation_min, output_activation_max);
390 }
391 }
392 }
393 }
394}

References nnfw::cker::ActivationFunctionWithMinMax(), nnfw::cker::ConvParams::dilation_height_factor, nnfw::cker::ConvParams::dilation_width_factor, nnfw::cker::Shape::DimensionsCount(), nnfw::cker::Shape::Dims(), nnfw::cker::ConvParams::float_activation_max, nnfw::cker::ConvParams::float_activation_min, nnfw::cker::PaddingValues::height, nnfw::cker::MatchingDim(), nnfw::cker::Offset(), output_shape, nnfw::cker::ConvParams::padding_values, nnfw::cker::ConvParams::stride_height, nnfw::cker::ConvParams::stride_width, and nnfw::cker::PaddingValues::width.

◆ Softmax()

void nnfw::cker::reference::Softmax ( const SoftmaxParams params,
const Shape input_shape,
const float *  input_data,
const Shape output_shape,
float *  output_data 
)
inline

Definition at line 43 of file SoftMax.h.

45{
46 const int trailing_dim = input_shape.DimensionsCount() - 1;
47 const int outer_size = MatchingFlatSizeSkipDim(input_shape, trailing_dim, output_shape);
48 const int depth = MatchingDim(input_shape, trailing_dim, output_shape, trailing_dim);
49
50 for (int i = 0; i < outer_size; ++i)
51 {
52 // Find max element value which we'll use to ensure numerical stability
53 // taking advantage of the following equality:
54 // exp(x[i])/sum(exp(x[i])) == exp(x[i]+C)/sum(exp(x[i]+C))
55 float max = std::numeric_limits<float>::lowest();
56 for (int c = 0; c < depth; ++c)
57 {
58 max = std::max(max, input_data[i * depth + c]);
59 }
60
61 // Compute sum.
62 float sum = 0.f;
63 for (int c = 0; c < depth; ++c)
64 {
65 sum += std::exp((input_data[i * depth + c] - max) * static_cast<float>(params.beta));
66 }
67
68 // Compute result.
69 for (int c = 0; c < depth; ++c)
70 {
71 output_data[i * depth + c] =
72 std::exp((input_data[i * depth + c] - max) * static_cast<float>(params.beta)) / sum;
73 }
74 }
75}
int MatchingFlatSizeSkipDim(const Shape &shape, int skip_dim, const Shape &check_shape_0)
Definition Shape.h:419

References nnfw::cker::SoftmaxParams::beta, nnfw::cker::Shape::DimensionsCount(), nnfw::cker::MatchingDim(), nnfw::cker::MatchingFlatSizeSkipDim(), and output_shape.

Referenced by onert::backend::cpu::ops::SoftMaxLayer::softmaxFloat32().

◆ Transpose()

template<typename T >
void nnfw::cker::reference::Transpose ( const TransposeParams params,
const Shape unextended_input_shape,
const T *  input_data,
const Shape unextended_output_shape,
T *  output_data 
)

Definition at line 91 of file Transpose.h.

93{
94 // Transpose kernel only does rearranging values not numeric evaluations on
95 // each cell. It's safe to implement per size of scalar type and this trick
96 // keeps the total code size in a reasonable range.
97 switch (sizeof(T))
98 {
99 case 1:
100 TransposeImpl<int8_t>(params, unextended_input_shape,
101 reinterpret_cast<const int8_t *>(input_data), unextended_output_shape,
102 reinterpret_cast<int8_t *>(output_data));
103 break;
104 case 2:
105 TransposeImpl<int16_t>(params, unextended_input_shape,
106 reinterpret_cast<const int16_t *>(input_data), unextended_output_shape,
107 reinterpret_cast<int16_t *>(output_data));
108 break;
109
110 case 4:
111 TransposeImpl<int32_t>(params, unextended_input_shape,
112 reinterpret_cast<const int32_t *>(input_data), unextended_output_shape,
113 reinterpret_cast<int32_t *>(output_data));
114 break;
115 case 8:
116 TransposeImpl<int64_t>(params, unextended_input_shape,
117 reinterpret_cast<const int64_t *>(input_data), unextended_output_shape,
118 reinterpret_cast<int64_t *>(output_data));
119 break;
120 }
121}

Referenced by nnfw::cker::TransposeImpl().

◆ TransposeImpl()

template<typename T >
void nnfw::cker::reference::TransposeImpl ( const TransposeParams params,
const Shape unextended_input_shape,
const T *  input_data,
const Shape unextended_output_shape,
T *  output_data 
)

Definition at line 33 of file Transpose.h.

35{
36 const int unextended_output_size = unextended_output_shape.DimensionsCount();
37 assert(unextended_input_shape.DimensionsCount() <= 6);
38 assert(unextended_output_size <= 6);
39 assert(unextended_output_size == params.perm_count);
40 const Shape input_shape = Shape::ExtendedShape(6, unextended_input_shape);
41 const Shape output_shape = Shape::ExtendedShape(6, unextended_output_shape);
42 const int input_ext_size = 6 - unextended_input_shape.DimensionsCount();
43 const int output_ext_size = 6 - unextended_output_size;
44
45 int extended_perm[6];
46 for (int i = 0; i < output_ext_size; ++i)
47 {
48 extended_perm[i] = i;
49 }
50 for (int i = 0; i < unextended_output_size; ++i)
51 {
52 extended_perm[i + output_ext_size] = params.perm[i] + input_ext_size;
53 }
54
55 int out_sizes[6];
56 for (int k = 0; k < 6; k++)
57 {
58 out_sizes[k] = MatchingDim(input_shape, extended_perm[k], output_shape, k);
59 }
60
61 int o[6];
62 int i[6];
63 for (o[5] = 0; o[5] < out_sizes[5]; o[5]++)
64 {
65 i[extended_perm[5]] = o[5];
66 for (o[4] = 0; o[4] < out_sizes[4]; o[4]++)
67 {
68 i[extended_perm[4]] = o[4];
69 for (o[3] = 0; o[3] < out_sizes[3]; o[3]++)
70 {
71 i[extended_perm[3]] = o[3];
72 for (o[2] = 0; o[2] < out_sizes[2]; o[2]++)
73 {
74 i[extended_perm[2]] = o[2];
75 for (o[1] = 0; o[1] < out_sizes[1]; o[1]++)
76 {
77 i[extended_perm[1]] = o[1];
78 for (o[0] = 0; o[0] < out_sizes[0]; o[0]++)
79 {
80 i[extended_perm[0]] = o[0];
81 output_data[Offset(output_shape, o)] = input_data[Offset(input_shape, i)];
82 }
83 }
84 }
85 }
86 }
87 }
88}

References nnfw::cker::Shape::DimensionsCount(), nnfw::cker::MatchingDim(), nnfw::cker::Offset(), output_shape, nnfw::cker::TransposeParams::perm, and nnfw::cker::TransposeParams::perm_count.

Variable Documentation

◆ kMaxBroadcastDim

constexpr int nnfw::cker::reference::kMaxBroadcastDim = 6
constexpr