mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-04-29 03:00:14 -04:00
Fix scope order in graph toposort [run_process_replay] (#5330)
* fix * test * nothing
This commit is contained in:
@@ -221,5 +221,20 @@ class TestUOpGraph(TestUOps):
|
||||
uops = UOpGraph([UOp(UOps.STORE, None, (glbl0, idx, UOp.const(dtypes.int, 42), bad_gate))])
|
||||
with self.assertRaises(AssertionError): uops.linearize()
|
||||
|
||||
def test_switched_range_order(self):
|
||||
glbl = UOp(UOps.DEFINE_GLOBAL, PtrDType(dtypes.int), (), (0, True))
|
||||
c0 = UOp.const(dtypes.int, 0)
|
||||
c2 = UOp.const(dtypes.int, 2)
|
||||
cf = UOp.const(dtypes.float, 0.0)
|
||||
r1 = UOp(UOps.RANGE, dtypes.int, (c0, c2), (1, 0, False))
|
||||
r2 = UOp(UOps.RANGE, dtypes.int, (c0, c2), (1, 1, False))
|
||||
alu = UOp(UOps.ALU, dtypes.int, (r2, r1), BinaryOps.MUL)
|
||||
store = UOp(UOps.STORE, None, (glbl, alu, cf))
|
||||
uops = UOpGraph([store]).uops
|
||||
ranges = [x for x in uops if x.op is UOps.RANGE]
|
||||
endranges = [x for x in uops if x.op is UOps.ENDRANGE]
|
||||
# ranges are closed in the right order
|
||||
self.assertEqual(endranges[-1].src[0], ranges[0])
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main(verbosity=2)
|
||||
|
||||
Reference in New Issue
Block a user