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

Method test_while_net

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

Source from the content-addressed store, hash-verified

311 self.assertTrue(str(local_blob) not in ws.blobs)
312
313 def test_while_net(self):
314 with NetBuilder() as nb:
315 x = ops.Const(0)
316 y = ops.Const(0)
317 with ops.WhileNet():
318 with ops.Condition():
319 ops.Add([x, ops.Const(1)], [x])
320 ops.LT([x, ops.Const(7)])
321 ops.Add([x, y], [y])
322
323 plan = Plan('while_net_test')
324 plan.AddStep(to_execution_step(nb))
325 ws = workspace.C.Workspace()
326 ws.run(plan)
327
328 x_value = ws.blobs[str(x)].fetch()
329 y_value = ws.blobs[str(y)].fetch()
330
331 self.assertEqual(x_value, 7)
332 self.assertEqual(y_value, 21)

Callers

nothing calls this directly

Calls 11

AddStepMethod · 0.95
NetBuilderClass · 0.90
PlanClass · 0.90
to_execution_stepFunction · 0.90
ConstMethod · 0.80
WhileNetMethod · 0.80
ConditionMethod · 0.80
AddMethod · 0.45
runMethod · 0.45
fetchMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected