changes for symbolic (#6844)

* changes for symbolic

* only for ints

* check int first
This commit is contained in:
George Hotz
2024-10-02 12:57:16 +08:00
committed by GitHub
parent 1735f8ef1c
commit be12409b51
4 changed files with 24 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
import unittest
from tinygrad.dtype import dtypes
from tinygrad.ops import UOp
from tinygrad.ops import UOp, resolve
class TestUOpResolve(unittest.TestCase):
def test_simple_int(self):
@@ -39,6 +39,14 @@ class TestUOpResolve(unittest.TestCase):
u = UOp.const(dtypes.int, 4) > 7
self.assertFalse(u)
def test_ambiguous_less_than(self):
u = UOp.define_var("i", dtypes.pyint, 1, 10)
self.assertTrue(resolve(u < 4))
self.assertFalse(resolve(u < 4, False))
self.assertTrue(resolve(u < 11, False))
self.assertFalse(resolve(u < -1, False))
self.assertFalse(resolve(u < -1, True))
def test_float_direct(self):
u = UOp.const(dtypes.float, 4.5) + 7
self.assertEqual(float(u), 11.5)