From 87289a7410c3fda294e16fa4ff2bf28c0de1207c Mon Sep 17 00:00:00 2001 From: George Hotz Date: Mon, 3 Aug 2026 15:25:51 -0700 Subject: [PATCH] hotfix: revert test_scalar_alu_index, violates spec --- test/backend/test_wait_loop.py | 14 -------------- tinygrad/codegen/__init__.py | 3 --- 2 files changed, 17 deletions(-) diff --git a/test/backend/test_wait_loop.py b/test/backend/test_wait_loop.py index 4ce681c631..83e0543e61 100644 --- a/test/backend/test_wait_loop.py +++ b/test/backend/test_wait_loop.py @@ -81,20 +81,6 @@ def loop_in_loop_kernel(C:UOp) -> UOp: return C[0].store(i[0].load()).sink(arg=KernelInfo(name="loop_in_loop", opts_to_apply=())) -def scalar_alu_index_kernel(out: UOp) -> UOp: - val = UOp.param(1, dtypes.int, (1,), vmin_vmax=(0, 100), addrspace=AddrSpace.ALU, name="val") - idx = UOp(Ops.INDEX, dtypes.int, (val, UOp.const(0, dtypes.int))) - return out[0].store(idx + 1).sink(arg=KernelInfo(name="scalar_alu_index")) - -class TestScalarALUIndex(unittest.TestCase): - def test_scalar_alu_index(self): - # regression: indexing a scalar (1,)-shaped ALU param must render the variable - # directly, not as data.x (which is a compile error on a scalar int) - out = Tensor.zeros(1, dtype=dtypes.int).contiguous().realize() - result = Tensor.custom_kernel(out, fxn=scalar_alu_index_kernel)[0] - run_linear(result.schedule_linear(), var_vals={"val": 42}) - self.assertEqual(result.item(), 43) - class TestWaitLoop(unittest.TestCase): def test_wait_loop(self): c = Tensor.empty(1, dtype=dtypes.int) diff --git a/tinygrad/codegen/__init__.py b/tinygrad/codegen/__init__.py index e0b8730c16..3f37a4c1dd 100644 --- a/tinygrad/codegen/__init__.py +++ b/tinygrad/codegen/__init__.py @@ -150,9 +150,6 @@ devectorizer2 = mop_cleanup+pm_mops+PatternMatcher([ (UPat(GroupOp.Elementwise|{Ops.LOAD,Ops.STORE}, name="b"), do_devectorize), # INDEX without src is nothing (TODO: this should be in mop_cleanup) (UPat(Ops.INDEX, src=(UPat.var('x'),)), lambda x: x), - # INDEX of a scalar ALU param is the param itself - (UPat(Ops.INDEX, src=(UPat(Ops.PARAM, name="v"),), allow_any_len=True), - lambda v: v if v.addrspace == AddrSpace.ALU and v.max_numel() == 1 else None), # unpack WMMA (UPat(Ops.WMMA, name="u"), do_stack_wmma), # stacked INDEX is many INDEX