aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/ops
diff options
context:
space:
mode:
authorGravatar Alexandre Passos <apassos@google.com>2018-10-04 15:11:26 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-04 15:16:24 -0700
commit26d3617d2ab5f4874b73059be524e94b9535465b (patch)
treed4e003ef8d0a675f51c3fa9228ca8eb051fc34ac /tensorflow/python/ops
parent2e2e89699c1186eef157911b57e4b062de376ce9 (diff)
Avoid creating control edges on not-this-graph.
PiperOrigin-RevId: 215811680
Diffstat (limited to 'tensorflow/python/ops')
-rw-r--r--tensorflow/python/ops/control_flow_ops.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/tensorflow/python/ops/control_flow_ops.py b/tensorflow/python/ops/control_flow_ops.py
index f779c3d273..5bc217d355 100644
--- a/tensorflow/python/ops/control_flow_ops.py
+++ b/tensorflow/python/ops/control_flow_ops.py
@@ -1333,6 +1333,9 @@ class ControlFlowState(object):
"""
if util.IsLoopSwitch(op):
return None
+ if op.graph._building_function: # pylint: disable=protected-access
+ # The optimization here is tricky to apply to functions
+ return array_ops.zeros_like(op.outputs[index])
dead_branch = util.IsSwitch(op)
forward_ctxt = _GetWhileContext(op)
grad_state = self._map.get(forward_ctxt)