| 46 | } |
| 47 | |
| 48 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 49 | TF_LITE_ENSURE_EQ(context, NumInputs(node), 2); |
| 50 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 51 | |
| 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 != kTfLiteInt32 && type != kTfLiteFloat32) { |
| 62 | context->ReportError(context, "Unsupported data type %d.", 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 | |
| 80 | template <typename T> |
| 81 | void PowImpl(const TfLiteTensor* input1, const TfLiteTensor* input2, |
nothing calls this directly
no test coverage detected