MCPcopy
hub / github.com/tinygrad/tinygrad / test_randperm_generator_out

Method test_randperm_generator_out

extra/torch_backend/test.py:14–22  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

12
13class TestTorchBackend(unittest.TestCase):
14 def test_randperm_generator_out(self):
15 n = 10
16 out = torch.empty(n, dtype=torch.long, device=device)
17 res = torch.randperm(n, out=out).cpu().numpy()
18 np.testing.assert_equal(set(res), set(range(n)))
19 np.testing.assert_equal(out.cpu().numpy(), res)
20
21 res2 = torch.randperm(n).cpu().numpy()
22 np.testing.assert_equal(set(res2), set(range(n)))
23
24 def test_numpy_ones(self):
25 a = torch.ones(4, device=device)

Callers

nothing calls this directly

Calls 4

randpermMethod · 0.80
assert_equalMethod · 0.80
emptyMethod · 0.45
numpyMethod · 0.45

Tested by

no test coverage detected