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

Function IfNot

caffe2/python/control.py:554–574  ·  view source on GitHub ↗

If condition_blob_or_net returns false, executes true_nets_or_steps, otherwise executes false_nets_or_steps

(name, condition_blob_or_net,
          true_nets_or_steps, false_nets_or_steps=None)

Source from the content-addressed store, hash-verified

552
553
554def IfNot(name, condition_blob_or_net,
555 true_nets_or_steps, false_nets_or_steps=None):
556 """
557 If condition_blob_or_net returns false, executes true_nets_or_steps,
558 otherwise executes false_nets_or_steps
559 """
560 if not false_nets_or_steps:
561 return _RunOnceIfNot(name + '/IfNot',
562 condition_blob_or_net, true_nets_or_steps)
563
564 if isinstance(condition_blob_or_net, core.Net):
565 condition_blob = GetConditionBlobFromNet(condition_blob_or_net)
566 else:
567 condition_blob = condition_blob_or_net
568
569 return Do(
570 name + '/IfNot',
571 _RunOnceIfNot(name + '/IfNot-true',
572 condition_blob_or_net, true_nets_or_steps),
573 _RunOnceIf(name + '/IfNot-false', condition_blob, false_nets_or_steps)
574 )

Callers

nothing calls this directly

Calls 5

_RunOnceIfNotFunction · 0.85
isinstanceFunction · 0.85
GetConditionBlobFromNetFunction · 0.85
DoFunction · 0.85
_RunOnceIfFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…