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

Method ResizeTensorImpl

tensorflow/lite/core/subgraph.cc:1040–1075  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1038}
1039
1040TfLiteStatus Subgraph::ResizeTensorImpl(TfLiteTensor* tensor,
1041 TfLiteIntArray* new_size) {
1042 // Note that in theory we could resize kTfLiteArenaRwPersistent tensors too.
1043 if (tensor->allocation_type == kTfLiteArenaRw ||
1044 tensor->allocation_type == kTfLiteDynamic ||
1045 tensor->allocation_type == kTfLiteArenaRwPersistent) {
1046 tensor_resized_since_op_invoke_ |=
1047 TfLiteIntArrayEqual(tensor->dims, new_size) == 0;
1048 if (tensor->type != kTfLiteString) {
1049 size_t bytesRequired;
1050 TfLiteStatus status = BytesRequired(tensor->type, new_size->data,
1051 new_size->size, &bytesRequired);
1052 if (status != kTfLiteOk) {
1053 TfLiteIntArrayFree(new_size);
1054 return kTfLiteError;
1055 }
1056
1057 // Realloc space for kTfLiteDynamic tensors.
1058 TfLiteTensorRealloc(bytesRequired, tensor);
1059 tensor->bytes = bytesRequired;
1060 }
1061 if (tensor->dims) TfLiteIntArrayFree(tensor->dims);
1062 tensor->dims = new_size;
1063
1064 if (tensor->allocation_type != kTfLiteDynamic) {
1065 tensor->data.raw = nullptr;
1066 }
1067 } else {
1068 // kTfLiteMmapRo tensors are stored in the flatbuffer and are therefore
1069 // of fixed size.
1070 TfLiteIntArrayFree(new_size);
1071 ReportError("Attempting to resize a fixed-size tensor.");
1072 return kTfLiteError;
1073 }
1074 return kTfLiteOk;
1075}
1076
1077void Subgraph::UseNNAPI(bool enable) {
1078 // Note that there is no way to disable the delegate once it modified the

Callers 1

ResizeTensorMethod · 0.80

Calls 5

TfLiteIntArrayEqualFunction · 0.85
BytesRequiredFunction · 0.85
TfLiteIntArrayFreeFunction · 0.85
TfLiteTensorReallocFunction · 0.85
ReportErrorFunction · 0.50

Tested by

no test coverage detected