| 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) |