Skip to content

Commit 66707f3

Browse files
suharshsangerson
authored andcommitted
Handle model deserialization when output tensor shape is NULL. (tensorflow#22219)
In flatbuffers, vectors default to NULL. Original change by alanchiao@. PiperOrigin-RevId: 212506392
1 parent 008ce56 commit 66707f3

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tensorflow/contrib/lite/model.cc

+5
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ TfLiteStatus InterpreterBuilder::BuildLocalIndexToRegistrationMapping() {
240240
namespace {
241241
template <class T>
242242
std::vector<int> FlatBufferIntArrayToVector(T* flat_array) {
243+
// Initialize shape of tensors with null shape. Empty vectors are converted
244+
// to nullptr for models that are constructed via flatbuffers::Pack.
245+
if (flat_array == nullptr) {
246+
return {};
247+
}
243248
std::vector<int> ret(flat_array->Length());
244249
for (int i = 0; i < flat_array->Length(); i++) {
245250
ret[i] = flat_array->Get(i);

0 commit comments

Comments
 (0)