Wrapper for `Graph.control_dependencies()` using the default graph. See `tf.Graph.control_dependencies` for more details. When eager execution is enabled, any callable object in the `control_inputs` list will be called. Args: control_inputs: A list of `Operation` or `Tensor` objects
(control_inputs)
| 5304 | |
| 5305 | @tf_export("control_dependencies") |
| 5306 | def control_dependencies(control_inputs): |
| 5307 | """Wrapper for `Graph.control_dependencies()` using the default graph. |
| 5308 | |
| 5309 | See `tf.Graph.control_dependencies` |
| 5310 | for more details. |
| 5311 | |
| 5312 | When eager execution is enabled, any callable object in the `control_inputs` |
| 5313 | list will be called. |
| 5314 | |
| 5315 | Args: |
| 5316 | control_inputs: A list of `Operation` or `Tensor` objects which must be |
| 5317 | executed or computed before running the operations defined in the context. |
| 5318 | Can also be `None` to clear the control dependencies. If eager execution |
| 5319 | is enabled, any callable object in the `control_inputs` list will be |
| 5320 | called. |
| 5321 | |
| 5322 | Returns: |
| 5323 | A context manager that specifies control dependencies for all |
| 5324 | operations constructed within the context. |
| 5325 | """ |
| 5326 | if context.executing_eagerly(): |
| 5327 | if control_inputs: |
| 5328 | # Excute any pending callables. |
| 5329 | for control in control_inputs: |
| 5330 | if callable(control): |
| 5331 | control() |
| 5332 | return NullContextmanager() |
| 5333 | else: |
| 5334 | return get_default_graph().control_dependencies(control_inputs) |
| 5335 | |
| 5336 | |
| 5337 | class _DefaultStack(threading.local): |
no test coverage detected