MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / CopyTensorsShapeAndType

Function CopyTensorsShapeAndType

tensorflow/lite/kernels/while.cc:41–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39// when resizing `While` op's outputs.
40template <typename SrcVector, typename DstVector>
41TfLiteStatus 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`.

Callers 2

PrepareFunction · 0.85
EvalFunction · 0.85

Calls 5

TfLiteIntArrayCopyFunction · 0.85
ResizeTensorMethod · 0.80
sizeMethod · 0.45
tensorMethod · 0.45
ResizeInputTensorMethod · 0.45

Tested by

no test coverage detected