diff --git a/test/unit/test_uop_vmin_vmax.py b/test/unit/test_uop_vmin_vmax.py index b67a5ae6ca..044a8fa13b 100644 --- a/test/unit/test_uop_vmin_vmax.py +++ b/test/unit/test_uop_vmin_vmax.py @@ -60,7 +60,7 @@ class TestVminVmaxProperties(unittest.TestCase): def test_vmin_vmax_variable_inside_special(self): uop = UOp(Ops.SPECIAL, dtypes.int, arg=('gidx0', UOp(Ops.DEFINE_VAR, dtypes.int, arg=('i', 1, 10)))) self.assertEqual(uop.vmin, 0) - self.assertEqual(uop.vmax, 10) + self.assertEqual(uop.vmax, 9) def test_vmin_vmax_multiplication_0_inf(self): # vmin and vmax for multiplication with a variable diff --git a/tinygrad/uop/ops.py b/tinygrad/uop/ops.py index f3d57a79c9..ac5f56c4f4 100644 --- a/tinygrad/uop/ops.py +++ b/tinygrad/uop/ops.py @@ -555,7 +555,7 @@ class UOp(MathTrait, metaclass=UOpMetaClass): if self.op is Ops.BIND: return self.src[0]._min_max # ignore the bound value if self.op in {Ops.UNROLL, Ops.VECTORIZE}: return min(x.vmin for x in self.src), max(x.vmax for x in self.src) # TODO: Ops.SPECIAL is Ops.DEFINE_VAR - if self.op is Ops.SPECIAL: return 0, self.arg[1]-1 if isinstance(self.arg[1], int) else self.arg[1].vmax + if self.op is Ops.SPECIAL: return 0, self.arg[1]-1 if isinstance(self.arg[1], int) else self.arg[1].vmax-1 if self.op is Ops.CONST: return self.arg, self.arg if self.op is Ops.VCONST: return (min(self.arg), max(self.arg)) # TODO: CAST to bool/unsigned is not monotone, still some case can be simplified