Caffe2 - Python API
A deep learning, cross platform ML framework
control_ops.py
1 ## @package control_ops
2 # Module caffe2.python.helpers.control_ops
3 from __future__ import absolute_import
4 from __future__ import division
5 from __future__ import print_function
6 from __future__ import unicode_literals
7 
8 from caffe2.python.control_ops_util import add_if_op, add_while_op
9 
10 
11 def cond(model, cond_blob, external_blobs, then_model, else_model=None):
12  """Condition"""
13  add_if_op(
14  model.net,
15  cond_blob,
16  external_blobs,
17  then_model.net,
18  else_model.net if else_model else None)
19 
20 
21 def loop(model, cond_blob, external_blobs, loop_model, cond_model=None):
22  """Loop"""
23  add_while_op(
24  model.net,
25  cond_blob,
26  external_blobs,
27  loop_model.net,
28  cond_model.net if cond_model else None)