Execute nets_or_steps iter_num times. Args: nets_or_steps: a ExecutionStep or a Net or a list of ExecutionSteps or a list nets. iter_num: the number times to execute the nets_or_steps. Returns: A ExecutionStep instance.
(name, nets_or_steps, iter_num)
| 344 | |
| 345 | |
| 346 | def For(name, nets_or_steps, iter_num): |
| 347 | """ |
| 348 | Execute nets_or_steps iter_num times. |
| 349 | |
| 350 | Args: |
| 351 | nets_or_steps: a ExecutionStep or a Net or a list of ExecutionSteps or |
| 352 | a list nets. |
| 353 | iter_num: the number times to execute the nets_or_steps. |
| 354 | |
| 355 | Returns: |
| 356 | A ExecutionStep instance. |
| 357 | """ |
| 358 | init_net = core.Net('init-net') |
| 359 | iter_cnt = init_net.CreateCounter([], init_count=iter_num) |
| 360 | iter_net = core.Net('For-iter') |
| 361 | iter_done = iter_net.CountDown([iter_cnt]) |
| 362 | |
| 363 | for_step = core.scoped_execution_step( |
| 364 | _get_next_step_name('For-inner', name), |
| 365 | _PrependNets(nets_or_steps, iter_net), |
| 366 | should_stop_blob=iter_done) |
| 367 | return Do(name + '/For', |
| 368 | Do(name + '/For-init-net', init_net), |
| 369 | for_step) |
| 370 | |
| 371 | |
| 372 | def While(name, condition_blob_or_net, nets_or_steps): |
no test coverage detected