You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:02:37 UTC

[GitHub] [incubator-tvm] xqdan opened a new pull request #5749: [Simplify]fix a min/max simplify bug

xqdan opened a new pull request #5749:
URL: https://github.com/apache/incubator-tvm/pull/5749


   Thanks for contributing to TVM!   Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from [Reviewers](https://github.com/apache/incubator-tvm/blob/master/CONTRIBUTORS.md#reviewers) by @ them in the pull request thread.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tqchen commented on a change in pull request #5749: [Simplify]fix a min/max simplify bug

Posted by GitBox <gi...@apache.org>.
tqchen commented on a change in pull request #5749:
URL: https://github.com/apache/incubator-tvm/pull/5749#discussion_r437108677



##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -1026,7 +1026,9 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const MinNode* op) {
       int64_t c1val = c1.Eval()->value;
       int64_t c2val = c2.Eval()->value;
       if (c2val % c1val == 0) {
-        if (c2val / c1val >= 0) {
+        if (c2val == 0) {
+          return c1val > 0 ? (min(x, 0) * c1val).Eval() : (max(x, 0) * c1val).Eval();
+        } else if (c2val / c1val > 0) {

Review comment:
       Thanks @xqdan this rule seems also should applies to other cases when c1val is smaller than 0, 
   
   e.g. (  `min(x * (-2),  -4)`), please also fix that case

##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -1026,7 +1026,9 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const MinNode* op) {
       int64_t c1val = c1.Eval()->value;
       int64_t c2val = c2.Eval()->value;
       if (c2val % c1val == 0) {
-        if (c2val / c1val >= 0) {
+        if (c2val == 0) {
+          return c1val > 0 ? (min(x, 0) * c1val).Eval() : (max(x, 0) * c1val).Eval();
+        } else if (c2val / c1val > 0) {

Review comment:
       We should also fix the case for max

##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -1026,7 +1026,9 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const MinNode* op) {
       int64_t c1val = c1.Eval()->value;
       int64_t c2val = c2.Eval()->value;
       if (c2val % c1val == 0) {
-        if (c2val / c1val >= 0) {
+        if (c2val == 0) {
+          return c1val > 0 ? (min(x, 0) * c1val).Eval() : (max(x, 0) * c1val).Eval();
+        } else if (c2val / c1val > 0) {

Review comment:
       We can change original line from `c2val / c1val >= 0` to `c1val > 0`.
   
   

##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -1026,7 +1026,9 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const MinNode* op) {
       int64_t c1val = c1.Eval()->value;
       int64_t c2val = c2.Eval()->value;
       if (c2val % c1val == 0) {
-        if (c2val / c1val >= 0) {
+        if (c2val == 0) {
+          return c1val > 0 ? (min(x, 0) * c1val).Eval() : (max(x, 0) * c1val).Eval();
+        } else if (c2val / c1val > 0) {

Review comment:
       Let us also fix the (rare) special case, `(c1val == 0)`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] xqdan commented on a change in pull request #5749: [ARITH][BACKPORT-0.6] fix a min/max simplify bug

Posted by GitBox <gi...@apache.org>.
xqdan commented on a change in pull request #5749:
URL: https://github.com/apache/incubator-tvm/pull/5749#discussion_r437126069



##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -1026,7 +1026,9 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const MinNode* op) {
       int64_t c1val = c1.Eval()->value;
       int64_t c2val = c2.Eval()->value;
       if (c2val % c1val == 0) {
-        if (c2val / c1val >= 0) {
+        if (c2val == 0) {
+          return c1val > 0 ? (min(x, 0) * c1val).Eval() : (max(x, 0) * c1val).Eval();
+        } else if (c2val / c1val > 0) {

Review comment:
       ok, fixed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tqchen merged pull request #5749: [ARITH][BACKPORT-0.6] fix a min/max simplify bug

Posted by GitBox <gi...@apache.org>.
tqchen merged pull request #5749:
URL: https://github.com/apache/incubator-tvm/pull/5749


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] tqchen commented on pull request #5749: [Simplify]fix a min/max simplify bug

Posted by GitBox <gi...@apache.org>.
tqchen commented on pull request #5749:
URL: https://github.com/apache/incubator-tvm/pull/5749#issuecomment-640982634






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-tvm] xqdan commented on pull request #5749: [Simplify]fix a min/max simplify bug

Posted by GitBox <gi...@apache.org>.
xqdan commented on pull request #5749:
URL: https://github.com/apache/incubator-tvm/pull/5749#issuecomment-640974004


   @tqchen @yzhliu please review


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org