Ignore while loops instead of mangling them in the automatic control dependencies.
authorAlexandre Passos <apassos@google.com>
Fri, 25 May 2018 23:43:40 +0000 (16:43 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Fri, 25 May 2018 23:49:05 +0000 (16:49 -0700)
PiperOrigin-RevId: 198122188

tensorflow/python/eager/function.py

index b46e061..23d87fb 100644 (file)
@@ -1215,6 +1215,9 @@ class AutomaticControlDependencies(object):
     # test that it works. Support while loops. Support init_scope escaping from
     # this.
     for op in new_operations:
+      # TODO(apassos) make this code safely support while loops.
+      if isinstance(op._control_flow_context, control_flow_ops.WhileContext):  # pylint: disable=protected-access
+        continue
       control_inputs = set()
       # Ensure stateful ops run
       if (op.type not in self._graph._registered_ops  # pylint: disable=protected-access