(device, op_fn)
Wraps the ops generated by `op_fn` in tf.while_loop.
Wraps the ops generated by `op_fn` in tf.while_loop.
Wraps the ops generated by op_fn in tf . while_loop .
def _wrap_computation_in_while_loop_with_stopping_signals(device, op_fn):
  """Wraps the ops generated by `op_fn` in tf.while_loop."""

  def cond(scalar_stopping_signal):
    return math_ops.logical_not(
        _StopSignals.should_stop(scalar_stopping_signal))

  def computation(unused_scalar_stopping_signal):
    return_value = op_fn()
    execute_ops = return_value['ops']
    signals = return_value['signals']
    with ops.control_dependencies(execute_ops):
      return _StopSignals.as_scalar_stopping_signal(signals)

  # By setting parallel_iterations=1, the parallel execution in while_loop is
  # basically turned off.
  with ops.device(device):
    return control_flow_ops.while_loop(
        cond,
        computation, [_StopSignals.NON_STOPPING_SIGNAL],
        parallel_iterations=1)
def _wrap_computation_in_while_loop_with_stopping_signals ( device , op_fn ) : def cond ( scalar_stopping_signal ) : return math_ops . logical_not ( _StopSignals . should_stop ( scalar_stopping_signal ) ) def computation ( unused_scalar_stopping_signal ) : return_value = op_fn ( ) execute_ops = return_value [ 'ops' ] signals = return_value [ 'signals' ] with ops . control_dependencies ( execute_ops ) : return _StopSignals . as_scalar_stopping_signal ( signals ) # By setting parallel_iterations=1, the parallel execution in while_loop is # basically turned off. with ops . device ( device ) : return control_flow_ops . while_loop ( cond , computation , [ _StopSignals . NON_STOPPING_SIGNAL ] , parallel_iterations = 1 )