MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / EvalQuantized

Function EvalQuantized

tensorflow/lite/kernels/div.cc:148–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147template <KernelType kernel_type>
148TfLiteStatus EvalQuantized(TfLiteContext* context, TfLiteNode* node,
149 TfLiteDivParams* params, const OpData* data,
150 const TfLiteTensor* input1,
151 const TfLiteTensor* input2, TfLiteTensor* output) {
152 if (input1->type == kTfLiteUInt8 && input2->type == kTfLiteUInt8 &&
153 output->type == kTfLiteUInt8) {
154 tflite::ArithmeticParams op_params;
155 SetActivationParams(data->output_activation_min,
156 data->output_activation_max, &op_params);
157 op_params.input1_offset = -input1->params.zero_point;
158 op_params.input2_offset = -input2->params.zero_point;
159 op_params.output_offset = output->params.zero_point;
160 op_params.output_multiplier = data->output_multiplier;
161 op_params.output_shift = data->output_shift;
162 bool need_broadcast = optimized_ops::ProcessBroadcastShapes(
163 GetTensorShape(input1), GetTensorShape(input2), &op_params);
164#define TF_LITE_DIV(type, opname, dtype) \
165 type::opname(op_params, GetTensorShape(input1), \
166 GetTensorData<dtype>(input1), GetTensorShape(input2), \
167 GetTensorData<dtype>(input2), GetTensorShape(output), \
168 GetTensorData<dtype>(output))
169 if (kernel_type == kReference) {
170 if (need_broadcast) {
171 TF_LITE_DIV(reference_ops, BroadcastDiv4DSlow, uint8_t);
172 } else {
173 TF_LITE_DIV(reference_ops, Div, uint8_t);
174 }
175 } else {
176 if (need_broadcast) {
177 TF_LITE_DIV(optimized_ops, BroadcastDiv4DSlow, uint8_t);
178 } else {
179 TF_LITE_DIV(optimized_ops, Div, uint8_t);
180 }
181 }
182#undef TF_LITE_DIV
183 } else {
184 context->ReportError(
185 context, "Unsupported combination of input and output types in Div.");
186 return kTfLiteError;
187 }
188 return kTfLiteOk;
189}
190
191template <KernelType kernel_type>
192TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) {

Callers

nothing calls this directly

Calls 4

SetActivationParamsFunction · 0.85
ProcessBroadcastShapesFunction · 0.85
GetTensorShapeFunction · 0.50
ReportErrorMethod · 0.45

Tested by

no test coverage detected