no bool in range [pr] (#7988)

* no bool in range [pr]

* fix llvm

* add arg to range spec

* fix broken test

* forgot this one

* hotfix: test_tiny jit is a real test
This commit is contained in:
George Hotz
2024-12-02 19:05:16 +08:00
committed by GitHub
parent 8909dbd82c
commit 0c7477b108
7 changed files with 38 additions and 47 deletions

View File

@@ -1,5 +1,5 @@
# basic self-contained tests of the external functionality of tinygrad
import unittest
import unittest, random
from tinygrad import Tensor, Context, Variable, TinyJit, dtypes, Device
from tinygrad.helpers import IMAGE
@@ -41,14 +41,21 @@ class TestTiny(unittest.TestCase):
def test_jit(self):
cnt = 0
def new_rand_list(ln=10): return [random.randint(0, 100000) for _ in range(ln)]
@TinyJit
def fxn(a,b):
def fxn(a,b) -> Tensor:
nonlocal cnt
cnt += 1
return a+b
for _ in range(3):
fa,fb = Tensor([1.,2,3]), Tensor([4.,5,6])
fxn(fa, fb)
la,lb = new_rand_list(), new_rand_list()
fa,fb = Tensor(la), Tensor(lb)
ret = fxn(fa, fb)
# math is correct
self.assertListEqual(ret.tolist(), [a+b for a,b in zip(la, lb)])
# function is only called twice
self.assertEqual(cnt, 2)