Improve error message.

You also get this message if the variable has been deleted.

PiperOrigin-RevId: 352808836
Change-Id: I928a579f177b3db839a4788c39337bf398b247de
This commit is contained in:
A. Unique TensorFlower 2021-01-20 09:30:28 -08:00 committed by TensorFlower Gardener
parent f0ef7e229f
commit 3d2621cee7
2 changed files with 5 additions and 6 deletions

View File

@ -136,11 +136,10 @@ void ReadVariableOp::Compute(OpKernelContext* ctx) {
const auto status = LookupResource(ctx, handle, &variable);
OP_REQUIRES(ctx, status.ok(),
errors::FailedPrecondition(
"Could not find variable ", handle.name(), ". ",
"This could mean that the variable has been deleted. ",
"In TF1, it can also mean the variable is uninitialized. ",
"Debug info: container=", handle.container(),
", status=", status.ToString()));
"Error while reading resource variable ", handle.name(),
" from Container: ", handle.container(),
". This could mean that the variable was uninitialized. ",
status.ToString()));
tf_shared_lock ml(*variable->mu());
// We're acquiring a reference to the underlying buffer while

View File

@ -193,7 +193,7 @@ class CSRSparseMatrixOpsTest(test.TestCase):
a_rt = sparse_csr_matrix_ops.csr_sparse_matrix_to_dense(
v, type=dtypes.float32)
v_reassign = state_ops.assign(v, v_id).op
with self.assertRaisesOpError("uninitialized"):
with self.assertRaisesOpError("Error while reading resource variable sm"):
self.evaluate(a_rt)
self.evaluate(v.initializer)
a_rt_value = self.evaluate(a_rt)