Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] Fix other div zero errors also in rewrite_simplify #8983

Merged
merged 9 commits into from
Sep 16, 2021
Prev Previous commit
Next Next commit
rewrite the test case of divison by zero to fix ci error
  • Loading branch information
syang-ng committed Sep 10, 2021
commit 158eb5d37f495f9b2b9eba271de9028afc1e5bf3
10 changes: 6 additions & 4 deletions tests/python/unittest/test_arith_rewrite_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,21 +934,23 @@ def test_shift_left_simplify():

def test_div_zero_simplify():
ck = RewriteChecker()
ramp = tvm.tir.Ramp(1, 1, 2)
broadcast = tvm.tir.Broadcast(0, 2)

with pytest.raises(tvm.error.TVMError) as cm:
ck.analyzer.rewrite_simplify(tvm.tir.Div(tvm.tir.Ramp(1, 1, 2), tvm.tir.Broadcast(0, 2)))
ck.analyzer.rewrite_simplify(tvm.tir.Div(ramp, broadcast))
assert "division by zero" in str(cm.execption)

with pytest.raises(tvm.error.TVMError) as cm:
ck.analyzer.rewrite_simplify(tvm.tir.Mod(tvm.tir.Ramp(1, 1, 2), tvm.tir.Broadcast(0, 2)))
ck.analyzer.rewrite_simplify(tvm.tir.Mod(ramp, broadcast))
assert "division by zero" in str(cm.execption)

with pytest.raises(tvm.error.TVMError) as cm:
ck.analyzer.rewrite_simplify(tvm.tir.FloorDiv(tvm.tir.Ramp(1, 1, 2), tvm.tir.Broadcast(0, 2)))
ck.analyzer.rewrite_simplify(tvm.tir.FloorDiv(ramp, broadcast))
assert "division by zero" in str(cm.execption)

with pytest.raises(tvm.error.TVMError) as cm:
ck.analyzer.rewrite_simplify(tvm.tir.FloorMod(tvm.tir.Ramp(1, 1, 2), tvm.tir.Broadcast(0, 2)))
ck.analyzer.rewrite_simplify(tvm.tir.FloorMod(ramp, broadcast))
assert "division by zero" in str(cm.execption)


Expand Down