| 45 | } |
| 46 | |
| 47 | TfLiteStatus 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 | |
| 80 | TfLiteStatus LogicalImpl(TfLiteContext* context, TfLiteNode* node, |
| 81 | bool (*func)(bool, bool)) { |
nothing calls this directly
no test coverage detected