tqchen commented on a change in pull request #5883:
URL: https://github.com/apache/incubator-tvm/pull/5883#discussion_r443635193



##########
File path: src/ir/expr.cc
##########
@@ -38,6 +38,8 @@ PrimExpr::PrimExpr(int32_t value) : 
PrimExpr(IntImm(DataType::Int(32), value)) {
 
 PrimExpr::PrimExpr(float value) : PrimExpr(FloatImm(DataType::Float(32), 
value)) {}
 
+PrimExpr::PrimExpr(double value) : PrimExpr(FloatImm(DataType::Float(64), 
value)) {}

Review comment:
       This is dangerous and can cause problems in the codebase, since implicit 
efault conversion to double may not be intended from the user side, we would 
rather be explicit. Let us remove this constructor and work around it(by 
explicitly construct via make_const)

##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -864,6 +902,31 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const 
FloorModNode* op) {
     TVM_TRY_REWRITE_IF(floormod(x + y * c1, c2), floormod(x, c2),
                        c2.Eval()->value > 0 && c1.Eval()->value % 
c2.Eval()->value == 0);
 
+    TVM_TRY_REWRITE_IF(floormod(x * c1 + y, c2), floormod(x, floordiv(c2, c1)) 
* c1 + y,

Review comment:
       move this part of change to a separate PR, add testcases to cover the 
change

##########
File path: src/arith/rewrite_simplify.cc
##########
@@ -864,6 +902,31 @@ PrimExpr RewriteSimplifier::Impl::VisitExpr_(const 
FloorModNode* op) {
     TVM_TRY_REWRITE_IF(floormod(x + y * c1, c2), floormod(x, c2),
                        c2.Eval()->value > 0 && c1.Eval()->value % 
c2.Eval()->value == 0);
 
+    TVM_TRY_REWRITE_IF(floormod(x * c1 + y, c2), floormod(x, floordiv(c2, c1)) 
* c1 + y,
+                       c1.Eval()->value > 0 && c2.Eval()->value > 0 &&
+                       c2.Eval()->value % c1.Eval()->value == 0 &&
+                       CanProveGreaterEqual(-y.Eval(), -c1.Eval()->value + 1));
+
+    // TODO(jcf94): For the next three rules, better use the max common factor
+    // of c1, c2, c3 to do the simplify
+    TVM_TRY_REWRITE_IF(floormod(x * c1 + y * c2 + z, c3),
+                       floormod(x * floordiv(c1, c2) + y, floordiv(c3, c2)) * 
c2 + z,
+                       c1.Eval()->value > 0 && c2.Eval()->value > 0 &&
+                       c3.Eval()->value > 0 &&
+                       c3.Eval()->value % c2.Eval()->value == 0 &&
+                       c1.Eval()->value % c2.Eval()->value == 0 &&
+                       CanProveGreaterEqual(-z.Eval(), -c2.Eval()->value + 1));
+
+    TVM_TRY_REWRITE_IF(floormod(w * c1 + x * c2 + y * c3 + z, c4),
+                       floormod(w * floordiv(c1, c3) + x * floordiv(c2, c3) + 
y,
+                                floordiv(c4, c3)) * c3 + z,
+                       c1.Eval()->value > 0 && c2.Eval()->value > 0 &&
+                       c3.Eval()->value > 0 && c4.Eval()->value > 0 &&

Review comment:
       Would be great if we can also provide an example motivation to the PR




----------------------------------------------------------------
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:
[email protected]


Reply via email to