| 447 | // The underlying logic for Reduce Sum/Prod/Max/Min/Any |
| 448 | template <typename T> |
| 449 | TfLiteStatus EvalLogic(TfLiteContext* context, TfLiteNode* node, |
| 450 | OpContext* op_context, T init_value, |
| 451 | T reducer(const T current, const T in)) { |
| 452 | int64_t num_axis = NumElements(op_context->axis); |
| 453 | TfLiteTensor* temp_index = GetTemporary(context, node, /*index=*/0); |
| 454 | TfLiteTensor* resolved_axis = GetTemporary(context, node, /*index=*/1); |
| 455 | // Resize the output tensor if the output tensor is dynamic. |
| 456 | if (IsDynamicTensor(op_context->output)) { |
| 457 | TF_LITE_ENSURE_OK(context, |
| 458 | ResizeTempAxis(context, op_context, resolved_axis)); |
| 459 | TF_LITE_ENSURE_OK(context, ResizeOutputTensor(context, op_context)); |
| 460 | } |
| 461 | if (op_context->input->type == kTfLiteUInt8) { |
| 462 | TF_LITE_ENSURE_EQ(context, op_context->input->params.scale, |
| 463 | op_context->output->params.scale); |
| 464 | TF_LITE_ENSURE_EQ(context, op_context->input->params.zero_point, |
| 465 | op_context->output->params.zero_point); |
| 466 | } |
| 467 | TF_LITE_ENSURE( |
| 468 | context, |
| 469 | reference_ops::ReduceGeneric<T>( |
| 470 | GetTensorData<T>(op_context->input), op_context->input->dims->data, |
| 471 | op_context->input->dims->size, GetTensorData<T>(op_context->output), |
| 472 | op_context->output->dims->data, op_context->output->dims->size, |
| 473 | GetTensorData<int>(op_context->axis), num_axis, |
| 474 | op_context->params->keep_dims, GetTensorData<int>(temp_index), |
| 475 | GetTensorData<int>(resolved_axis), init_value, reducer)); |
| 476 | return kTfLiteOk; |
| 477 | } |
| 478 | |
| 479 | enum ReduceType { |
| 480 | kSum, |
nothing calls this directly
no test coverage detected