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

Function BoolNet

caffe2/python/control.py:97–126  ·  view source on GitHub ↗

A net assigning constant bool values to blobs. It is mainly used for initializing condition blobs, for example, in multi-task learning, we need to access reader_done blobs before reader_net run. In that case, the reader_done blobs must be initialized. Args: blobs_with_bool_value

(*blobs_with_bool_value)

Source from the content-addressed store, hash-verified

95
96
97def BoolNet(*blobs_with_bool_value):
98 """A net assigning constant bool values to blobs. It is mainly used for
99 initializing condition blobs, for example, in multi-task learning, we
100 need to access reader_done blobs before reader_net run. In that case,
101 the reader_done blobs must be initialized.
102
103 Args:
104 blobs_with_bool_value: one or more (blob, bool_value) pairs. The net will
105 assign each bool_value to the corresponding blob.
106
107 returns
108 bool_net: A net assigning constant bool values to blobs.
109
110 Examples:
111 - BoolNet((blob_1, bool_value_1), ..., (blob_n, bool_value_n))
112 - BoolNet([(blob_1, net1), ..., (blob_n, bool_value_n)])
113 - BoolNet((cond_1, bool_value_1))
114 """
115 blobs_with_bool_value = _MakeList(blobs_with_bool_value)
116 bool_net = core.Net('bool_net')
117 for blob, bool_value in blobs_with_bool_value:
118 out_blob = bool_net.ConstantFill(
119 [],
120 [blob],
121 shape=[],
122 value=bool_value,
123 dtype=core.DataType.BOOL)
124 bool_net.AddExternalOutput(out_blob)
125
126 return bool_net
127
128
129def NotNet(condition_blob_or_net):

Callers 4

_RunOnceIfFunction · 0.85
WhileFunction · 0.85
DoWhileFunction · 0.85
DoUntilFunction · 0.85

Calls 3

AddExternalOutputMethod · 0.95
_MakeListFunction · 0.85
NetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…