add vmin vmax of SPECIAL (#5670)

* add vmin vmax of SPECIAL

folded stuff like (-1 < gidx0)

* flaky
This commit is contained in:
chenyu
2024-07-23 22:55:54 -04:00
committed by GitHub
parent 5de43e7073
commit 3060e0be4f
2 changed files with 4 additions and 1 deletions

File diff suppressed because one or more lines are too long

View File

@@ -100,12 +100,15 @@ class UOp:
return False # generic false if we aren't sure
@functools.cached_property
def vmax(self) -> UOp:
# TODO: UOps.SPECIAL is UOps.DEFINE_VAR
if self.op is UOps.DEFINE_VAR: return self.src[1]
if self.op is UOps.SPECIAL and isinstance(self.arg[1], int): return self.const(self.arg[1])
if self.op is UOps.CONST: return self
return self.const(dtypes.max(cast(DType, self.dtype)))
@functools.cached_property
def vmin(self) -> UOp:
if self.op is UOps.DEFINE_VAR: return self.src[0]
if self.op is UOps.SPECIAL: return self.const(0)
if self.op is UOps.CONST: return self
return self.const(dtypes.min(cast(DType, self.dtype)))