MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / clear_control_inputs

Function clear_control_inputs

tensorflow/python/ops/control_flow_util_v2.py:197–213  ·  view source on GitHub ↗

Clears the control inputs but preserves the ControlFlowContext. This is needed to preserve the XLAControlFlowControl when clearing control inputs for the gradient accumulators in while_v2. `ops.control_dependencies` does not allow that. Yields: A context manager in which the ops create

()

Source from the content-addressed store, hash-verified

195
196@tf_contextlib.contextmanager
197def clear_control_inputs():
198 """Clears the control inputs but preserves the ControlFlowContext.
199
200 This is needed to preserve the XLAControlFlowControl when clearing
201 control inputs for the gradient accumulators in while_v2.
202 `ops.control_dependencies` does not allow that.
203
204 Yields:
205 A context manager in which the ops created will not have any control inputs
206 by default but the control flow context is the same.
207 """
208 # pylint: disable=protected-access
209 control_flow_context = ops.get_default_graph()._get_control_flow_context()
210 with ops.control_dependencies(None):
211 ops.get_default_graph()._set_control_flow_context(control_flow_context)
212 yield
213 # pylint: enable=protected-access
214
215
216def _is_tpu_strategy(strategy):

Callers

nothing calls this directly

Calls 3

control_dependenciesMethod · 0.45

Tested by

no test coverage detected