From b071d687adf2fb6383bb409eaca92d5ddee711c4 Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" <gardener@tensorflow.org> Date: Thu, 8 Oct 2020 16:12:45 -0700 Subject: [PATCH] Fixed bug where Tensorflow misreports sizes when sizes are mismatched. PiperOrigin-RevId: 336185233 Change-Id: I484b326ad9917495ea147448895eb72c8fc9caeb --- tensorflow/core/util/example_proto_fast_parsing.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tensorflow/core/util/example_proto_fast_parsing.cc b/tensorflow/core/util/example_proto_fast_parsing.cc index 03acb98989b..16f982f11b2 100644 --- a/tensorflow/core/util/example_proto_fast_parsing.cc +++ b/tensorflow/core/util/example_proto_fast_parsing.cc @@ -2285,12 +2285,13 @@ Status ParseContextDenseFeatures(const FeatureProtosMap& context_features, context_features.find(c.feature_name)->second; TensorShape dense_shape, example_shape; DataType dtype = c.dtype; - const size_t expected_max_elements = feature.length; + const size_t data_max_elements = feature.length; if (!c.shape.AsTensorShape(&example_shape) || - expected_max_elements != example_shape.num_elements()) { + data_max_elements != example_shape.num_elements()) { return errors::InvalidArgument( - "Inconsistent number of elements for feature ", c.feature_name, ": ", - expected_max_elements, " vs ", dense_shape.num_elements()); + "Inconsistent max number of elements for feature ", c.feature_name, + ": expected ", example_shape.num_elements(), ", but found ", + data_max_elements); } if (is_batch) { dense_shape.AddDim(num_examples); @@ -2324,7 +2325,7 @@ Status ParseContextDenseFeatures(const FeatureProtosMap& context_features, EnableAliasing(&stream); num_elements += ParseFeature(dtype, &stream, &out, &out_offset); } - if (num_elements != expected_max_elements) { + if (num_elements != data_max_elements) { return errors::InvalidArgument( "Unexpected number of elements in example ", ExampleName(example_names, e));