| 90 | if dtypes.is_int(self): return 2**(self.scalar().bitsize)-1+self.min |
| 91 | return float("inf") if dtypes.is_float(self) else True |
| 92 | def const(self, val: tuple[ConstType, ...]|ConstType): |
| 93 | if isinstance(val, tuple): |
| 94 | assert len(val) == self.count, f"mismatch {val} {self}" |
| 95 | return tuple(map(self.const, val)) |
| 96 | if isinstance(val, InvalidType): return val |
| 97 | # NOTE: float('nan') != float('nan'), so we canonicalize here |
| 98 | if isinstance(val, float) and math.isnan(val): val = math.nan |
| 99 | # int is the default. wrap floats in ConstFloat to distinguish -0.0 from 0.0 in cache |
| 100 | return ConstFloat(float(val)) if dtypes.is_float(self) else bool(val) if dtypes.is_bool(self) else int(val) |
| 101 | |
| 102 | @dataclass(frozen=True, eq=False) |
| 103 | class PtrDType(DType): |