19#include "kernels/Utils.h"
21#include <tensorflow/lite/kernels/internal/reference/div.h>
22#include <tensorflow/lite/kernels/internal/reference/process_broadcast_shapes.h>
44 switch (
input1()->element_type())
46 case DataType::FLOAT32:
50 evalInteger<int64_t>();
53 evalInteger<int32_t>();
59 throw std::runtime_error(
"luci-intp Div Unsupported type.");
63void Div::evalFloat()
const
65 tflite::ArithmeticParams
params{};
68 const bool need_broadcast = tflite::reference_ops::ProcessBroadcastShapes(
73 tflite::reference_ops::BroadcastDivSlow(
85template <
typename T>
void Div::evalInteger()
const
87 tflite::ArithmeticParams
params{};
90 const bool need_broadcast = tflite::reference_ops::ProcessBroadcastShapes(
95 tflite::reference_ops::BroadcastDivSlow(
107void Div::evalQuantized()
const
109 const auto input1_scale =
static_cast<double>(
input1()->
scale());
110 const auto input2_scale =
static_cast<double>(
input2()->
scale());
111 const auto output_scale =
static_cast<double>(
output()->
scale());
113 const double real_output_multiplier = input1_scale / (input2_scale * output_scale);
115 int32_t output_multiplier{};
120 int32_t activation_min{};
121 int32_t activation_max{};
124 tflite::ArithmeticParams
params{};
129 params.output_multiplier = output_multiplier;
130 params.output_shift = output_shift;
131 params.quantized_activation_min = activation_min;
132 params.quantized_activation_max = activation_max;
134 const bool need_broadcast = tflite::reference_ops::ProcessBroadcastShapes(
139 tflite::reference_ops::BroadcastDivSlow(
const DivParams & params() const
void resize(const Shape &new_shape)
int32_t zero_point() const
Div(const Tensor *input1, const Tensor *input2, Tensor *output, const DivParams ¶ms)
const Tensor * input2() const
void configure() override
void execute() const override
const Tensor * input1() const
#define LUCI_INTERPRETER_CHECK(cond)
Shape calculateShapeForBroadcast(const Shape &input1_shape, const Shape &input2_shape)
tflite::RuntimeShape getTensorShape(const Tensor *tensor)
void calculateActivationRangeQuantized(Activation activation, const Tensor *output, int32_t *activation_min, int32_t *activation_max)
void quantizeMultiplier(double double_multiplier, int32_t *quantized_multiplier, int *shift)