mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-02-12 23:54:58 -05:00
tests for symbolic_simple failing tensor const spec [pr] (#8469)
* tests for symbolic_simple failing tensor const spec [pr] * mul is correct
This commit is contained in:
@@ -2048,6 +2048,26 @@ class TestBigGraph(unittest.TestCase):
|
||||
sink = tensor_rewrite(a)
|
||||
assert UPat.cvar(dtype=dtypes.int).match(sink, {})
|
||||
|
||||
def test_const_folding_mul(self):
|
||||
a = Tensor([1])
|
||||
sink = tensor_rewrite(a*0)
|
||||
assert UPat(Ops.CONST, arg=0).match(sink, {}), f"expected {sink} to collapse to a const 0"
|
||||
assert sink.shape == a.shape
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_const_folding_ne(self):
|
||||
a = Tensor([1])
|
||||
sink = tensor_rewrite(a != a)
|
||||
assert UPat(Ops.CONST, arg=False).match(sink, {}), f"expected {sink} to collapse to a const False"
|
||||
assert sink.shape == a.shape
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_const_folding_lt(self):
|
||||
a = Tensor([1])
|
||||
sink = tensor_rewrite(a < a)
|
||||
assert UPat(Ops.CONST, arg=False).match(sink, {}), f"expected {sink} to collapse to a const False"
|
||||
assert sink.shape == a.shape
|
||||
|
||||
tensor_const_pm = PatternMatcher([
|
||||
(UPat(Ops.CONST, src=(UPat(Ops.VIEW, src=(UPat(Ops.DEVICE),)),)), lambda: True),
|
||||
(UPat(Ops.VIEW, src=(UPat(Ops.DEVICE), UPat(Ops.BIND, src=(UPat(Ops.DEFINE_VAR), UPat(Ops.CONST))))), lambda: True),
|
||||
|
||||
Reference in New Issue
Block a user