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

Function ComparisonPrepare

tensorflow/lite/kernels/comparisons.cc:30–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28constexpr int kOutputTensor = 0;
29
30TfLiteStatus ComparisonPrepare(TfLiteContext* context, TfLiteNode* node) {
31 TF_LITE_ENSURE_EQ(context, NumInputs(node), 2);
32 TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1);
33
34 const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1);
35 const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2);
36 TfLiteTensor* output = GetOutput(context, node, kOutputTensor);
37
38 // Don't support string.
39 TF_LITE_ENSURE(context, input1->type != kTfLiteString);
40 // Currently only support tensors have the same type.
41 TF_LITE_ENSURE_TYPES_EQ(context, input1->type, input2->type);
42 output->type = kTfLiteBool;
43
44 bool requires_broadcast = !HaveSameShapes(input1, input2);
45
46 TfLiteIntArray* output_size = nullptr;
47 if (requires_broadcast) {
48 TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast(
49 context, input1, input2, &output_size));
50 } else {
51 output_size = TfLiteIntArrayCopy(input1->dims);
52 }
53
54 return context->ResizeTensor(context, output, output_size);
55}
56
57// TODO(ruic): optimize macros below to using template functions.
58#define TF_LITE_QUANTIZE_COMPARISON(opname) \

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected