| 115 | } |
| 116 | |
| 117 | TfLiteStatus Prepare(TfLiteContext* context, TfLiteNode* node) { |
| 118 | TF_LITE_ENSURE(context, NumInputs(node) == 1 || NumInputs(node) == 2); |
| 119 | TF_LITE_ENSURE_EQ(context, NumOutputs(node), 1); |
| 120 | |
| 121 | // Always postpone sizing string tensors, even if we could in principle |
| 122 | // calculate their shapes now. String tensors don't benefit from having their |
| 123 | // shapes precalculated because the actual memory can only be allocated after |
| 124 | // we know all the content. |
| 125 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 126 | if (output->type != kTfLiteString) { |
| 127 | if (NumInputs(node) == 1 || |
| 128 | IsConstantTensor(GetInput(context, node, kShapeTensor))) { |
| 129 | TF_LITE_ENSURE_OK(context, ResizeOutput(context, node)); |
| 130 | } else { |
| 131 | SetTensorToDynamic(output); |
| 132 | } |
| 133 | } |
| 134 | return kTfLiteOk; |
| 135 | } |
| 136 | |
| 137 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 138 | const TfLiteTensor* input = GetInput(context, node, kInputTensor); |
nothing calls this directly
no test coverage detected