| 85 | } |
| 86 | |
| 87 | TfLiteStatus CheckCondOutput(TfLiteContext* context, |
| 88 | const TfLiteTensor* cond_output) { |
| 89 | // The condition output must be a single boolean value. |
| 90 | TF_LITE_ENSURE_EQ(context, cond_output->type, kTfLiteBool); |
| 91 | if (cond_output->dims->size == 0) { |
| 92 | // It's okay if it's a 0D scalar. |
| 93 | return kTfLiteOk; |
| 94 | } |
| 95 | // Otherwise it must be 1D with shape [1]. |
| 96 | TF_LITE_ENSURE_EQ(context, cond_output->dims->size, 1); |
| 97 | TF_LITE_ENSURE_EQ(context, cond_output->dims->data[0], 1); |
| 98 | return kTfLiteOk; |
| 99 | } |
| 100 | |
| 101 | } // namespace |
| 102 | |