| 51 | } |
| 52 | |
| 53 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 54 | TF_LITE_ENSURE_EQ(context, NumInputs(node), 1); |
| 55 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 56 | |
| 57 | const TfLiteTensor* cond_tensor = |
| 58 | GetInput(context, node, kInputConditionTensor); |
| 59 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 60 | |
| 61 | if (cond_tensor->type != kTfLiteBool) { |
| 62 | context->ReportError(context, |
| 63 | "Condition tensor must be of type bool, but saw '%s'.", |
| 64 | TfLiteTypeGetName(cond_tensor->type)); |
| 65 | return kTfLiteError; |
| 66 | } |
| 67 | |
| 68 | // As output will be a 2D tensor of indices, we use int32 as data type. |
| 69 | output->type = kTfLiteInt32; |
| 70 | |
| 71 | // Exit early if cond is a non-const tensor. Set output tensor to dynamic so |
| 72 | // output size can be determined in Eval. |
| 73 | if (!IsConstantTensor(cond_tensor)) { |
| 74 | SetTensorToDynamic(output); |
| 75 | return kTfLiteOk; |
| 76 | } |
| 77 | return ResizeOutputTensor(context, cond_tensor, output); |
| 78 | } |
| 79 | |
| 80 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 81 | const TfLiteTensor* cond_tensor = |
nothing calls this directly
no test coverage detected