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

Function Switch

caffe2/python/control.py:495–512  ·  view source on GitHub ↗

Execute the steps for which the condition is true. Each condition is a tuple (condition_blob_or_net, nets_or_steps). Note: 1. Multi steps can be executed if their conditions are true. 2. The conditions_blob_or_net (if it is Net) of all steps will be executed once.

(name, *conditions)

Source from the content-addressed store, hash-verified

493
494
495def Switch(name, *conditions):
496 """
497 Execute the steps for which the condition is true.
498 Each condition is a tuple (condition_blob_or_net, nets_or_steps).
499 Note:
500 1. Multi steps can be executed if their conditions are true.
501 2. The conditions_blob_or_net (if it is Net) of all steps will be
502 executed once.
503
504 Examples:
505 - Switch('name', (cond_1, net_1), (cond_2, net_2), ..., (cond_n, net_n))
506 - Switch('name', [(cond_1, net1), (cond_2, net_2), ..., (cond_n, net_n)])
507 - Switch('name', (cond_1, net_1))
508 """
509 conditions = _MakeList(conditions)
510 return core.scoped_execution_step(
511 _get_next_step_name('Switch', name),
512 [_RunOnceIf(name + '/Switch', cond, step) for cond, step in conditions])
513
514
515def SwitchNot(name, *conditions):

Callers

nothing calls this directly

Calls 3

_MakeListFunction · 0.85
_get_next_step_nameFunction · 0.85
_RunOnceIfFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…