diff options
author | 2018-09-11 13:12:21 -0700 | |
---|---|---|
committer | 2018-09-11 13:15:54 -0700 | |
commit | dad6912b530c92b2f362f1cc2a83006a22f604b6 (patch) | |
tree | 37c5752fe425d9ac0adcbbe7fdd8a324e2a38cdf /tensorflow/contrib/lite/model.cc | |
parent | 1025b0c68b819a7292b51e51bbf7badc8818f286 (diff) |
Handle model deserialization when output tensor shape is NULL.
In flatbuffers, vectors default to NULL.
Original change by alanchiao@.
PiperOrigin-RevId: 212506392
Diffstat (limited to 'tensorflow/contrib/lite/model.cc')
-rw-r--r-- | tensorflow/contrib/lite/model.cc | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/model.cc b/tensorflow/contrib/lite/model.cc index 241865b3d8..6311d60b91 100644 --- a/tensorflow/contrib/lite/model.cc +++ b/tensorflow/contrib/lite/model.cc @@ -177,6 +177,11 @@ TfLiteStatus InterpreterBuilder::BuildLocalIndexToRegistrationMapping() { namespace { template <class T> std::vector<int> FlatBufferIntArrayToVector(T* flat_array) { + // Initialize shape of tensors with null shape. Empty vectors are converted + // to nullptr for models that are constructed via flatbuffers::Pack. + if (flat_array == nullptr) { + return {}; + } std::vector<int> ret(flat_array->Length()); for (int i = 0; i < flat_array->Length(); i++) { ret[i] = flat_array->Get(i); |