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

Function Prepare

tensorflow/lite/kernels/logical.cc:47–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45}
46
47TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) {
48 TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
49 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
50
51 // Reinterprete the opaque data provided by user.
52 OpData* data = reinterpret_cast<OpData*>(node->user_data);
53
54 const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);
55 const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);
56 TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
57
58 TF_LITE_ENSURE_EQ(context, input1->type, input2->type);
59
60 const TfLiteType type = input1->type;
61 if (type != kTfLiteBool) {
62 context->ReportError(context, "Logical ops only support bool type.");
63 return kTfLiteError;
64 }
65 output->type = type;
66
67 data->requires_broadcast = !HaveSameShapes(input1, input2);
68
69 TfLiteIntArray* output_size = nullptr;
70 if (data->requires_broadcast) {
71 TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(
72 context, input1, input2, &output_size));
73 } else {
74 output_size = TfLiteIntArrayCopy(input1->dims);
75 }
76
77 return context->ResizeTensor(context, output, output_size);
78}
79
80TfLiteStatus LogicalImpl(TfLiteContext* context, TfLiteNode* node,
81 bool (*func)(bool, bool)) {

Callers

nothing calls this directly

Calls 9

NumInputsFunction · 0.85
GetInputFunction · 0.85
GetOutputFunction · 0.85
HaveSameShapesFunction · 0.85
TfLiteIntArrayCopyFunction · 0.85
ResizeTensorMethod · 0.80
NumOutputsFunction · 0.70
ReportErrorMethod · 0.45

Tested by

no test coverage detected