MCPcopy Index your code
hub / github.com/pytorch/pytorch / For

Function For

caffe2/python/control.py:346–369  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

344
345
346def 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
372def While(name, condition_blob_or_net, nets_or_steps):

Callers 1

build_ForMethod · 0.85

Calls 4

_get_next_step_nameFunction · 0.85
_PrependNetsFunction · 0.85
DoFunction · 0.85
NetMethod · 0.80

Tested by

no test coverage detected