mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-10 07:28:15 -05:00
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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user