From 3d2621cee7a68218656398318754ca6a4daa7f6a Mon Sep 17 00:00:00 2001 From: "A. Unique TensorFlower" <gardener@tensorflow.org> Date: Wed, 20 Jan 2021 09:30:28 -0800 Subject: [PATCH] Improve error message. You also get this message if the variable has been deleted. PiperOrigin-RevId: 352808836 Change-Id: I928a579f177b3db839a4788c39337bf398b247de --- tensorflow/core/kernels/resource_variable_ops.cc | 9 ++++----- .../linalg/sparse/csr_sparse_matrix_ops_test.py | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/tensorflow/core/kernels/resource_variable_ops.cc b/tensorflow/core/kernels/resource_variable_ops.cc index d16c8f51450..950a80b6b2d 100644 --- a/tensorflow/core/kernels/resource_variable_ops.cc +++ b/tensorflow/core/kernels/resource_variable_ops.cc @@ -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 diff --git a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py index 48441423e88..b9d9f007167 100644 --- a/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py +++ b/tensorflow/python/kernel_tests/linalg/sparse/csr_sparse_matrix_ops_test.py @@ -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)