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

Method test_builder_tuple

caffe2/python/python_op_test.py:77–92  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

75 workspace.RunNetOnce(net)
76
77 def test_builder_tuple(self):
78 net = core.Net("builder_template")
79 iter_blob = 'iter'
80 net.Python((op_builder, ['name', 5], {'extra': 4.2}))([iter_blob], [])
81 net.Python((op_builder, ['name', 5], {'extra': 4.2}))([iter_blob], [])
82 for repeat in range(2):
83 # check that the builder will be called exactly once for each
84 # PythonOp constructor. Cloning the net will also trigger a call
85 # to the builder when the net is created.
86 cloned_net = net.Clone('builder_%d' % repeat)
87 workspace.FeedBlob(iter_blob, np.array([0]))
88 # Builder gets called once per python op in the line below
89 workspace.CreateNet(cloned_net)
90 for i in range(10):
91 workspace.FeedBlob(iter_blob, np.array([i]))
92 workspace.RunNet(cloned_net)
93
94 @given(x=hu.tensor())
95 def test_feed_with_gc(self, x):

Callers

nothing calls this directly

Calls 4

PythonMethod · 0.95
CloneMethod · 0.95
NetMethod · 0.80
rangeFunction · 0.50

Tested by

no test coverage detected