You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by sy...@apache.org on 2022/07/22 03:47:06 UTC
[tvm] branch main updated: [arith][BugFix] Fix simplify input PrimExpr of DetectClipBound (#12150)
This is an automated email from the ASF dual-hosted git repository.
syfeng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 8c42a83361 [arith][BugFix] Fix simplify input PrimExpr of DetectClipBound (#12150)
8c42a83361 is described below
commit 8c42a833610dad9993c64eea1664b9a9470f5c07
Author: yin.changsheng <yi...@intellif.com>
AuthorDate: Fri Jul 22 11:46:58 2022 +0800
[arith][BugFix] Fix simplify input PrimExpr of DetectClipBound (#12150)
---
src/arith/detect_linear_equation.cc | 4 ++--
tests/python/unittest/test_arith_detect_clip_bound.py | 6 ++++++
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/arith/detect_linear_equation.cc b/src/arith/detect_linear_equation.cc
index d81159bf05..8ea8f168b6 100644
--- a/src/arith/detect_linear_equation.cc
+++ b/src/arith/detect_linear_equation.cc
@@ -245,7 +245,8 @@ void SplitCommExpr(const PrimExpr& e, std::vector<PrimExpr>* ret) {
// e must be connected by and.
Array<PrimExpr> DetectClipBound(const PrimExpr& e, const Array<Var>& vars) {
std::vector<PrimExpr> splits;
- SplitCommExpr<tir::AndNode>(e, &splits);
+ Analyzer analyzer;
+ SplitCommExpr<tir::AndNode>(analyzer.Simplify(e), &splits);
std::unordered_map<const VarNode*, IntervalEntry> rmap;
for (Var v : vars) {
rmap[v.get()] = IntervalEntry();
@@ -253,7 +254,6 @@ Array<PrimExpr> DetectClipBound(const PrimExpr& e, const Array<Var>& vars) {
for (PrimExpr cond : splits) {
if (!DetectClipBound(cond, &rmap)) return Array<PrimExpr>();
}
- Analyzer analyzer;
Array<PrimExpr> ret;
for (Var v : vars) {
IntervalEntry e = rmap[v.get()];
diff --git a/tests/python/unittest/test_arith_detect_clip_bound.py b/tests/python/unittest/test_arith_detect_clip_bound.py
index e12afa8ef7..0a9d75fcea 100644
--- a/tests/python/unittest/test_arith_detect_clip_bound.py
+++ b/tests/python/unittest/test_arith_detect_clip_bound.py
@@ -31,6 +31,12 @@ def test_basic():
m = tvm.arith.detect_clip_bound(tvm.tir.all(a + 10 * c <= 20, b - 1 > 0), [a, b])
tvm.testing.assert_prim_expr_equal(m[1], 20 - 10 * c)
tvm.testing.assert_prim_expr_equal(m[2], 2)
+ m = tvm.arith.detect_clip_bound(tvm.tir.all(tvm.tir.Not(a * 1 > b * 6), a - 1 > 0), [a])
+ tvm.testing.assert_prim_expr_equal(m[1], b * 6)
+ m = tvm.arith.detect_clip_bound(tvm.tir.all(tvm.tir.Min(a, b) > 3, a - 10 < 0), [a, b])
+ tvm.testing.assert_prim_expr_equal(m[0], 4)
+ tvm.testing.assert_prim_expr_equal(m[1], 9)
+ tvm.testing.assert_prim_expr_equal(m[2], 4)
if __name__ == "__main__":