| 146 | |
| 147 | template <KernelType kernel_type> |
| 148 | TfLiteStatus 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 | |
| 191 | template <KernelType kernel_type> |
| 192 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
nothing calls this directly
no test coverage detected