()
| 155 | get_device_count("xpu") <= 2, reason="xpu counts need > 2", |
| 156 | ) |
| 157 | def test_poisson_op(): |
| 158 | set_global_seed(1024) |
| 159 | lam = F.full([8, 9, 11, 12], value=2, dtype="float32") |
| 160 | op = PoissonRNG(seed=get_global_rng_seed()) |
| 161 | (output,) = apply(op, lam) |
| 162 | assert np.fabs(output.numpy().mean() - 2.0) < 1e-1 |
| 163 | assert np.fabs(np.sqrt(output.numpy().var()) - np.sqrt(2.0)) < 1e-1 |
| 164 | assert str(output.device) == str(CompNode("xpux")) |
| 165 | |
| 166 | cn = CompNode("xpu2") |
| 167 | seed = 233333 |
| 168 | h = new_rng_handle(cn, seed) |
| 169 | lam = F.full([8, 9, 11, 12], value=2, dtype="float32", device=cn) |
| 170 | op = PoissonRNG(seed=seed, handle=h) |
| 171 | (output,) = apply(op, lam) |
| 172 | delete_rng_handle(h) |
| 173 | assert np.fabs(output.numpy().mean() - 2.0) < 1e-1 |
| 174 | assert np.fabs(np.sqrt(output.numpy().var()) - np.sqrt(2.0)) < 1e-1 |
| 175 | assert str(output.device) == str(cn) |
| 176 | |
| 177 | |
| 178 | @pytest.mark.skipif( |
nothing calls this directly
no test coverage detected