def IfNotCondTest(self, cond_net, expect, cond_on_blob): if cond_on_blob: step = control.Do( control.Do(cond_net), control.IfNot(cond_net.Proto().external_output[-1], self.cnt_net_)) else: step = control.IfNot(cond_net, self.cnt_net_) self.BuildAndRunPlan(step) self.CheckNetOutput([(self.cnt_net_, expect)])
def IfNotElseCondTest(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.IfNot(cond_net.Proto().external_output[-1], true_step, false_step)) else: step = control.IfNot(cond_net, true_step, false_step) self.BuildAndRunPlan(step) self.CheckNetOutput([(self.cnt_net_, expect)])
def IfNotElseCondTest(self, cond_net, cond_value, expect, cond_on_blob): if cond_value: run_net = self.cnt_2_net_ else: run_net = self.cnt_net_ if cond_on_blob: step = control.Do( 'if-not-else', control.Do('count', cond_net), control.IfNot('myIfNotElse', cond_net.Proto().external_output[-1], self.cnt_net_, self.cnt_2_net_)) else: step = control.IfNot('myIfNotElse', cond_net, self.cnt_net_, self.cnt_2_net_) self.BuildAndRunPlan(step) self.CheckNetOutput([(run_net, expect)])