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

Function EvalQuantized

tensorflow/lite/kernels/mul.cc:160–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

158
159template <KernelType kernel_type>
160TfLiteStatus EvalQuantized(TfLiteContext* context, TfLiteNode* node,
161 TfLiteMulParams* params, const OpData* data,
162 const TfLiteTensor* input1,
163 const TfLiteTensor* input2, TfLiteTensor* output) {
164 if (input1->type == input2->type && input1->type == output->type &&
165 (input1->type == kTfLiteUInt8 || input1->type == kTfLiteInt8)) {
166 tflite::ArithmeticParams op_params;
167 SetActivationParams(data->output_activation_min,
168 data->output_activation_max, &op_params);
169 op_params.input1_offset = -input1->params.zero_point;
170 op_params.input2_offset = -input2->params.zero_point;
171 op_params.output_offset = output->params.zero_point;
172 op_params.output_multiplier = data->output_multiplier;
173 op_params.output_shift = data->output_shift;
174 bool need_broadcast = optimized_ops::ProcessBroadcastShapes(
175 GetTensorShape(input1), GetTensorShape(input2), &op_params);
176#define TF_LITE_MUL(type, opname, dtype) \
177 type::opname(op_params, GetTensorShape(input1), \
178 GetTensorData<dtype>(input1), GetTensorShape(input2), \
179 GetTensorData<dtype>(input2), GetTensorShape(output), \
180 GetTensorData<dtype>(output))
181 if (input1->type == kTfLiteInt8) {
182 if (kernel_type == kReference) {
183 if (need_broadcast) {
184 TF_LITE_MUL(reference_integer_ops, BroadcastMul4DSlow, int8_t);
185 } else {
186 TF_LITE_MUL(reference_integer_ops, Mul, int8_t);
187 }
188 } else {
189 if (need_broadcast) {
190 TF_LITE_MUL(optimized_integer_ops, BroadcastMulFivefold, int8_t);
191 } else {
192 TF_LITE_MUL(optimized_integer_ops, Mul, int8_t);
193 }
194 }
195 } else {
196 // type == kTfLiteUInt8
197 if (kernel_type == kReference) {
198 if (need_broadcast) {
199 TF_LITE_MUL(reference_ops, BroadcastMul4DSlow, uint8_t);
200 } else {
201 TF_LITE_MUL(reference_ops, Mul, uint8_t);
202 }
203 } else {
204 if (need_broadcast) {
205 TF_LITE_MUL(optimized_ops, BroadcastMulFivefold, uint8_t);
206 } else {
207 TF_LITE_MUL(optimized_ops, Mul, uint8_t);
208 }
209 }
210 }
211#undef TF_LITE_MUL
212 } else if (input1->type == kTfLiteInt16 && input2->type == kTfLiteInt16 &&
213 output->type == kTfLiteInt16) {
214#define TF_LITE_MUL(type, opname) \
215 tflite::ArithmeticParams op_params; \
216 type::opname(op_params, GetTensorShape(input1), \
217 GetTensorData<int16_t>(input1), GetTensorShape(input2), \

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