()
| 65 | get_device_count("xpu") <= 2, reason="xpu counts need > 2", |
| 66 | ) |
| 67 | def test_uniform_op(): |
| 68 | set_global_seed(1024) |
| 69 | shape = ( |
| 70 | 8, |
| 71 | 9, |
| 72 | 11, |
| 73 | 12, |
| 74 | ) |
| 75 | shape = Tensor(shape, dtype="int32") |
| 76 | op = UniformRNG(seed=get_global_rng_seed(), dtype="float32") |
| 77 | (output,) = apply(op, shape) |
| 78 | assert np.fabs(output.numpy().mean() - 0.5) < 1e-1 |
| 79 | assert str(output.device) == str(CompNode("xpux")) |
| 80 | assert output.dtype == np.float32 |
| 81 | |
| 82 | cn = CompNode("xpu2") |
| 83 | seed = 233333 |
| 84 | h = new_rng_handle(cn, seed) |
| 85 | op = UniformRNG(seed=seed, dtype="float32", handle=h) |
| 86 | (output,) = apply(op, shape) |
| 87 | delete_rng_handle(h) |
| 88 | assert np.fabs(output.numpy().mean() - 0.5) < 1e-1 |
| 89 | assert str(output.device) == str(cn) |
| 90 | assert output.dtype == np.float32 |
| 91 | |
| 92 | |
| 93 | @pytest.mark.skipif( |
nothing calls this directly
no test coverage detected