Execute nets_or_steps when condition_blob_or_net returns true. It will execute nets_or_steps before evaluating condition_blob_or_net. Args: condition_blob_or_net: if it is an instance of Net, tts last external_output must be a single bool. nets_or_steps: a ExecutionStep o
(name, condition_blob_or_net, nets_or_steps)
| 427 | |
| 428 | |
| 429 | def DoWhile(name, condition_blob_or_net, nets_or_steps): |
| 430 | """ |
| 431 | Execute nets_or_steps when condition_blob_or_net returns true. It will |
| 432 | execute nets_or_steps before evaluating condition_blob_or_net. |
| 433 | |
| 434 | Args: |
| 435 | condition_blob_or_net: if it is an instance of Net, tts last external_output |
| 436 | must be a single bool. |
| 437 | nets_or_steps: a ExecutionStep or a Net or a list of ExecutionSteps or |
| 438 | a list nets. |
| 439 | |
| 440 | Returns: |
| 441 | A ExecutionStep instance. |
| 442 | """ |
| 443 | condition_not_net, stop_blob = NotNet(condition_blob_or_net) |
| 444 | if isinstance(condition_blob_or_net, core.Net): |
| 445 | nets_or_steps = _AppendNets( |
| 446 | nets_or_steps, condition_blob_or_net, condition_not_net) |
| 447 | else: |
| 448 | nets_or_steps = _AppendNets(nets_or_steps, condition_not_net) |
| 449 | |
| 450 | # If stop_blob is pre-set to True (this may happen when DoWhile() is |
| 451 | # called twice), the loop will exit after executing the first net/step |
| 452 | # in nets_or_steps. This is not what we want. So we use BootNet to |
| 453 | # set stop_blob to False. |
| 454 | bool_net = BoolNet((stop_blob, False)) |
| 455 | return Do(name + '/DoWhile', bool_net, core.scoped_execution_step( |
| 456 | _get_next_step_name('DoWhile-inner', name), |
| 457 | nets_or_steps, |
| 458 | should_stop_blob=stop_blob, |
| 459 | )) |
| 460 | |
| 461 | |
| 462 | def DoUntil(name, condition_blob_or_net, nets_or_steps): |
nothing calls this directly
no test coverage detected
searching dependent graphs…