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
()
| 195 | |
| 196 | @tf_contextlib.contextmanager |
| 197 | def 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 | |
| 216 | def _is_tpu_strategy(strategy): |
nothing calls this directly
no test coverage detected