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

Method test_multithreaded_evaluation

caffe2/python/python_op_test.py:151–167  ·  view source on GitHub ↗
(self, x, n, w)

Source from the content-addressed store, hash-verified

149 w=st.integers(min_value=1, max_value=20))
150 @settings(deadline=1000)
151 def test_multithreaded_evaluation(self, x, n, w):
152 def f(inputs, outputs):
153 outputs[0].reshape(inputs[0].shape)
154 outputs[0].data[...] = inputs[0].data
155 ops = [CreatePythonOperator(f, ["x"], [str(i)]) for i in range(n)]
156 net = core.Net("net")
157 net.Proto().op.extend(ops)
158 net.Proto().type = "dag"
159 net.Proto().num_workers = w
160 iters = 100
161 plan = core.Plan("plan")
162 plan.AddStep(core.ExecutionStep("test-step", net, iters))
163 workspace.FeedBlob("x", x)
164 workspace.RunPlan(plan.Proto().SerializeToString())
165 for i in range(n):
166 y = workspace.FetchBlob(str(i))
167 np.testing.assert_almost_equal(x, y)
168
169 @given(x=hu.tensor(), in_place=st.booleans(), **hu.gcs)
170 @settings(deadline=10000)

Callers

nothing calls this directly

Calls 7

ProtoMethod · 0.95
AddStepMethod · 0.95
ProtoMethod · 0.95
CreatePythonOperatorFunction · 0.90
NetMethod · 0.80
rangeFunction · 0.50
extendMethod · 0.45

Tested by

no test coverage detected