From 25af78c593323e69cc6d199faf2c2c904b5bcd79 Mon Sep 17 00:00:00 2001 From: chenyu Date: Sun, 8 Sep 2024 23:08:58 -0400 Subject: [PATCH] failed uop_symbolic divmod test by variable (#6414) --- test/unit/test_symbolic.py | 8 ++++++++ test/unit/test_uop_symbolic.py | 13 ++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/test/unit/test_symbolic.py b/test/unit/test_symbolic.py index 00d3f53b..b3cab5aa 100644 --- a/test/unit/test_symbolic.py +++ b/test/unit/test_symbolic.py @@ -318,6 +318,14 @@ class TestSymbolic(unittest.TestCase): lidx3 = Variable("lidx3", 0, 1) self.helper_test_variable((gidx0+lidx2+lidx3)*4, 0, 80, "((gidx0*4)+(lidx2*4)+(lidx3*4))") + def test_variable_divmod(self): + start_pos = Variable("start_pos", 0, 127) + v = start_pos + 1 + idx0 = Variable("idx0", 0, 2) + idx1 = Variable("idx1", 0, start_pos) + self.helper_test_variable((idx0*v+idx1)//v, 0, 2, "(idx0)") + self.helper_test_variable((idx0*v+idx1)%v, 0, start_pos, "idx1") + class TestSymbolicNumeric(unittest.TestCase): def helper_test_numeric(self, f): # TODO: why are the negative tests broken? (even if we did support negative variables) diff --git a/test/unit/test_uop_symbolic.py b/test/unit/test_uop_symbolic.py index 7bf2e46c..bf0775d1 100644 --- a/test/unit/test_uop_symbolic.py +++ b/test/unit/test_uop_symbolic.py @@ -27,7 +27,9 @@ def render(self) -> Tuple[str, ConstType, ConstType]: def NumNode(val): return UOp.const(dtypes.int, val) def Variable(expr, nmin, nmax): - return UOp(UOps.DEFINE_VAR, dtypes.int, arg=(expr, UOp.const(dtypes.int, nmin), UOp.const(dtypes.int, nmax))) + vmin = UOp.const(dtypes.int, nmin) + vmax = UOp.const(dtypes.int, nmax) if isinstance(nmax, int) else nmax + return UOp(UOps.DEFINE_VAR, dtypes.int, arg=(expr, vmin, vmax)) class Node: @staticmethod def sum(ops): return functools.reduce(lambda x,y: x+y, ops) @@ -375,6 +377,15 @@ class TestSymbolic(unittest.TestCase): lidx3 = Variable("lidx3", 0, 1) self.helper_test_variable((gidx0+lidx2+lidx3)*4, 0, 80, "((gidx0*4)+(lidx2*4)+(lidx3*4))") + @unittest.expectedFailure + def test_variable_divmod(self): + start_pos = Variable("start_pos", 0, 127) + v = start_pos + 1 + idx0 = Variable("idx0", 0, 2) + idx1 = Variable("idx1", 0, start_pos) + self.helper_test_variable((idx0*v+idx1)//v, 0, 2, "(idx0)") + self.helper_test_variable((idx0*v+idx1)%v, 0, start_pos, "idx1") + # *** below are uop_symbolic only # NOTE: tests are not correct in symbolic