33 const tflite::RuntimeShape &unextended_input2_shape,
35 const tflite::RuntimeShape &unextended_output_shape, T *output_data,
38 if (unextended_input1_shape == unextended_input2_shape)
40 const int flat_size = tflite::MatchingElementsSize(
41 unextended_input1_shape, unextended_input2_shape, unextended_output_shape);
42 for (
int i = 0; i < flat_size; ++i)
44 output_data[i] = op(input1_data[i], input2_data[i]);
49 assert(unextended_input1_shape.DimensionsCount() <= N);
50 assert(unextended_input2_shape.DimensionsCount() <= N);
51 assert(unextended_output_shape.DimensionsCount() <= N);
53 tflite::NdArrayDesc<N>
desc1{};
54 tflite::NdArrayDesc<N>
desc2{};
55 tflite::NdArrayDesc<N> output_desc{};
56 tflite::NdArrayDescsForElementwiseBroadcast(unextended_input1_shape, unextended_input2_shape,
58 tflite::CopyDimsToDesc(tflite::RuntimeShape::ExtendedShape(N, unextended_output_shape),
61 auto fn = [&](
int indexes[N]) {
66 tflite::NDOpsHelper<N>(output_desc, fn);
void BinaryOpBroadcastSlow(const tflite::RuntimeShape &unextended_input1_shape, const T *input1_data, const tflite::RuntimeShape &unextended_input2_shape, const T *input2_data, const tflite::RuntimeShape &unextended_output_shape, T *output_data, Op op)