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

Function PrepareMeanOrSum

tensorflow/lite/kernels/reduce.cc:239–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237}
238
239TfLiteStatus 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
262void ResolveAxis(const int* axis_data, int axis_count,
263 tflite::MeanParams* op_params) {

Callers

nothing calls this directly

Calls 6

PrepareSimpleFunction · 0.85
GetTemporaryFunction · 0.85
SetTensorToDynamicFunction · 0.85
ResizeTempSumFunction · 0.85
IsConstantTensorFunction · 0.70
QuantizeMultiplierFunction · 0.50

Tested by

no test coverage detected