mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-08 22:48:25 -05:00
create randperm and support pytorch backend (#10019)
This commit is contained in:
@@ -237,6 +237,13 @@ class TestTinygrad(unittest.TestCase):
|
||||
b = random_fn(10,10).realize()
|
||||
np.testing.assert_allclose(a.numpy(), b.numpy())
|
||||
|
||||
def test_randperm(self):
|
||||
Tensor.manual_seed(0)
|
||||
a = Tensor.randperm(10).realize()
|
||||
np.testing.assert_equal(a.numpy(), [5, 2, 8, 1, 3, 7, 9, 6, 0, 4])
|
||||
b = Tensor.randperm(1000).realize()
|
||||
np.testing.assert_equal(set(b.numpy()), set(range(1000)))
|
||||
|
||||
def test_randn_isnt_inf_on_zero(self):
|
||||
# simulate failure case of rand handing a zero to randn
|
||||
original_rand, Tensor.rand = Tensor.rand, Tensor.zeros
|
||||
|
||||
Reference in New Issue
Block a user