18#ifndef __NNFW_CKER_REFERENCE_BINARYARITHMETICOPS_H__
19#define __NNFW_CKER_REFERENCE_BINARYARITHMETICOPS_H__
39 const T *input1_data,
const Shape &input2_shape,
41 const std::function<T(
const T &,
const T &)> &fn)
44 for (
int i = 0; i < flat_size; ++i)
54 const float *input1_data,
const Shape &input2_shape,
57 const std::function<
float(
const float &,
const float &)> &fn)
60 for (
int i = 0; i <
size; i++)
69 const bool *input1_data,
const Shape &input2_shape,
72 const std::function<
bool(
const bool &,
const bool &)> &fn)
75 for (
int i = 0; i <
size; i++)
77 output_data[i] = fn(input1_data[i], input2_data[i]);
83 const int64_t *input1_data,
const Shape &input2_shape,
86 const std::function<int64_t(
const int64_t &,
const int64_t &)> &fn)
89 for (
int i = 0; i < flat_size; ++i)
120 for (
int d0 = 0; d0 < extended_output_shape.
Dims(0); ++d0)
122 for (
int d1 = 0; d1 < extended_output_shape.
Dims(1); ++d1)
124 for (
int d2 = 0; d2 < extended_output_shape.
Dims(2); ++d2)
126 for (
int d3 = 0; d3 < extended_output_shape.
Dims(3); ++d3)
128 for (
int d4 = 0; d4 < extended_output_shape.
Dims(4); ++d4)
130 for (
int d5 = 0; d5 < extended_output_shape.
Dims(5); ++d5)
132 output_data[
Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
133 ActivationFunctionWithMinMax<T>(
146 const Shape &input1_shape,
const T *input1_data,
147 const Shape &input2_shape,
const T *input2_data,
149 const std::function<T(
const T &,
const T &)> &fn)
169 for (
int d0 = 0; d0 < extended_output_shape.
Dims(0); ++d0)
171 for (
int d1 = 0; d1 < extended_output_shape.
Dims(1); ++d1)
173 for (
int d2 = 0; d2 < extended_output_shape.
Dims(2); ++d2)
175 for (
int d3 = 0; d3 < extended_output_shape.
Dims(3); ++d3)
177 for (
int d4 = 0; d4 < extended_output_shape.
Dims(4); ++d4)
179 for (
int d5 = 0; d5 < extended_output_shape.
Dims(5); ++d5)
181 output_data[
Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
182 ActivationFunctionWithMinMax<T>(
198 float *output_data,
const std::function<
float(
const float &,
const float &)> &fn)
205 for (
int d0 = 0; d0 < extended_output_shape.
Dims(0); ++d0)
207 for (
int d1 = 0; d1 < extended_output_shape.
Dims(1); ++d1)
209 for (
int d2 = 0; d2 < extended_output_shape.
Dims(2); ++d2)
211 for (
int d3 = 0; d3 < extended_output_shape.
Dims(3); ++d3)
213 for (
int d4 = 0; d4 < extended_output_shape.
Dims(4); ++d4)
215 for (
int d5 = 0; d5 < extended_output_shape.
Dims(5); ++d5)
217 output_data[
Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
234 const std::function<
bool(
const bool &,
const bool &)> &fn)
241 for (
int d0 = 0; d0 < extended_output_shape.
Dims(0); ++d0)
243 for (
int d1 = 0; d1 < extended_output_shape.
Dims(1); ++d1)
245 for (
int d2 = 0; d2 < extended_output_shape.
Dims(2); ++d2)
247 for (
int d3 = 0; d3 < extended_output_shape.
Dims(3); ++d3)
249 for (
int d4 = 0; d4 < extended_output_shape.
Dims(4); ++d4)
251 for (
int d5 = 0; d5 < extended_output_shape.
Dims(5); ++d5)
253 output_data[
Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
268 int64_t *output_data,
const std::function<int64_t(
const int64_t &,
const int64_t &)> &fn)
275 for (
int d0 = 0; d0 < extended_output_shape.
Dims(0); ++d0)
277 for (
int d1 = 0; d1 < extended_output_shape.
Dims(1); ++d1)
279 for (
int d2 = 0; d2 < extended_output_shape.
Dims(2); ++d2)
281 for (
int d3 = 0; d3 < extended_output_shape.
Dims(3); ++d3)
283 for (
int d4 = 0; d4 < extended_output_shape.
Dims(4); ++d4)
285 for (
int d5 = 0; d5 < extended_output_shape.
Dims(5); ++d5)
287 output_data[
Offset(extended_output_shape, d0, d1, d2, d3, d4, d5)] =
int32_t Dims(int i) const
const luci_interpreter::RuntimeShape output_shape
constexpr int kMaxBroadcastDim
std::enable_if_t< is_quant8< T >::value > BroadcastBinaryArithmeticOpSlow(const BinaryArithmeticOpParam ¶ms, 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 ¶ms, const T &, const T &)> &fn)
void BinaryArithmeticOp(const BinaryArithmeticOpParam ¶ms, 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)
int Offset(const Shape &shape, int i0, int i1, int i2, int i3)
void NdArrayDescsForElementwiseBroadcast(const Shape &input0_shape, const Shape &input1_shape, NdArrayDesc< N > *desc0_out, NdArrayDesc< N > *desc1_out)
T ActivationFunctionWithMinMax(T x, T output_activation_min, T output_activation_max)
int MatchingElementsSize(const Shape &shape, const Shape &check_shape_0, const Shape &check_shape_1)
int SubscriptToIndex(const NdArrayDesc< 4 > &desc, int i0, int i1, int i2, int i3)
int32_t quantized_activation_max
int64_t int64_activation_min
int32_t quantized_activation_min
float float_activation_max
int64_t int64_activation_max
float float_activation_min