From 381df7f45f907aa8d1126f90aa2c80bb566f9af9 Mon Sep 17 00:00:00 2001 From: ttomsa Date: Tue, 7 Oct 2025 21:05:44 +0100 Subject: [PATCH] cpu should work now --- test/test_linearizer.py | 2 +- test/test_uop_graph.py | 13 ------------- tinygrad/codegen/late/control_flow.py | 6 +++--- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/test/test_linearizer.py b/test/test_linearizer.py index 3198ff3877..166ce47a88 100644 --- a/test/test_linearizer.py +++ b/test/test_linearizer.py @@ -233,7 +233,7 @@ class TestLinearizer(unittest.TestCase): assert u.src[1].op in GroupOp.ALU assert begin_range < uops.index(u) < end_range # children of STORE are placed after ENDRANGE - if any(x.op is Ops.STORE and x.src[1].op in GroupOp.ALU for x in u.src): + if any(x.op is Ops.STORE and x.src[1].op in GroupOp.ALU for x in u.src) and u.op is not Ops.ENDRANGE: assert end_range < uops.index(u) def test_grouped_dims(self): diff --git a/test/test_uop_graph.py b/test/test_uop_graph.py index 9f6d5c5ccb..f298d0d11e 100644 --- a/test/test_uop_graph.py +++ b/test/test_uop_graph.py @@ -651,19 +651,6 @@ class TestUOpGraph(unittest.TestCase): bad_gate = UOp.const(dtypes.int, 1) with self.assertRaises(AssertionError): to_uops_list([UOp(Ops.STORE, dtypes.void, (glbl0, idx, UOp.const(dtypes.int, 42), bad_gate))]) - def test_switched_range_order(self): - glbl = UOp(Ops.DEFINE_GLOBAL, dtypes.int.ptr(), (), 0) - cf = UOp.const(dtypes.float, 0.0) - r1 = UOp.range(2, 0) - r2 = UOp.range(2, 1) - alu = UOp(Ops.MUL, dtypes.int, (r2, r1)) - store = UOp(Ops.STORE, dtypes.void, (glbl.index(alu), cf)) - uops = to_uops_list([store]) - ranges = [x for x in uops if x.op is Ops.RANGE] - endranges = [x for x in uops if x.op is Ops.ENDRANGE] - # ranges are closed in the right order - self.assertEqual(endranges[-1].src[0], ranges[0]) - @track_rewrites() def expander_rewrite(sink): return graph_rewrite(sink, sym + expander) diff --git a/tinygrad/codegen/late/control_flow.py b/tinygrad/codegen/late/control_flow.py index 01eb18548b..02a930e459 100644 --- a/tinygrad/codegen/late/control_flow.py +++ b/tinygrad/codegen/late/control_flow.py @@ -66,9 +66,9 @@ pm_control_flow_ends = PatternMatcher([ class CFGContext: def __init__(self, sink:UOp): # there are 3 relationships between ranges: - # nested, meaning range y is a dependency of endrange x and range x is a dependency of endrange y - # dependent, meaning range y is a dependency of endrange x and range x is not a dependency of endrange y (i.e. load in range x depends on store in range y) - # independent, range y is not a dependency if endrange x + # nested, meaning endrange y is a dependency of endrange x and range x is a dependency of endrange y + # dependent, meaning endrange y is a dependency of endrange x and range x is not a dependency of endrange y (i.e. load in range x depends on store in range y) + # independent, endrange y is not a dependency of endrange x # ifs are always independent deps: dict[UOp, set[UOp]] = {} nesting: dict[UOp, UOp] = {}