/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
caffe2
/
python
/
/usr/local/lib64/python3.6/site-packages/caffe2/python
mkdir
upload
Name
Size
Mode
Actions
docs/
-
0755
rm
examples/
-
0755
rm
fakelowp/
-
0755
rm
helpers/
-
0755
rm
ideep/
-
0755
rm
layers/
-
0755
rm
mint/
-
0755
rm
mkl/
-
0755
rm
modeling/
-
0755
rm
models/
-
0755
rm
onnx/
-
0755
rm
operator_test/
-
0755
rm
predictor/
-
0755
rm
rnn/
-
0755
rm
serialized_test/
-
0755
rm
test/
-
0755
rm
trt/
-
0755
rm
__pycache__/
-
0755
rm
allcompare_test.py
2255
0644
edit
dl
rm
attention.py
12359
0644
edit
dl
rm
benchmark_generator.py
4912
0644
edit
dl
rm
binarysize.py
5521
0644
edit
dl
rm
brew.py
4762
0644
edit
dl
rm
brew_test.py
11739
0644
edit
dl
rm
build.py
153
0644
edit
dl
rm
cached_reader.py
4394
0644
edit
dl
rm
caffe2_pybind11_state.cpython-36m-x86_64-linux-gnu.so
48299712
0755
edit
dl
rm
caffe2_pybind11_state_gpu.cpython-36m-x86_64-linux-gnu.so
49048144
0755
edit
dl
rm
caffe_translator.py
35227
0644
edit
dl
rm
caffe_translator_test.py
3553
0644
edit
dl
rm
checkpoint.py
32101
0644
edit
dl
rm
checkpoint_test.py
13405
0644
edit
dl
rm
cnn.py
7626
0644
edit
dl
rm
context.py
2841
0644
edit
dl
rm
context_test.py
1792
0644
edit
dl
rm
control.py
19309
0644
edit
dl
rm
control_ops_grad.py
28893
0644
edit
dl
rm
control_ops_grad_test.py
1752
0644
edit
dl
rm
control_ops_util.py
10863
0644
edit
dl
rm
control_test.py
12276
0644
edit
dl
rm
convert.py
55
0644
edit
dl
rm
convert_test.py
201
0644
edit
dl
rm
convnet_benchmarks.py
20533
0644
edit
dl
rm
convnet_benchmarks_test.py
839
0644
edit
dl
rm
core.py
119400
0644
edit
dl
rm
core_gradients_test.py
38022
0644
edit
dl
rm
core_test.py
47683
0644
edit
dl
rm
crf.py
13250
0644
edit
dl
rm
crf_predict.py
1159
0644
edit
dl
rm
crf_viterbi_test.py
1663
0644
edit
dl
rm
dataio.py
23532
0644
edit
dl
rm
dataio_test.py
17575
0644
edit
dl
rm
dataset.py
12886
0644
edit
dl
rm
data_parallel_model.py
83100
0644
edit
dl
rm
data_parallel_model_test.py
56145
0644
edit
dl
rm
data_workers.py
15941
0644
edit
dl
rm
data_workers_test.py
6561
0644
edit
dl
rm
db_file_reader.py
6608
0644
edit
dl
rm
db_test.py
1110
0644
edit
dl
rm
device_checker.py
5157
0644
edit
dl
rm
dyndep.py
1533
0644
edit
dl
rm
embedding_generation_benchmark.py
5256
0644
edit
dl
rm
experiment_util.py
3625
0644
edit
dl
rm
extension_loader.py
744
0644
edit
dl
rm
fakefp16_transform_lib.py
322
0644
edit
dl
rm
filler_test.py
748
0644
edit
dl
rm
functional.py
4415
0644
edit
dl
rm
functional_test.py
4204
0644
edit
dl
rm
fused_8bit_rowwise_conversion_ops_test.py
3945
0644
edit
dl
rm
gradient_checker.py
15377
0644
edit
dl
rm
gradient_check_test.py
20729
0644
edit
dl
rm
gru_cell.py
5129
0644
edit
dl
rm
hip_test_util.py
405
0644
edit
dl
rm
hsm_util.py
2259
0644
edit
dl
rm
hypothesis_test.py
105762
0644
edit
dl
rm
hypothesis_test_util.py
26853
0644
edit
dl
rm
ideep_test_util.py
998
0644
edit
dl
rm
layers_test.py
92931
0644
edit
dl
rm
layer_model_helper.py
29340
0644
edit
dl
rm
layer_model_instantiator.py
3935
0644
edit
dl
rm
layer_parameter_sharing_test.py
9148
0644
edit
dl
rm
layer_test_util.py
4875
0644
edit
dl
rm
lazy.py
277
0644
edit
dl
rm
lazy_dyndep.py
2562
0644
edit
dl
rm
lazy_dyndep_test.py
3914
0644
edit
dl
rm
lengths_reducer_fused_8bit_rowwise_ops_test.py
7575
0644
edit
dl
rm
lengths_reducer_rowwise_8bit_ops_test.py
5710
0644
edit
dl
rm
lstm_benchmark.py
10649
0644
edit
dl
rm
memonger.py
34041
0644
edit
dl
rm
memonger_test.py
36910
0644
edit
dl
rm
mkl_test_util.py
1142
0644
edit
dl
rm
model_device_test.py
4777
0644
edit
dl
rm
model_helper.py
23492
0644
edit
dl
rm
model_helper_test.py
2336
0644
edit
dl
rm
modifier_context.py
1772
0644
edit
dl
rm
muji.py
8131
0644
edit
dl
rm
muji_test.py
3058
0644
edit
dl
rm
net_builder.py
27679
0644
edit
dl
rm
net_builder_test.py
11382
0644
edit
dl
rm
net_drawer.py
14264
0644
edit
dl
rm
net_printer.py
12704
0644
edit
dl
rm
net_printer_test.py
3190
0644
edit
dl
rm
nomnigraph.py
4216
0644
edit
dl
rm
nomnigraph_test.py
15427
0644
edit
dl
rm
nomnigraph_transformations.py
3787
0644
edit
dl
rm
nomnigraph_transformations_test.py
5767
0644
edit
dl
rm
normalizer.py
1411
0644
edit
dl
rm
normalizer_context.py
1007
0644
edit
dl
rm
normalizer_test.py
487
0644
edit
dl
rm
numa_benchmark.py
2230
0644
edit
dl
rm
numa_test.py
1663
0644
edit
dl
rm
observer_test.py
5316
0644
edit
dl
rm
operator_fp_exceptions_test.py
1248
0644
edit
dl
rm
optimizer.py
78813
0644
edit
dl
rm
optimizer_context.py
1462
0644
edit
dl
rm
optimizer_test.py
30705
0644
edit
dl
rm
optimizer_test_util.py
9187
0644
edit
dl
rm
parallelize_bmuf_distributed_test.py
9908
0644
edit
dl
rm
parallel_workers.py
7682
0644
edit
dl
rm
parallel_workers_test.py
3501
0644
edit
dl
rm
pipeline.py
17283
0644
edit
dl
rm
pipeline_test.py
2542
0644
edit
dl
rm
predictor_constants.py
198
0644
edit
dl
rm
python_op_test.py
9169
0644
edit
dl
rm
queue_util.py
4459
0644
edit
dl
rm
record_queue.py
4453
0644
edit
dl
rm
recurrent.py
13297
0644
edit
dl
rm
regularizer.py
21120
0644
edit
dl
rm
regularizer_context.py
1013
0644
edit
dl
rm
regularizer_test.py
10266
0644
edit
dl
rm
rnn_cell.py
68233
0644
edit
dl
rm
schema.py
45621
0644
edit
dl
rm
schema_test.py
15754
0644
edit
dl
rm
scope.py
3623
0644
edit
dl
rm
scope_test.py
5249
0644
edit
dl
rm
session.py
7642
0644
edit
dl
rm
session_test.py
2078
0644
edit
dl
rm
sparse_to_dense_mask_test.py
6565
0644
edit
dl
rm
sparse_to_dense_test.py
3556
0644
edit
dl
rm
task.py
24274
0644
edit
dl
rm
task_test.py
870
0644
edit
dl
rm
test_util.py
3524
0644
edit
dl
rm
text_file_reader.py
1990
0644
edit
dl
rm
timeout_guard.py
4054
0644
edit
dl
rm
toy_regression_test.py
2822
0644
edit
dl
rm
transformations.py
1832
0644
edit
dl
rm
transformations_test.py
11960
0644
edit
dl
rm
tt_core.py
9349
0644
edit
dl
rm
tt_core_test.py
2518
0644
edit
dl
rm
utils.py
14181
0644
edit
dl
rm
utils_test.py
1399
0644
edit
dl
rm
visualize.py
6315
0644
edit
dl
rm
workspace.py
25263
0644
edit
dl
rm
workspace_test.py
34844
0644
edit
dl
rm
_import_c_extension.py
2250
0644
edit
dl
rm
__init__.py
3925
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/caffe2/python/control.py
(19309B)
## @package control # Module caffe2.python.control """ Implement functions for controlling execution of nets and steps, including Do DoParallel For-loop While-loop Do-While-loop Switch If """ from caffe2.python import core from future.utils import viewitems # Used to generate names of the steps created by the control functions. # It is actually the internal index of these steps. _current_idx = 1 _used_step_names = set() def _get_next_step_name(control_name, base_name): global _current_idx, _used_step_names concat_name = '%s/%s' % (base_name, control_name) next_name = concat_name while next_name in _used_step_names: next_name = '%s_%d' % (concat_name, _current_idx) _current_idx += 1 _used_step_names.add(next_name) return next_name def _MakeList(input): """ input is a tuple. Example: (a, b, c) --> [a, b, c] (a) --> [a] ([a, b, c]) --> [a, b, c] """ if len(input) == 0: raise ValueError( 'input cannot be empty.') elif len(input) == 1: output = input[0] if not isinstance(output, list): output = [output] else: output = list(input) return output def _IsNets(nets_or_steps): if isinstance(nets_or_steps, list): return all(isinstance(n, core.Net) for n in nets_or_steps) else: return isinstance(nets_or_steps, core.Net) def _PrependNets(nets_or_steps, *nets): nets_or_steps = _MakeList((nets_or_steps,)) nets = _MakeList(nets) if _IsNets(nets_or_steps): return nets + nets_or_steps else: return [Do('prepend', nets)] + nets_or_steps def _AppendNets(nets_or_steps, *nets): nets_or_steps = _MakeList((nets_or_steps,)) nets = _MakeList(nets) if _IsNets(nets_or_steps): return nets_or_steps + nets else: return nets_or_steps + [Do('append', nets)] def GetConditionBlobFromNet(condition_net): """ The condition blob is the last external_output that must be a single bool """ assert len(condition_net.Proto().external_output) > 0, ( "Condition net %s must has at least one external output" % condition_net.Proto.name) # we need to use a blob reference here instead of a string # otherwise, it will add another name_scope to the input later # when we create new ops (such as OR of two inputs) return core.BlobReference(condition_net.Proto().external_output[-1]) def BoolNet(*blobs_with_bool_value): """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: one or more (blob, bool_value) pairs. The net will assign each bool_value to the corresponding blob. returns bool_net: A net assigning constant bool values to blobs. Examples: - BoolNet((blob_1, bool_value_1), ..., (blob_n, bool_value_n)) - BoolNet([(blob_1, net1), ..., (blob_n, bool_value_n)]) - BoolNet((cond_1, bool_value_1)) """ blobs_with_bool_value = _MakeList(blobs_with_bool_value) bool_net = core.Net('bool_net') for blob, bool_value in blobs_with_bool_value: out_blob = bool_net.ConstantFill( [], [blob], shape=[], value=bool_value, dtype=core.DataType.BOOL) bool_net.AddExternalOutput(out_blob) return bool_net def NotNet(condition_blob_or_net): """Not of a condition blob or net Args: condition_blob_or_net can be either blob or net. If condition_blob_or_net is Net, the condition is its last external_output that must be a single bool. returns not_net: the net NOT the input out_blob: the output blob of the not_net """ if isinstance(condition_blob_or_net, core.Net): condition_blob = GetConditionBlobFromNet(condition_blob_or_net) else: condition_blob = condition_blob_or_net not_net = core.Net('not_net') out_blob = not_net.Not(condition_blob) not_net.AddExternalOutput(out_blob) return not_net, out_blob def _CopyConditionBlobNet(condition_blob): """Make a condition net that copies the condition_blob Args: condition_blob is a single bool. returns not_net: the net NOT the input out_blob: the output blob of the not_net """ condition_net = core.Net('copy_condition_blob_net') out_blob = condition_net.Copy(condition_blob) condition_net.AddExternalOutput(out_blob) return condition_net, out_blob def MergeConditionNets(name, condition_nets, relation): """ Merge multi condition nets into a single condition nets. Args: name: name of the new condition net. condition_nets: a list of condition nets. The last external_output of each condition net must be single bool value. relation: can be 'And' or 'Or'. Returns: - A new condition net. Its last external output is relation of all condition_nets. """ if not isinstance(condition_nets, list): return condition_nets if len(condition_nets) <= 1: return condition_nets[0] if condition_nets else None merged_net = core.Net(name) for i in range(len(condition_nets)): net_proto = condition_nets[i].Proto() assert net_proto.device_option == merged_net.Proto().device_option assert net_proto.type == merged_net.Proto().type merged_net.Proto().op.extend(net_proto.op) merged_net.Proto().external_input.extend(net_proto.external_input) # discard external outputs as we're combining them together curr_cond = GetConditionBlobFromNet(condition_nets[i]) if i == 0: last_cond = curr_cond else: last_cond = merged_net.__getattr__(relation)([last_cond, curr_cond]) # merge attributes for k, v in viewitems(condition_nets[i]._attr_dict): merged_net._attr_dict[k] += v merged_net.AddExternalOutput(last_cond) return merged_net def CombineConditions(name, condition_nets, relation): """ Combine conditions of multi nets into a single condition nets. Unlike MergeConditionNets, the actual body of condition_nets is not copied into the combine condition net. One example is about multi readers. Each reader net has a reader_done condition. When we want to check whether all readers are done, we can use this function to build a new net. Args: name: name of the new condition net. condition_nets: a list of condition nets. The last external_output of each condition net must be single bool value. relation: can be 'And' or 'Or'. Returns: - A new condition net. Its last external output is relation of all condition_nets. """ if not condition_nets: return None if not isinstance(condition_nets, list): raise ValueError('condition_nets must be a list of nets.') if len(condition_nets) == 1: condition_blob = GetConditionBlobFromNet(condition_nets[0]) condition_net, _ = _CopyConditionBlobNet(condition_blob) return condition_net combined_net = core.Net(name) for i in range(len(condition_nets)): curr_cond = GetConditionBlobFromNet(condition_nets[i]) if i == 0: last_cond = curr_cond else: last_cond = combined_net.__getattr__(relation)( [last_cond, curr_cond]) combined_net.AddExternalOutput(last_cond) return combined_net def Do(name, *nets_or_steps): """ Execute the sequence of nets or steps once. Examples: - Do('myDo', net1, net2, ..., net_n) - Do('myDo', list_of_nets) - Do('myDo', step1, step2, ..., step_n) - Do('myDo', list_of_steps) """ nets_or_steps = _MakeList(nets_or_steps) if (len(nets_or_steps) == 1 and isinstance( nets_or_steps[0], core.ExecutionStep)): return nets_or_steps[0] else: return core.scoped_execution_step( _get_next_step_name('Do', name), nets_or_steps) def DoParallel(name, *nets_or_steps): """ Execute the nets or steps in parallel, waiting for all of them to finish Examples: - DoParallel('pDo', net1, net2, ..., net_n) - DoParallel('pDo', list_of_nets) - DoParallel('pDo', step1, step2, ..., step_n) - DoParallel('pDo', list_of_steps) """ nets_or_steps = _MakeList(nets_or_steps) if (len(nets_or_steps) == 1 and isinstance( nets_or_steps[0], core.ExecutionStep)): return nets_or_steps[0] else: return core.scoped_execution_step( _get_next_step_name('DoParallel', name), nets_or_steps, concurrent_substeps=True) def _RunOnceIf(name, condition_blob_or_net, nets_or_steps): """ Execute nets_or_steps once if condition_blob_or_net evaluates as true. If condition_blob_or_net is Net, the condition is its last external_output that must be a single bool. And this net will be executed before nets_or_steps so as to get the condition. """ condition_not_net, stop_blob = NotNet(condition_blob_or_net) if isinstance(condition_blob_or_net, core.Net): nets_or_steps = _PrependNets( nets_or_steps, condition_blob_or_net, condition_not_net) else: nets_or_steps = _PrependNets(nets_or_steps, condition_not_net) def if_step(control_name): return core.scoped_execution_step( _get_next_step_name(control_name, name), nets_or_steps, should_stop_blob=stop_blob, only_once=True, ) if _IsNets(nets_or_steps): bool_net = BoolNet((stop_blob, False)) return Do(name + '/_RunOnceIf', bool_net, if_step('_RunOnceIf-inner')) else: return if_step('_RunOnceIf') def _RunOnceIfNot(name, condition_blob_or_net, nets_or_steps): """ Similar to _RunOnceIf() but Execute nets_or_steps once if condition_blob_or_net evaluates as false. """ if isinstance(condition_blob_or_net, core.Net): condition_blob = GetConditionBlobFromNet(condition_blob_or_net) nets_or_steps = _PrependNets(nets_or_steps, condition_blob_or_net) else: copy_net, condition_blob = _CopyConditionBlobNet(condition_blob_or_net) nets_or_steps = _PrependNets(nets_or_steps, copy_net) return core.scoped_execution_step( _get_next_step_name('_RunOnceIfNot', name), nets_or_steps, should_stop_blob=condition_blob, only_once=True, ) def For(name, nets_or_steps, iter_num): """ 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. """ init_net = core.Net('init-net') iter_cnt = init_net.CreateCounter([], init_count=iter_num) iter_net = core.Net('For-iter') iter_done = iter_net.CountDown([iter_cnt]) for_step = core.scoped_execution_step( _get_next_step_name('For-inner', name), _PrependNets(nets_or_steps, iter_net), should_stop_blob=iter_done) return Do(name + '/For', Do(name + '/For-init-net', init_net), for_step) def While(name, condition_blob_or_net, nets_or_steps): """ Execute nets_or_steps when condition_blob_or_net returns true. Args: condition_blob_or_net: If it is an instance of Net, its last external_output must be a single bool. nets_or_steps: a ExecutionStep or a Net or a list of ExecutionSteps or a list nets. Returns: A ExecutionStep instance. """ condition_not_net, stop_blob = NotNet(condition_blob_or_net) if isinstance(condition_blob_or_net, core.Net): nets_or_steps = _PrependNets( nets_or_steps, condition_blob_or_net, condition_not_net) else: nets_or_steps = _PrependNets(nets_or_steps, condition_not_net) def while_step(control_name): return core.scoped_execution_step( _get_next_step_name(control_name, name), nets_or_steps, should_stop_blob=stop_blob, ) if _IsNets(nets_or_steps): # In this case, while_step has sub-nets: # [condition_blob_or_net, condition_not_net, nets_or_steps] # If stop_blob is pre-set to True (this may happen when While() is # called twice), the loop will exit after executing # condition_blob_or_net. So we use BootNet to set stop_blob to # False. bool_net = BoolNet((stop_blob, False)) return Do(name + '/While', bool_net, while_step('While-inner')) else: return while_step('While') def Until(name, condition_blob_or_net, nets_or_steps): """ Similar to While() but execute nets_or_steps when condition_blob_or_net returns false """ if isinstance(condition_blob_or_net, core.Net): stop_blob = GetConditionBlobFromNet(condition_blob_or_net) nets_or_steps = _PrependNets(nets_or_steps, condition_blob_or_net) else: stop_blob = core.BlobReference(str(condition_blob_or_net)) return core.scoped_execution_step( _get_next_step_name('Until', name), nets_or_steps, should_stop_blob=stop_blob) def DoWhile(name, condition_blob_or_net, nets_or_steps): """ Execute nets_or_steps when condition_blob_or_net returns true. It will execute nets_or_steps before evaluating condition_blob_or_net. Args: condition_blob_or_net: if it is an instance of Net, tts last external_output must be a single bool. nets_or_steps: a ExecutionStep or a Net or a list of ExecutionSteps or a list nets. Returns: A ExecutionStep instance. """ condition_not_net, stop_blob = NotNet(condition_blob_or_net) if isinstance(condition_blob_or_net, core.Net): nets_or_steps = _AppendNets( nets_or_steps, condition_blob_or_net, condition_not_net) else: nets_or_steps = _AppendNets(nets_or_steps, condition_not_net) # If stop_blob is pre-set to True (this may happen when DoWhile() is # called twice), the loop will exit after executing the first net/step # in nets_or_steps. This is not what we want. So we use BootNet to # set stop_blob to False. bool_net = BoolNet((stop_blob, False)) return Do(name + '/DoWhile', bool_net, core.scoped_execution_step( _get_next_step_name('DoWhile-inner', name), nets_or_steps, should_stop_blob=stop_blob, )) def DoUntil(name, condition_blob_or_net, nets_or_steps): """ Similar to DoWhile() but execute nets_or_steps when condition_blob_or_net returns false. It will execute nets_or_steps before evaluating condition_blob_or_net. Special case: if condition_blob_or_net is a blob and is pre-set to true, then only the first net/step of nets_or_steps will be executed and loop is exited. So you need to be careful about the initial value the condition blob when using DoUntil(), esp when DoUntil() is called twice. """ if not isinstance(condition_blob_or_net, core.Net): stop_blob = core.BlobReference(condition_blob_or_net) return core.scoped_execution_step( _get_next_step_name('DoUntil', name), nets_or_steps, should_stop_blob=stop_blob) nets_or_steps = _AppendNets(nets_or_steps, condition_blob_or_net) stop_blob = GetConditionBlobFromNet(condition_blob_or_net) # If stop_blob is pre-set to True (this may happen when DoWhile() is # called twice), the loop will exit after executing the first net/step # in nets_or_steps. This is not what we want. So we use BootNet to # set stop_blob to False. bool_net = BoolNet((stop_blob, False)) return Do(name + '/DoUntil', bool_net, core.scoped_execution_step( _get_next_step_name('DoUntil-inner', name), nets_or_steps, should_stop_blob=stop_blob, )) def Switch(name, *conditions): """ 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. Examples: - Switch('name', (cond_1, net_1), (cond_2, net_2), ..., (cond_n, net_n)) - Switch('name', [(cond_1, net1), (cond_2, net_2), ..., (cond_n, net_n)]) - Switch('name', (cond_1, net_1)) """ conditions = _MakeList(conditions) return core.scoped_execution_step( _get_next_step_name('Switch', name), [_RunOnceIf(name + '/Switch', cond, step) for cond, step in conditions]) def SwitchNot(name, *conditions): """ Similar to Switch() but execute the steps for which the condition is False. """ conditions = _MakeList(conditions) return core.scoped_execution_step( _get_next_step_name('SwitchNot', name), [_RunOnceIfNot(name + '/SwitchNot', cond, step) for cond, step in conditions]) def If(name, condition_blob_or_net, true_nets_or_steps, false_nets_or_steps=None): """ condition_blob_or_net is first evaluated or executed. If the condition is true, true_nets_or_steps is then executed, otherwise, false_nets_or_steps is executed. If condition_blob_or_net is Net, the condition is its last external_output that must be a single bool. And this Net will be executred before both true/false_nets_or_steps so as to get the condition. """ if not false_nets_or_steps: return _RunOnceIf(name + '/If', condition_blob_or_net, true_nets_or_steps) if isinstance(condition_blob_or_net, core.Net): condition_blob = GetConditionBlobFromNet(condition_blob_or_net) else: condition_blob = condition_blob_or_net return Do( name + '/If', _RunOnceIf(name + '/If-true', condition_blob_or_net, true_nets_or_steps), _RunOnceIfNot(name + '/If-false', condition_blob, false_nets_or_steps) ) def IfNot(name, condition_blob_or_net, true_nets_or_steps, false_nets_or_steps=None): """ If condition_blob_or_net returns false, executes true_nets_or_steps, otherwise executes false_nets_or_steps """ if not false_nets_or_steps: return _RunOnceIfNot(name + '/IfNot', condition_blob_or_net, true_nets_or_steps) if isinstance(condition_blob_or_net, core.Net): condition_blob = GetConditionBlobFromNet(condition_blob_or_net) else: condition_blob = condition_blob_or_net return Do( name + '/IfNot', _RunOnceIfNot(name + '/IfNot-true', condition_blob_or_net, true_nets_or_steps), _RunOnceIf(name + '/IfNot-false', condition_blob, false_nets_or_steps) )
Save
cmd:
run