Exemplo n.º 1
0
 def IfCondTest(self, cond_net, expect, cond_on_blob):
     if cond_on_blob:
         step = control.Do(
             control.Do(cond_net),
             control.If(cond_net.Proto().external_output[-1],
                        self.cnt_net_))
     else:
         step = control.If(cond_net, self.cnt_net_)
     self.BuildAndRunPlan(step)
     self.CheckNetOutput([(self.cnt_net_, expect)])
Exemplo n.º 2
0
 def IfElseCondTest(self, cond_net, expect, cond_on_blob):
     true_step = control.For(self.cnt_net_, self.N_)
     false_step = control.For(self.cnt_net_, 2 * self.N_)
     if cond_on_blob:
         step = control.Do(
             control.Do(cond_net),
             control.If(cond_net.Proto().external_output[-1], true_step,
                        false_step))
     else:
         step = control.If(cond_net, true_step, false_step)
     self.BuildAndRunPlan(step)
     self.CheckNetOutput([(self.cnt_net_, expect)])
Exemplo n.º 3
0
 def IfElseCondTest(self, cond_net, cond_value, expect, cond_on_blob):
     if cond_value:
         run_net = self.cnt_net_
     else:
         run_net = self.cnt_2_net_
     if cond_on_blob:
         step = control.Do(
             'if-else-all', control.Do('count', cond_net),
             control.If('myIfElse',
                        cond_net.Proto().external_output[-1], self.cnt_net_,
                        self.cnt_2_net_))
     else:
         step = control.If('myIfElse', cond_net, self.cnt_net_,
                           self.cnt_2_net_)
     self.BuildAndRunPlan(step)
     self.CheckNetOutput([(run_net, expect)])