From 63b42e05a0d9d24019009eb7eebbcde15f9e7064 Mon Sep 17 00:00:00 2001 From: ANSHUMAN TRIPATHY Date: Tue, 17 Mar 2020 22:33:18 +0530 Subject: [PATCH 1/5] [TE][Schedule] Duplicate likely nodes removed --- src/te/schedule/message_passing.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/te/schedule/message_passing.cc b/src/te/schedule/message_passing.cc index a7b248285c4d..695ed0128a61 100644 --- a/src/te/schedule/message_passing.cc +++ b/src/te/schedule/message_passing.cc @@ -556,6 +556,15 @@ void PassUpBoundCheck(const Stage& s, } } +bool IsRangeSame(const Range input_1, const Range input_2) { + arith::Analyzer analyzer; + if(input_1.same_as(input_2)) return true; + if ( !analyzer.CanProve(input_1->min == input_2->min) || !analyzer.CanProve(input_1->extent == input_2->extent)) { + return false; + } + return true; +} + std::vector MakeBoundCheck( const Stage& stage, const Map& dom_map, @@ -593,7 +602,7 @@ std::vector MakeBoundCheck( if (skip_iter.count(iv) || iv->iter_type == kOpaque) continue; Range dom = dom_map.at(iv); CHECK(iv->dom.defined()); - if (!skip_ivar_domain && !iv->dom.same_as(dom)) { + if (!skip_ivar_domain && !IsRangeSame(iv->dom, dom)) { PrimExpr value = value_map.at(iv) - iv->dom->min; IntSet s = EvalSet(value, iset_dmap); PrimExpr vmin = s.min(); From 499fa90041fff459739e824a0a2c3b4fed4c2c6d Mon Sep 17 00:00:00 2001 From: ANSHUMAN TRIPATHY Date: Tue, 17 Mar 2020 22:34:21 +0530 Subject: [PATCH 2/5] [1] Test case added --- tests/python/unittest/test_te_build_lower.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/python/unittest/test_te_build_lower.py b/tests/python/unittest/test_te_build_lower.py index 736030bd548d..3ad1747d3ecc 100644 --- a/tests/python/unittest/test_te_build_lower.py +++ b/tests/python/unittest/test_te_build_lower.py @@ -40,6 +40,19 @@ def test_dependent_output_shape(): s = te.create_schedule(B.op) mod = tvm.build(s, [A, B, x]) +def test_split_uneven_unique_likely(): + a = te.placeholder((16, 16),) + b = te.placeholder((16, 16),) + c = te.compute((16, 16), lambda x, y: a[x, y] + b[x, y]) + + x, y = c.op.axis + sch = te.create_schedule(c.op) + xo, xi = sch[c].split(x, 5) + stmt = tvm.lower(sch, [a, b, c], simple_mode=True) + assert isinstance(stmt.body.body.body.body, tvm.tir.stmt.IfThenElse) + assert str(stmt.body.body.body.body).count("likely") == 1 + if __name__ == "__main__": test_lower_rfactor() test_dependent_output_shape() + test_split_uneven_unique_likely() From 41243c1147b91c05740b470770e1c29f3905fd6f Mon Sep 17 00:00:00 2001 From: ANSHUMAN TRIPATHY Date: Wed, 18 Mar 2020 00:31:55 +0530 Subject: [PATCH 3/5] [2] Lint error fixed --- src/te/schedule/message_passing.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/te/schedule/message_passing.cc b/src/te/schedule/message_passing.cc index 695ed0128a61..d2d8f0be7f20 100644 --- a/src/te/schedule/message_passing.cc +++ b/src/te/schedule/message_passing.cc @@ -558,8 +558,9 @@ void PassUpBoundCheck(const Stage& s, bool IsRangeSame(const Range input_1, const Range input_2) { arith::Analyzer analyzer; - if(input_1.same_as(input_2)) return true; - if ( !analyzer.CanProve(input_1->min == input_2->min) || !analyzer.CanProve(input_1->extent == input_2->extent)) { + if (input_1.same_as(input_2)) return true; + if ( !analyzer.CanProve(input_1->min == input_2->min) + || !analyzer.CanProve(input_1->extent == input_2->extent)) { return false; } return true; From 5f7b50a919e3f7d684ff89fc303ba7719d4d1e18 Mon Sep 17 00:00:00 2001 From: ANSHUMAN TRIPATHY Date: Fri, 20 Mar 2020 23:25:00 +0530 Subject: [PATCH 4/5] [3] Review comments handled --- src/te/schedule/message_passing.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/te/schedule/message_passing.cc b/src/te/schedule/message_passing.cc index d2d8f0be7f20..93c09a942df5 100644 --- a/src/te/schedule/message_passing.cc +++ b/src/te/schedule/message_passing.cc @@ -559,7 +559,7 @@ void PassUpBoundCheck(const Stage& s, bool IsRangeSame(const Range input_1, const Range input_2) { arith::Analyzer analyzer; if (input_1.same_as(input_2)) return true; - if ( !analyzer.CanProve(input_1->min == input_2->min) + if (!analyzer.CanProve(input_1->min == input_2->min) || !analyzer.CanProve(input_1->extent == input_2->extent)) { return false; } From 20437f967aec7d0944d2c04f1bb39b30bbd78fe3 Mon Sep 17 00:00:00 2001 From: ANSHUMAN TRIPATHY Date: Sat, 21 Mar 2020 00:47:49 +0530 Subject: [PATCH 5/5] [4] Review comments handled --- src/te/schedule/message_passing.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/te/schedule/message_passing.cc b/src/te/schedule/message_passing.cc index 93c09a942df5..fc1327817020 100644 --- a/src/te/schedule/message_passing.cc +++ b/src/te/schedule/message_passing.cc @@ -559,11 +559,9 @@ void PassUpBoundCheck(const Stage& s, bool IsRangeSame(const Range input_1, const Range input_2) { arith::Analyzer analyzer; if (input_1.same_as(input_2)) return true; - if (!analyzer.CanProve(input_1->min == input_2->min) - || !analyzer.CanProve(input_1->extent == input_2->extent)) { - return false; - } - return true; + + return (analyzer.CanProve(input_1->min == input_2->min) + && analyzer.CanProve(input_1->extent == input_2->extent)); } std::vector MakeBoundCheck(