Skip to content

Commit

Permalink
Only pre-read variables in tf.identity when executing eagerly
Browse files Browse the repository at this point in the history
Not necessary when graph building, and someone somewhere wrote a test which relies on it not happening...

PiperOrigin-RevId: 263207114
  • Loading branch information
allenlavoie authored and tensorflower-gardener committed Aug 13, 2019
1 parent a2a84a8 commit bdfdec0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tensorflow/python/ops/array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit bdfdec0

Please sign in to comment.