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

Method setUp

caffe2/python/control_test.py:13–57  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

11
12class TestControl(test_util.TestCase):
13 def setUp(self):
14 super().setUp()
15 self.N_ = 10
16
17 self.init_net_ = core.Net("init-net")
18 cnt = self.init_net_.CreateCounter([], init_count=0)
19 const_n = self.init_net_.ConstantFill(
20 [], shape=[], value=self.N_, dtype=core.DataType.INT64)
21 const_0 = self.init_net_.ConstantFill(
22 [], shape=[], value=0, dtype=core.DataType.INT64)
23
24 self.cnt_net_ = core.Net("cnt-net")
25 self.cnt_net_.CountUp([cnt])
26 curr_cnt = self.cnt_net_.RetrieveCount([cnt])
27 self.init_net_.ConstantFill(
28 [], [curr_cnt], shape=[], value=0, dtype=core.DataType.INT64)
29 self.cnt_net_.AddExternalOutput(curr_cnt)
30
31 self.cnt_2_net_ = core.Net("cnt-2-net")
32 self.cnt_2_net_.CountUp([cnt])
33 self.cnt_2_net_.CountUp([cnt])
34 curr_cnt_2 = self.cnt_2_net_.RetrieveCount([cnt])
35 self.init_net_.ConstantFill(
36 [], [curr_cnt_2], shape=[], value=0, dtype=core.DataType.INT64)
37 self.cnt_2_net_.AddExternalOutput(curr_cnt_2)
38
39 self.cond_net_ = core.Net("cond-net")
40 cond_blob = self.cond_net_.LT([curr_cnt, const_n])
41 self.cond_net_.AddExternalOutput(cond_blob)
42
43 self.not_cond_net_ = core.Net("not-cond-net")
44 cond_blob = self.not_cond_net_.GE([curr_cnt, const_n])
45 self.not_cond_net_.AddExternalOutput(cond_blob)
46
47 self.true_cond_net_ = core.Net("true-cond-net")
48 true_blob = self.true_cond_net_.LT([const_0, const_n])
49 self.true_cond_net_.AddExternalOutput(true_blob)
50
51 self.false_cond_net_ = core.Net("false-cond-net")
52 false_blob = self.false_cond_net_.GT([const_0, const_n])
53 self.false_cond_net_.AddExternalOutput(false_blob)
54
55 self.idle_net_ = core.Net("idle-net")
56 self.idle_net_.ConstantFill(
57 [], shape=[], value=0, dtype=core.DataType.INT64)
58
59 def CheckNetOutput(self, nets_and_expects):
60 """

Callers

nothing calls this directly

Calls 2

NetMethod · 0.80
AddExternalOutputMethod · 0.80

Tested by

no test coverage detected