mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 15:08:02 -05:00
Fix bug where Tensor.randn returns inf (#1192)
* fix randn inf bug * add test * more compact test * clarify test purpose
This commit is contained in:
@@ -145,6 +145,13 @@ class TestTinygrad(unittest.TestCase):
|
||||
b = random_fn(10,10).realize()
|
||||
np.testing.assert_allclose(a.numpy(), b.numpy())
|
||||
|
||||
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
|
||||
try: self.assertNotIn(np.inf, Tensor.randn(16).numpy())
|
||||
except: raise
|
||||
finally: Tensor.rand = original_rand
|
||||
|
||||
def test_zeros_like_has_same_dtype(self):
|
||||
for datatype in [dtypes.float16, dtypes.float32, dtypes.int8, dtypes.int32, dtypes.int64, dtypes.uint8]:
|
||||
a = Tensor([1, 2, 3], dtype=datatype)
|
||||
|
||||
Reference in New Issue
Block a user