| 237 | } |
| 238 | |
| 239 | TfLiteStatus PrepareMeanOrSum(TfLiteContext* context, TfLiteNode* node) { |
| 240 | TF_LITE_ENSURE_OK(context, PrepareSimple(context, node)); |
| 241 | OpData* data = reinterpret_cast<OpData*>(node->user_data); |
| 242 | |
| 243 | // reduce_mean requires a buffer to store intermediate sum result. |
| 244 | OpContext op_context(context, node); |
| 245 | if (op_context.input->type == kTfLiteInt8) { |
| 246 | const double real_multiplier = |
| 247 | static_cast<double>(op_context.input->params.scale) / |
| 248 | static_cast<double>(op_context.output->params.scale); |
| 249 | int exponent; |
| 250 | QuantizeMultiplier(real_multiplier, &data->multiplier, &exponent); |
| 251 | data->shift = exponent; |
| 252 | } |
| 253 | TfLiteTensor* temp_sum = GetTemporary(context, node, /*index=*/2); |
| 254 | if (!IsConstantTensor(op_context.axis)) { |
| 255 | SetTensorToDynamic(temp_sum); |
| 256 | return kTfLiteOk; |
| 257 | } |
| 258 | temp_sum->allocation_type = kTfLiteArenaRw; |
| 259 | return ResizeTempSum(context, &op_context, temp_sum); |
| 260 | } |
| 261 | |
| 262 | void ResolveAxis(const int* axis_data, int axis_count, |
| 263 | tflite::MeanParams* op_params) { |
nothing calls this directly
no test coverage detected