In grappler ConstantFolding:EvaluateOneNode, improve error message
if the TensorProto cannot be parsed into a Tensor.
Includes the name of the node that failed and the TensorShape.
Otherwise, all you get is a malloc failure and a CHECK that
doesn't tell you where the problem was.
PiperOrigin-RevId: 328390785
Change-Id: Id41b30efde5095d6e9048abfc74448fa8589d4e2
diff --git a/tensorflow/core/grappler/optimizers/constant_folding.cc b/tensorflow/core/grappler/optimizers/constant_folding.cc
index d595d2b..e44bed4 100644
--- a/tensorflow/core/grappler/optimizers/constant_folding.cc
+++ b/tensorflow/core/grappler/optimizers/constant_folding.cc
@@ -1338,7 +1338,9 @@
TF_RETURN_IF_ERROR(CheckAttrExists(*input_node, "value"));
const TensorProto& raw_val = input_node->attr().at("value").tensor();
Tensor* value = new Tensor(raw_val.dtype(), raw_val.tensor_shape());
- CHECK(value->FromProto(raw_val));
+ CHECK(value->FromProto(raw_val))
+ << "Unable to make Tensor from proto for " << node.name()
+ << " with shape " << raw_val.tensor_shape().DebugString();
inputs.emplace_back(value);
total_inputs_size += value->TotalBytes();
}