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

Method If

caffe2/python/net_builder.py:323–334  ·  view source on GitHub ↗

Creates a NetBuilder that will execute once as the next step of the current NetBuilder if the blob `cond` is True. Example: with ops.If(ops.Const(True)): ops.Print(ops.Const('Will print')) with ops.If(ops.Const(False)):

(self, cond, name=None)

Source from the content-addressed store, hash-verified

321 _StopGuard(has_stopped_blob=has_stopped_blob, name=name))
322
323 def If(self, cond, name=None):
324 """
325 Creates a NetBuilder that will execute once as the next step of the
326 current NetBuilder if the blob `cond` is True.
327 Example:
328 with ops.If(ops.Const(True)):
329 ops.Print(ops.Const('Will print'))
330 with ops.If(ops.Const(False)):
331 ops.Print(ops.Const('Wont print'))
332 The example will print 'Will print' once.
333 """
334 return NetBuilder.current().add(_RunIf(cond, name=name))
335
336 def IfNet(self, cond, name=None):
337 """

Callers 11

ceilMethod · 0.80
maxMethod · 0.80
minMethod · 0.80
visit_ModuleMethod · 0.80
_test_ifFunction · 0.80
_actual_loopMethod · 0.80
test_control_op_remapMethod · 0.80
IfCondTestMethod · 0.80
IfElseCondTestMethod · 0.80
example_loopFunction · 0.80
add_if_opFunction · 0.80

Calls 3

_RunIfClass · 0.85
currentMethod · 0.80
addMethod · 0.45

Tested by 7

visit_ModuleMethod · 0.64
_test_ifFunction · 0.64
_actual_loopMethod · 0.64
test_control_op_remapMethod · 0.64
IfCondTestMethod · 0.64
IfElseCondTestMethod · 0.64
example_loopFunction · 0.64