| 135 | } |
| 136 | |
| 137 | TfLiteStatus Eval(TfLiteContext* context, TfLiteNode* node) { |
| 138 | const TfLiteTensor* input = GetInput(context, node, kInputTensor); |
| 139 | TfLiteTensor* output = GetOutput(context, node, kOutputTensor); |
| 140 | |
| 141 | // There are two ways in which the 'output' can be made dynamic: it could be |
| 142 | // a string tensor, or its shape cannot be calculated during Prepare(). In |
| 143 | // either case, we now have all the information to calculate its shape. |
| 144 | if (IsDynamicTensor(output)) { |
| 145 | TF_LITE_ENSURE_OK(context, ResizeOutput(context, node)); |
| 146 | } |
| 147 | |
| 148 | // Note that string tensors are always "dynamic" in the sense that their size |
| 149 | // is not known until we have all the content. This applies even when their |
| 150 | // shape is known ahead of time. As a result, a string tensor is never given |
| 151 | // any memory by ResizeOutput(), and we need to do it manually here. Since |
| 152 | // reshape doesn't change the data, the output tensor needs exactly as many |
| 153 | // bytes as the input tensor. |
| 154 | if (output->type == kTfLiteString) { |
| 155 | auto bytes_required = input->bytes; |
| 156 | TfLiteTensorRealloc(bytes_required, output); |
| 157 | output->bytes = bytes_required; |
| 158 | } |
| 159 | |
| 160 | memcpy(output->data.raw, input->data.raw, input->bytes); |
| 161 | |
| 162 | return kTfLiteOk; |
| 163 | } |
| 164 | |
| 165 | } // namespace reshape |
| 166 |
nothing calls this directly
no test coverage detected