From 74cc6fd3c2fade760db28de3bcf9e59cc8a678dc Mon Sep 17 00:00:00 2001 From: chenyu Date: Wed, 3 Jan 2024 17:44:55 -0500 Subject: [PATCH] remove AndNode.__floordiv__ special case (#2996) * remove AndNode.__floordiv__ AndNode produces a Node that min/max is bounded by [0, 1] so `//` on top of that is almost always 0. we don't really use that either * keep the test --- test/unit/test_symbolic.py | 2 +- tinygrad/shape/symbolic.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/unit/test_symbolic.py b/test/unit/test_symbolic.py index ef28eb2615..506c632cba 100644 --- a/test/unit/test_symbolic.py +++ b/test/unit/test_symbolic.py @@ -44,7 +44,7 @@ class TestSymbolic(unittest.TestCase): self.helper_test_variable(expr, 0, 1, "((idx1<128) and (idx2<128))") expr = Node.ands([(Variable("idx1", 0, 511)*4 + Variable("FLOAT4_INDEX", 0, 3)) < 512, (Variable("idx2", 0, 511)*4 + Variable("FLOAT8_INDEX", 0, 7)) < 512]) - self.helper_test_variable(expr//4, 0, 1, "((((FLOAT8_INDEX//4)+idx2)<128) and ((idx1//4)<32))") + self.helper_test_variable(expr//4, 0, 0, "0") def test_lt_factors(self): expr = Node.ands([(Variable("idx1", 0, 511)*4 + Variable("FLOAT4_INDEX", 0, 256)) < 512]) diff --git a/tinygrad/shape/symbolic.py b/tinygrad/shape/symbolic.py index e981672e92..9eba406dc7 100644 --- a/tinygrad/shape/symbolic.py +++ b/tinygrad/shape/symbolic.py @@ -291,7 +291,6 @@ class SumNode(RedNode): def flat_components(self): return [y for x in self.nodes for y in (x.flat_components if isinstance(x, SumNode) else [x])] class AndNode(RedNode): - def __floordiv__(self, b: Union[Node, int], _=True): return Node.ands([x//b for x in self.nodes]) def substitute(self, var_vals: Dict[Variable, Node]) -> Node: subed = [] for node in self.nodes: