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

Method test_setup

caffe2/python/net_builder_test.py:167–189  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

165 self.assertEqual(e, a)
166
167 def test_setup(self):
168 with Task() as task:
169 with ops.task_init():
170 one = ops.Const(1)
171 two = ops.Add([one, one])
172 with ops.task_init():
173 three = ops.Const(3)
174 accum = ops.Add([two, three])
175 # here, accum should be 5
176 with ops.task_exit():
177 # here, accum should be 6, since this executes after lines below
178 seven_1 = ops.Add([accum, one])
179 six = ops.Add([accum, one])
180 ops.Add([accum, one], [accum])
181 seven_2 = ops.Add([accum, one])
182 o6 = final_output(six)
183 o7_1 = final_output(seven_1)
184 o7_2 = final_output(seven_2)
185 with LocalSession() as session:
186 session.run(task)
187 self.assertEqual(o6.fetch(), 6)
188 self.assertEqual(o7_1.fetch(), 7)
189 self.assertEqual(o7_2.fetch(), 7)
190
191 def test_multi_instance_python_op(self):
192 """

Callers

nothing calls this directly

Calls 10

TaskClass · 0.90
final_outputFunction · 0.90
LocalSessionClass · 0.90
task_initMethod · 0.80
ConstMethod · 0.80
task_exitMethod · 0.80
AddMethod · 0.45
runMethod · 0.45
assertEqualMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected