| 256 | |
| 257 | template <KernelType kernel_type> |
| 258 | void EvalQuantizedPerChannel(TfLiteContext* context, TfLiteNode* node, |
| 259 | TfLiteDepthwiseConvParams* params, OpData* data, |
| 260 | const TfLiteTensor* input, |
| 261 | const TfLiteTensor* filter, |
| 262 | const TfLiteTensor* bias, TfLiteTensor* output) { |
| 263 | DepthwiseParams op_params; |
| 264 | op_params.padding_type = PaddingType::kSame; |
| 265 | op_params.padding_values.width = data->padding.width; |
| 266 | op_params.padding_values.height = data->padding.height; |
| 267 | op_params.stride_width = params->stride_width; |
| 268 | op_params.stride_height = params->stride_height; |
| 269 | op_params.dilation_width_factor = params->dilation_width_factor; |
| 270 | op_params.dilation_height_factor = params->dilation_height_factor; |
| 271 | op_params.depth_multiplier = params->depth_multiplier; |
| 272 | op_params.input_offset = -input->params.zero_point; |
| 273 | op_params.weights_offset = 0; |
| 274 | op_params.output_offset = output->params.zero_point; |
| 275 | // TODO(b/130439627): Use calculated value for clamping. |
| 276 | op_params.quantized_activation_min = std::numeric_limits<int8_t>::min(); |
| 277 | op_params.quantized_activation_max = std::numeric_limits<int8_t>::max(); |
| 278 | |
| 279 | if (kernel_type == kReference) { |
| 280 | reference_integer_ops::DepthwiseConvPerChannel( |
| 281 | op_params, data->per_channel_output_multiplier.data(), |
| 282 | data->per_channel_output_shift.data(), GetTensorShape(input), |
| 283 | GetTensorData<int8>(input), GetTensorShape(filter), |
| 284 | GetTensorData<int8>(filter), GetTensorShape(bias), |
| 285 | GetTensorData<int32>(bias), GetTensorShape(output), |
| 286 | GetTensorData<int8>(output)); |
| 287 | } else { |
| 288 | optimized_integer_ops::DepthwiseConvPerChannel( |
| 289 | op_params, data->per_channel_output_multiplier.data(), |
| 290 | data->per_channel_output_shift.data(), GetTensorShape(input), |
| 291 | GetTensorData<int8>(input), GetTensorShape(filter), |
| 292 | GetTensorData<int8>(filter), GetTensorShape(bias), |
| 293 | GetTensorData<int32>(bias), GetTensorShape(output), |
| 294 | GetTensorData<int8>(output), |
| 295 | CpuBackendContext::GetFromContext(context)); |
| 296 | } |
| 297 | } |
| 298 | |
| 299 | template <KernelType kernel_type> |
| 300 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
nothing calls this directly
no test coverage detected