This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch v0.6
in repository https://gitbox.apache.org/repos/asf/incubator-tvm.git
The following commit(s) were added to refs/heads/v0.6 by this push:
new 802f055 [BACKPORT-0.6][Bugfix][Arith] keep div_mode during floordiv
simplify (#5927)
802f055 is described below
commit 802f0555553312d71e66489f92fcec9ea00b31df
Author: Yizhi Liu <[email protected]>
AuthorDate: Thu Jun 25 11:33:18 2020 -0700
[BACKPORT-0.6][Bugfix][Arith] keep div_mode during floordiv simplify (#5927)
---
src/arithmetic/canonical_simplify.cc | 1 +
tests/python/unittest/test_arith_canonical_simplify.py | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/arithmetic/canonical_simplify.cc
b/src/arithmetic/canonical_simplify.cc
index 2a05834..52104f3 100644
--- a/src/arithmetic/canonical_simplify.cc
+++ b/src/arithmetic/canonical_simplify.cc
@@ -715,6 +715,7 @@ SplitDivConst(SplitExpr lhs, int64_t cval, DivMode
div_mode) {
CHECK(lhs->DivModeCompatibleTo(div_mode));
CHECK_EQ(lhs->scale, 1);
lhs.CopyOnWrite()->lower_factor *= cval;
+ lhs.CopyOnWrite()->div_mode = div_mode;
return lhs;
}
diff --git a/tests/python/unittest/test_arith_canonical_simplify.py
b/tests/python/unittest/test_arith_canonical_simplify.py
index 08038ff..aa41d71 100644
--- a/tests/python/unittest/test_arith_canonical_simplify.py
+++ b/tests/python/unittest/test_arith_canonical_simplify.py
@@ -82,6 +82,7 @@ def test_split_index_simplify():
# floordiv
fld = tvm.floordiv
flm = tvm.floormod
+ ck.verify(fld(x*5, 2), fld(x*5, 2))
ck.verify(fld(x, 3) * 3 + flm(x, 3), x)
ck.verify(fld(x, 6) * 6 + flm(fld(x, 3), 2) * 3 + flm(x, 3), x)
ck.verify(fld(fld(flm(x, 16), 2) * 2, 4), fld(flm(x, 16), 4))