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

Function Prepare

tensorflow/lite/kernels/div.cc:63–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
64 auto* params = reinterpret_cast<TfLiteDivParams*>(node->builtin_data);
65 OpData* data = reinterpret_cast<OpData*>(node->user_data);
66
67 TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
68 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
69
70 const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);
71 const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);
72 TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
73
74 TF_LITE_ENSURE_EQ(context, input1->type, input2->type);
75 output->type = input2->type;
76
77 data->requires_broadcast = !HaveSameShapes(input1, input2);
78
79 TfLiteIntArray* output_size = nullptr;
80 if (data->requires_broadcast) {
81 TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(
82 context, input1, input2, &output_size));
83 } else {
84 output_size = TfLiteIntArrayCopy(input1->dims);
85 }
86
87 if (output->type == kTfLiteUInt8) {
88 CalculateActivationRangeUint8(params->activation, output,
89 &data->output_activation_min,
90 &data->output_activation_max);
91 const double real_multiplier =
92 input1->params.scale / (input2->params.scale * output->params.scale);
93 QuantizeMultiplier(real_multiplier, &data->output_multiplier,
94 &data->output_shift);
95 }
96
97 return context->ResizeTensor(context, output, output_size);
98}
99
100template <KernelType kernel_type>
101void EvalDiv(TfLiteContext* context, TfLiteNode* node, TfLiteDivParams* params,

Callers

nothing calls this directly

Calls 10

NumInputsFunction · 0.85
GetInputFunction · 0.85
GetOutputFunction · 0.85
HaveSameShapesFunction · 0.85
TfLiteIntArrayCopyFunction · 0.85
ResizeTensorMethod · 0.80
NumOutputsFunction · 0.70
QuantizeMultiplierFunction · 0.50

Tested by

no test coverage detected