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

Function Prepare

tensorflow/lite/kernels/sub.cc:192–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190}
191
192TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
193 OpData* data = reinterpret_cast<OpData*>(node->user_data);
194 auto* params = reinterpret_cast<TfLiteSubParams*>(node->builtin_data);
195
196 TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
197 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
198
199 const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);
200 const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);
201 TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
202
203 TF_LITE_ENSURE_EQ(context, input1->type, input2->type);
204 output->type = input2->type;
205
206 data->requires_broadcast = !HaveSameShapes(input1, input2);
207
208 TfLiteIntArray* output_size = nullptr;
209 if (data->requires_broadcast) {
210 TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(
211 context, input1, input2, &output_size));
212 } else {
213 output_size = TfLiteIntArrayCopy(input1->dims);
214 }
215
216 if (output->type == kTfLiteUInt8 || output->type == kTfLiteInt8) {
217 TF_LITE_ENSURE_OK(context, Prepare8BitSubOp(context, input1, input2, output,
218 params, data, -1));
219 } else if (output->type == kTfLiteInt16) {
220 TF_LITE_ENSURE_OK(context, PrepareInt16SubOp(context, input1, input2,
221 output, params, data));
222 }
223
224 return context->ResizeTensor(context, output, output_size);
225}
226
227template <KernelType kernel_type>
228void EvalSub(TfLiteContext* context, TfLiteNode* node, TfLiteSubParams* params,

Callers

nothing calls this directly

Calls 10

NumInputsFunction · 0.85
GetInputFunction · 0.85
GetOutputFunction · 0.85
HaveSameShapesFunction · 0.85
TfLiteIntArrayCopyFunction · 0.85
Prepare8BitSubOpFunction · 0.85
PrepareInt16SubOpFunction · 0.85
ResizeTensorMethod · 0.80
NumOutputsFunction · 0.70

Tested by

no test coverage detected