From 937aeaec6009b3ecfb56f7110e71d431742a3541 Mon Sep 17 00:00:00 2001 From: chenyu Date: Sun, 7 Jun 2026 16:38:43 -0400 Subject: [PATCH] remove device= from UPat.const [PR] (#16530) --- tinygrad/mixin/__init__.py | 4 ++-- tinygrad/tensor.py | 3 +-- tinygrad/uop/ops.py | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/tinygrad/mixin/__init__.py b/tinygrad/mixin/__init__.py index a128cad376..af1cdbfbe8 100644 --- a/tinygrad/mixin/__init__.py +++ b/tinygrad/mixin/__init__.py @@ -17,9 +17,9 @@ ReductionStr = Literal["mean", "sum", "none"] class OpMixin(ElementwiseMixin, ReduceMixin): @staticmethod - def unique_const(fill_value:ConstType, **kwargs): raise NotImplementedError("creation helpers are only supported on Tensor and UOp") + def unique_const(fill_value:ConstType, **kwargs): raise NotImplementedError @staticmethod - def const(dtype, b): raise NotImplementedError("creation helpers are only supported on Tensor and UOp") + def const(dtype, b): raise NotImplementedError @property def _uop(self) -> UOp: raise NotImplementedError def _wrap_uop(self, u:UOp) -> Self: raise NotImplementedError diff --git a/tinygrad/tensor.py b/tinygrad/tensor.py index 026371735b..82d22b0d73 100644 --- a/tinygrad/tensor.py +++ b/tinygrad/tensor.py @@ -161,8 +161,7 @@ class Tensor(OpMixin): def _wrap_uop(self, u:UOp) -> Tensor: return Tensor(u) def const_like(self, b:ConstType) -> Tensor: return Tensor(self.uop.const_like(b)) @staticmethod - def const(dtype:DType, b:ConstType|UOp) -> Tensor: - return Tensor(UOp.const(dtype, b)) + def const(dtype:DType, b:ConstType|UOp) -> Tensor: return Tensor(UOp.const(dtype, b)) @staticmethod def unique_const(fill_value:ConstType|UOp, **kwargs) -> Tensor: if isinstance(fill_value, UOp): return Tensor(fill_value, **kwargs) diff --git a/tinygrad/uop/ops.py b/tinygrad/uop/ops.py index a23a5500f4..594b09d112 100644 --- a/tinygrad/uop/ops.py +++ b/tinygrad/uop/ops.py @@ -1253,7 +1253,7 @@ class UPat(OpMixin): @functools.cache def cvar(name:str|None=None, dtype:DType|tuple[DType, ...]|None=None, arg=None): return UPat(Ops.CONST, dtype, name=name, arg=arg) @staticmethod - def const(dtype:DType|tuple[DType, ...]|None, b:ConstType, device=None): return UPat(Ops.CONST, dtype=dtype, arg=b) + def const(dtype:DType|tuple[DType, ...]|None, b:ConstType): return UPat(Ops.CONST, dtype=dtype, arg=b) # lil helper def f(self, op, **kwargs): return UPat(op, src=(self,), **kwargs)