diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-05-18 16:28:59 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-05-18 16:32:05 -0700 |
commit | f4cb5978667ccf6396e4a779e3a482766959e5dd (patch) | |
tree | bd86d11f33b3e33edbdde2d4cd55799bd6cf1307 | |
parent | 88ec2f68522495d13d8efc5542c7999e841b85e5 (diff) |
Improve import error messages.
PiperOrigin-RevId: 197217638
-rw-r--r-- | tensorflow/contrib/lite/toco/import_tensorflow.cc | 49 | ||||
-rw-r--r-- | tensorflow/contrib/lite/toco/import_tensorflow_test.cc | 9 |
2 files changed, 39 insertions, 19 deletions
diff --git a/tensorflow/contrib/lite/toco/import_tensorflow.cc b/tensorflow/contrib/lite/toco/import_tensorflow.cc index 9c35867051..27e9d1af88 100644 --- a/tensorflow/contrib/lite/toco/import_tensorflow.cc +++ b/tensorflow/contrib/lite/toco/import_tensorflow.cc @@ -203,9 +203,13 @@ Status ImportFloatArray(const TensorProto& input_tensor, Array* output_array) { toco::port::CopyToBuffer(input_tensor.tensor_content(), reinterpret_cast<char*>(output_float_data.data())); } else { - return Status(false, - "Neither input_content nor float_val have the right " - "dimensions for this float tensor"); + return Status( + false, + absl::StrCat("Neither input_content (", + input_tensor.tensor_content().size() / sizeof(float), + ") nor float_val (", input_tensor.float_val_size(), + ") have the right dimensions (", input_flat_size, + ") for this float tensor")); } return Status::OK(); } @@ -232,9 +236,13 @@ Status ImportQuint8Array(const TensorProto& input_tensor, Array* output_array) { toco::port::CopyToBuffer(input_tensor.tensor_content(), reinterpret_cast<char*>(output_int_data.data())); } else { - return Status(false, - "Neither input_content nor int_val have the right dimensions " - "for this uint8 tensor"); + return Status( + false, + absl::StrCat("Neither input_content (", + input_tensor.tensor_content().size() / sizeof(uint8_t), + ") nor int_val (", input_tensor.int_val_size(), + ") have the right dimensions (", input_flat_size, + ") for this uint8 tensor")); } return Status::OK(); } @@ -261,9 +269,13 @@ Status ImportInt32Array(const TensorProto& input_tensor, Array* output_array) { toco::port::CopyToBuffer(input_tensor.tensor_content(), reinterpret_cast<char*>(output_int_data.data())); } else { - return Status(false, - "Neither input_content nor int_val have the right dimensions " - "for this int32 tensor"); + return Status( + false, + absl::StrCat("Neither input_content (", + input_tensor.tensor_content().size() / sizeof(int32), + ") nor int_val (", input_tensor.int_val_size(), + ") have the right dimensions (", input_flat_size, + ") for this int32 tensor")); } return Status::OK(); } @@ -290,9 +302,13 @@ Status ImportInt64Array(const TensorProto& input_tensor, Array* output_array) { toco::port::CopyToBuffer(input_tensor.tensor_content(), reinterpret_cast<char*>(output_int_data.data())); } else { - return Status(false, - "Neither input_content nor int64_val have the right " - "dimensions for this int64 tensor"); + return Status( + false, + absl::StrCat("Neither input_content (", + input_tensor.tensor_content().size() / sizeof(int64), + ") nor int64_val (", input_tensor.int64_val_size(), + ") have the right dimensions (", input_flat_size, + ") for this int64 tensor")); } return Status::OK(); } @@ -327,9 +343,12 @@ Status ImportBoolArray(const TensorProto& input_tensor, Array* output_array) { // So far only encountered that in an array with 1 entry, let's // require that until we encounter a graph where that's not the case. if (output_bool_data.size() != 1) { - return Status(false, - "Neither input_content nor bool_val have the right " - "dimensions for this bool tensor"); + return Status( + false, absl::StrCat("Neither input_content (", + input_tensor.tensor_content().size(), + ") nor bool_val (", input_tensor.bool_val_size(), + ") have the right dimensions (", input_flat_size, + ") for this bool tensor")); } output_bool_data[0] = false; } diff --git a/tensorflow/contrib/lite/toco/import_tensorflow_test.cc b/tensorflow/contrib/lite/toco/import_tensorflow_test.cc index 5dc78f73ad..835676662b 100644 --- a/tensorflow/contrib/lite/toco/import_tensorflow_test.cc +++ b/tensorflow/contrib/lite/toco/import_tensorflow_test.cc @@ -148,10 +148,11 @@ TEST_P(ShapeImportTest, ValidShapeButZeroElements) { NodeDef node; BuildConstNode({1, 2, 2, 2}, GetParam(), 0, &node); auto status = ImportNode(node); - EXPECT_THAT(status.error_message(), - ::testing::MatchesRegex( - "Neither input_content nor .*_val have the right dimensions " - "for this .* tensor .while processing node 'Node1'.")); + EXPECT_THAT( + status.error_message(), + ::testing::MatchesRegex( + "Neither input_content .0. nor .*_val .0. have the right " + "dimensions .8. for this .* tensor .while processing node 'Node1'.")); } INSTANTIATE_TEST_CASE_P(ValidShapeButZeroElements, ShapeImportTest, ::testing::ValuesIn(TestTypes())); |