Improve the error message when importing a flatbuffer which has empty buffers.

PiperOrigin-RevId: 315120693
Change-Id: I3e40dc860fb0c984c7655f645013862443a1bf8f
This commit is contained in:
Jing Pu 2020-06-06 19:54:23 -07:00 committed by TensorFlower Gardener
parent 36cc491e71
commit 735bb0fc23

View File

@ -424,6 +424,10 @@ StatusOr<Operation*> BuildExternalConstOp(const tflite::TensorT& tensor,
StatusOr<Operation*> BuildConstOp(const tflite::TensorT& tensor,
const std::vector<uint8_t>& buffer,
OpBuilder builder, Location loc) {
if (buffer.empty()) {
return errors::InvalidArgument("Constant's buffer may not be empty");
}
TF_ASSIGN_OR_RETURN(auto type, GetTensorType(tensor, builder,
/*shapeless_are_scalars=*/true,
/*is_constant=*/true));