diff --git a/test/test_uops.py b/test/test_uops.py index b191fac730..a08ca29f41 100644 --- a/test/test_uops.py +++ b/test/test_uops.py @@ -388,11 +388,6 @@ class TestUOpStr(unittest.TestCase): sink = UOp(UOps.SINK, dtypes.void, (get_kernel(Device[Device.DEFAULT].renderer, t.schedule()[-1].ast).linearize().uops[-1],)) assert_equiv_uops(sink, eval(str(sink))) - def test_variable_const(self): - # TODO: this is not possible after VALID. - uop = UOp(UOps.CONST, dtypes.int, (), arg=Variable("a",1,10)) - assert str(eval(str(uop))) == str(uop) - def test_vectorized_str(self): vec = UOp(UOps.VECTORIZE, dtypes.int.vec(4), tuple(UOp.const(dtypes.int, x) for x in range(4))) assert str(eval(str(vec))) == str(vec) diff --git a/tinygrad/ops.py b/tinygrad/ops.py index 08075e4448..b0f51cab1b 100644 --- a/tinygrad/ops.py +++ b/tinygrad/ops.py @@ -169,8 +169,7 @@ class UOp(MathTrait): def key(self) -> bytes: return hashlib.sha256(str((self.op, self.dtype, self.arg)).encode() + b"".join([s.key for s in self.src])).digest() def __repr__(self): return pretty_print(self, lambda x: f"{type(self).__name__}({x.op}, {x.dtype}, arg={x.argstr()}, src=(%s))") - def argstr(self): - return f'({", ".join(map(str, self.arg))})' if self.op is UOps.REDUCE_AXIS else repr(self.arg) if isinstance(self.arg, Variable) else self.arg + def argstr(self): return f'({", ".join(map(str, self.arg))})' if self.op is UOps.REDUCE_AXIS else self.arg # *** uop syntactic sugar @property def st_arg(self) -> ShapeTracker: @@ -412,7 +411,7 @@ class UPat(MathTrait): return UPat((UOps.CONST, UOps.VCONST) if vec else UOps.CONST, dtype=dtype, name=name) @staticmethod @functools.lru_cache(None) - def const(dtype:Optional[DType], b:ConstType|Variable): return UPat(UOps.CONST, dtype=dtype, arg=b) + def const(dtype:Optional[DType], b:ConstType): return UPat(UOps.CONST, dtype=dtype, arg=b) # copied from UOp def cast(self, dtype=None): return UPat(UOps.CAST, dtype, (self,))