delete test_variable_const [run_process_replay] (#6757)

* delete test_variable_const [run_process_replay]

* don't allow variable UPat
This commit is contained in:
qazal 2024-09-26 12:27:11 +08:00 committed by GitHub
commit ee4feedb77
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 8 deletions

View file

@ -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)

View file

@ -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,))