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

Function IsAllocatableTransientArray

tensorflow/lite/toco/tooling_util.cc:1787–1813  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1785}
1786
1787bool IsAllocatableTransientArray(const Model& model, const string& array_name) {
1788 // Optional array is not transient
1789 if (model.IsOptionalArray(array_name)) return false;
1790 // The model's input and output arrays are externally allocated.
1791 // They are not transient arrays.
1792 if (IsInputArray(model, array_name) || IsOutputArray(model, array_name)) {
1793 return false;
1794 }
1795 const auto& array = &model.GetArray(array_name);
1796 // An array with a constant buffer isn't a transient array.
1797 if (!!array->buffer) {
1798 return false;
1799 }
1800 // An array without shape isn't allocatable.
1801 if (!array->has_shape()) {
1802 return false;
1803 }
1804
1805 // The size of string tensors is rarely known ahead of time, so all transient
1806 // tensors of this type will need to be dynamically allocated.
1807 if (array->final_data_type == ArrayDataType::kString ||
1808 array->data_type == ArrayDataType::kString) {
1809 return false;
1810 }
1811
1812 return true;
1813}
1814
1815string AvailableArrayName(const Model& model, const string& name) {
1816 string sanitized_name = SanitizeNameForTFNode(name);

Callers 3

TransientArraySizeFunction · 0.85
AllocateTransientArrayFunction · 0.85
DeallocateTransientArrayFunction · 0.85

Calls 4

IsInputArrayFunction · 0.85
IsOutputArrayFunction · 0.85
IsOptionalArrayMethod · 0.80
has_shapeMethod · 0.80

Tested by

no test coverage detected