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

Method test_net_execution

caffe2/python/workspace_test.py:513–535  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

511
512class TestCWorkspace(htu.HypothesisTestCase):
513 def test_net_execution(self):
514 ws = workspace.C.Workspace()
515 self.assertEqual(ws.nets, {})
516 self.assertEqual(ws.blobs, {})
517 net = core.Net("test-net")
518 net.ConstantFill([], "testblob", shape=[1, 2, 3, 4], value=1.0)
519 ws.create_net(net)
520 # If we do not specify overwrite, this should raise an error.
521 with self.assertRaises(RuntimeError):
522 ws.create_net(net)
523 # But, if we specify overwrite, this should pass.
524 ws.create_net(net, True)
525 # Overwrite can also be a kwarg.
526 ws.create_net(net, overwrite=True)
527 self.assertIn("testblob", ws.blobs)
528 self.assertEqual(len(ws.nets), 1)
529 net_name = net.Proto().name
530 self.assertIn("test-net", net_name)
531 net = ws.nets[net_name].run()
532 blob = ws.blobs["testblob"]
533 np.testing.assert_array_equal(
534 np.ones((1, 2, 3, 4), dtype=np.float32), blob.fetch()
535 )
536
537 @given(name=st.text(), value=st.floats(min_value=-1, max_value=1.0))
538 def test_operator_run(self, name, value):

Callers

nothing calls this directly

Calls 8

ProtoMethod · 0.95
NetMethod · 0.80
assertRaisesMethod · 0.80
assertEqualMethod · 0.45
create_netMethod · 0.45
runMethod · 0.45
onesMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected