revert a mod pattern (#5864)

fixed UOP_IS_SYMBOLIC=1 linearizer failure 47
This commit is contained in:
chenyu
2024-08-01 17:24:26 -04:00
committed by GitHub
parent 34168a64e3
commit 5c8de2d044
3 changed files with 5 additions and 2 deletions

View File

@@ -225,7 +225,9 @@ jobs:
run: PYTHONPATH=. THREEFRY=1 GPU=1 python3 -m pytest test/test_randomness.py test/test_jit.py --durations=20
- if: ${{ matrix.task == 'onnx' }}
name: Test UOP_IS_SYMBOLIC
run: PYTHONPATH=. UOP_IS_SYMBOLIC=1 GPU=1 python3 -m pytest -n=auto test/test_ops.py -k "conv and not (test_padded_conv3d or test_conv2d_bs_4_cin_3 or test_conv2d or test_conv2d_bs_4_cin_1 or test_strided_conv_transpose2d)" --durations=20
run: |
PYTHONPATH=. UOP_IS_SYMBOLIC=1 GPU=1 python3 -m pytest -n=auto test/test_ops.py -k "conv and not (test_padded_conv3d or test_conv2d_bs_4_cin_3 or test_conv2d or test_conv2d_bs_4_cin_1 or test_strided_conv_transpose2d)" --durations=20
PYTHONPATH=. UOP_IS_SYMBOLIC=1 python -m pytest -rA test/test_linearizer_failures.py::TestLinearizerFailures::test_failure_47 --durations=20
- if: ${{ matrix.task == 'onnx' }}
name: Run handcode_opt
run: PYTHONPATH=. MODEL=resnet GPU=1 DEBUG=1 BS=4 HALF=0 python3 examples/handcode_opt.py

View File

@@ -261,6 +261,7 @@ class TestSymbolic(unittest.TestCase):
# TODO: simplify further
self.helper_test_variable((1+Variable("a", 0, 3))*(-2)+12, 4, 10, {"((a*-2)+10)", "(((a+1)*(-2))+12)"})
@unittest.expectedFailure
def test_mod_mul_sum(self):
self.helper_test_variable(Node.sum([Variable("b", 0, 2), Variable("a", 0, 5)*10])%9, 0, 7, "(a+b)")

View File

@@ -245,7 +245,7 @@ constant_folder = PatternMatcher([
x*(c0.arg%c1.arg)%c1 if 0 < c1.arg <= c0.arg else (x%(c1.arg//c0.arg))*c0 if c1.arg%c0.arg == 0 else None),
# mul add mod
(((NOp.cvar('c0')*NOp.var('x'))+NOp.var('x2')) % NOp.cvar('c1'),
lambda x,x2,c0,c1: x2%c1 if (r:=c0.arg%c1.arg) == 0 else (x*r+x2)%c1 if 0 < c1.arg <= c0.arg else None),
lambda x,x2,c0,c1: x2%c1 if c0.arg%c1.arg == 0 else None),
# mod mod
((NOp.var('x') % NOp.cvar('c0')) % NOp.cvar('c1'), lambda x,c0,c1: x % c1 if c0.arg % c1.arg == 0 else None),
# -(x+y) -> -x + -y