From 033fb53f9e3e13c5ef57d8eee30823b0cd06ffb5 Mon Sep 17 00:00:00 2001 From: uuuvn <83587632+uuuvn@users.noreply.github.com> Date: Sat, 15 Jun 2024 15:18:35 +0300 Subject: [PATCH] Incomplete/buggy rule breaks process replay on #4976 (#4978) * Incomplete/buggy rule breaks process replay on #4976 * test passes --------- Co-authored-by: qazal --- test/test_uops.py | 2 +- tinygrad/codegen/uops.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_uops.py b/test/test_uops.py index dac9df01dd..332710d11a 100644 --- a/test/test_uops.py +++ b/test/test_uops.py @@ -151,7 +151,7 @@ class TestNonFloatUOps(TestUOps): value = -y+x uops = UOpGraph([UOp(UOps.STORE, None, (data0, idx, value))]) - with self.assertRaises(AssertionError): assert uops[-1].vin[2].arg is BinaryOps.SUB + assert uops[-1].vin[2].arg is BinaryOps.SUB class TestBoolUOps(TestUOps): def _test_uop_bool_fxn(self, op, fxn): diff --git a/tinygrad/codegen/uops.py b/tinygrad/codegen/uops.py index 430e1a7e70..b0f7eda1f1 100644 --- a/tinygrad/codegen/uops.py +++ b/tinygrad/codegen/uops.py @@ -181,7 +181,7 @@ constant_folder = PatternMatcher([ # -(-x) -> x (UPat(UOps.ALU, UnaryOps.NEG, (UPat(UOps.ALU, UnaryOps.NEG, (UPat(name="x"),)))), lambda x: x), # x+-y -> x-y - (UPat(UOps.ALU, BinaryOps.ADD, (UPat(name="x"), UPat(UOps.ALU, UnaryOps.NEG, name="my"))), lambda x, my: x-my.vin[0]), + (UPat(UOps.ALU, BinaryOps.ADD, [UPat(name="x"), UPat(UOps.ALU, UnaryOps.NEG, name="my")]), lambda x, my: x-my.vin[0]), # -1*x -> -x (UPat(UOps.ALU, BinaryOps.MUL, [UPat(name="x"), UPat(UOps.CONST, -1)]), lambda x: -x), # bool < False is always false, True < bool is always false