| 51 | } |
| 52 | |
| 53 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 54 | OpData* data = reinterpret_cast<OpData*>(node->user_data); |
| 55 | |
| 56 | TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); |
| 57 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 58 | |
| 59 | const TfLiteTensor* input1 = GetInput(context, node, kInputTensor1); |
| 60 | const TfLiteTensor* input2 = GetInput(context, node, kInputTensor2); |
| 61 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 62 | |
| 63 | TF_LITE_ENSURE_EQ(context, input1->type, input2->type); |
| 64 | output->type = input2->type; |
| 65 | |
| 66 | data->requires_broadcast = !HaveSameShapes(input1, input2); |
| 67 | |
| 68 | TfLiteIntArray* output_size = nullptr; |
| 69 | if (data->requires_broadcast) { |
| 70 | TF_LITE_ENSURE_OK(context, CalculateShapeForBroadcast( |
| 71 | context, input1, input2, &output_size)); |
| 72 | } else { |
| 73 | output_size = TfLiteIntArrayCopy(input1->dims); |
| 74 | } |
| 75 | |
| 76 | return context->ResizeTensor(context, output, output_size); |
| 77 | } |
| 78 | |
| 79 | template <typename T> |
| 80 | void EvalSquaredDifference(TfLiteContext* context, TfLiteNode* node, |
nothing calls this directly
no test coverage detected