fix tests for delete lazy [pr] (#7980)

This commit is contained in:
George Hotz
2024-12-02 12:00:48 +08:00
committed by GitHub
parent 254c86d712
commit d53cd92364
2 changed files with 6 additions and 3 deletions

View File

@@ -120,7 +120,9 @@ class TestDType(unittest.TestCase):
data = [1., 2., 0., 0.5, -1.5, 5.25]
for dt in dtypes:
arr = np.asarray(data).astype(dt)
tin = Tensor(arr).numpy()
tensor = Tensor(arr)
if not is_dtype_supported(tensor.dtype): continue
tin = tensor.numpy()
tor = torch.as_tensor(arr).detach().numpy()
assert dt == tin.dtype == tor.dtype, f"dtype mismatch: expected={dt} | tinygrad={tin.dtype} | torch={tor.dtype}"
np.testing.assert_allclose(tin, tor, atol=1e-6, rtol=1e-3)

View File

@@ -46,8 +46,9 @@ class TestTiny(unittest.TestCase):
nonlocal cnt
cnt += 1
return a+b
fa,fb = Tensor([1.,2,3]), Tensor([4.,5,6])
for _ in range(3): fxn(fa, fb)
for _ in range(3):
fa,fb = Tensor([1.,2,3]), Tensor([4.,5,6])
fxn(fa, fb)
# function is only called twice
self.assertEqual(cnt, 2)