From bdfdec06d559a6b384761d65c6d35ce65dfaa584 Mon Sep 17 00:00:00 2001 From: Allen Lavoie Date: Tue, 13 Aug 2019 13:49:58 -0700 Subject: [PATCH] Only pre-read variables in tf.identity when executing eagerly Not necessary when graph building, and someone somewhere wrote a test which relies on it not happening... PiperOrigin-RevId: 263207114 --- tensorflow/python/ops/array_ops.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/ops/array_ops.py b/tensorflow/python/ops/array_ops.py index 830da765158..8108dd26084 100644 --- a/tensorflow/python/ops/array_ops.py +++ b/tensorflow/python/ops/array_ops.py @@ -196,8 +196,10 @@ def identity(input, name=None): # pylint: disable=redefined-builtin Returns: A `Tensor`. Has the same type as `input`. """ - # Make sure we get an input with handle data attached from resource variables. - input = ops.convert_to_tensor(input) + if context.executing_eagerly() and not hasattr(input, "graph"): + # Make sure we get an input with handle data attached from resource + # variables. Variables have correct handle data when graph building. + input = ops.convert_to_tensor(input) ret = gen_array_ops.identity(input, name=name) # Propagate handle data for happier shape inference for resource variables. if hasattr(input, "_handle_data"):