| 39 | // when resizing `While` op's outputs. |
| 40 | template <typename SrcVector, typename DstVector> |
| 41 | TfLiteStatus CopyTensorsShapeAndType(TfLiteContext* context, |
| 42 | Subgraph* src_subgraph, |
| 43 | const SrcVector& src_tensor_indices, |
| 44 | Subgraph* dst_subgraph, |
| 45 | const DstVector& dst_tensor_indices, |
| 46 | bool resize_subgraph_inputs) { |
| 47 | TF_LITE_ENSURE_EQ(context, src_tensor_indices.size(), |
| 48 | dst_tensor_indices.size()); |
| 49 | for (int i = 0; i < src_tensor_indices.size(); ++i) { |
| 50 | const TfLiteTensor* src_tensor = |
| 51 | src_subgraph->tensor(src_tensor_indices[i]); |
| 52 | |
| 53 | TfLiteTensor* dst_tensor = dst_subgraph->tensor(dst_tensor_indices[i]); |
| 54 | if (resize_subgraph_inputs) { |
| 55 | std::vector<int> dims(src_tensor->dims->data, |
| 56 | src_tensor->dims->data + src_tensor->dims->size); |
| 57 | dst_subgraph->ResizeInputTensor(dst_tensor_indices[i], dims); |
| 58 | } else { |
| 59 | TF_LITE_ENSURE_OK( |
| 60 | context, context->ResizeTensor(context, dst_tensor, |
| 61 | TfLiteIntArrayCopy(src_tensor->dims))); |
| 62 | } |
| 63 | dst_tensor->type = src_tensor->type; |
| 64 | } |
| 65 | return kTfLiteOk; |
| 66 | } |
| 67 | |
| 68 | // Copy the tensors data from tensors `src_tensor_indices` in `src_subgraph` |
| 69 | // to `dst_tensor_indices` in `dst_subgraph`. |
no test coverage detected