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 2022/07/06 03:33:17 UTC

[GitHub] [tvm] ganler commented on a diff in pull request #12013: [BugFix] IRSubstitution should keep Var type consistency

ganler commented on code in PR #12013:
URL: https://github.com/apache/tvm/pull/12013#discussion_r914383061


##########
src/tir/ir/stmt_functor.cc:
##########
@@ -640,10 +641,44 @@ Stmt IRTransform(Stmt ir_node, const runtime::PackedFunc& f_preorder,
   return transform(std::move(ir_node));
 }
 
+#define DEFINE_BIOP_EXPR_PROMOTABLE_MUTATE_(OP)                                           \
+  PrimExpr VisitExpr_(const OP##Node* op) override {                                      \
+    PrimExpr a = this->VisitExpr(op->a);                                                  \
+    PrimExpr b = this->VisitExpr(op->b);                                                  \
+    if (a.same_as(op->a) && b.same_as(op->b)) {                                           \
+      return GetRef<PrimExpr>(op);                                                        \
+    } else {                                                                              \
+      if (a.dtype().code() == b.dtype().code() && a.dtype().bits() != b.dtype().bits()) { \

Review Comment:
   IR substituion will eventually fail if `a.dtype() != b.dtype()` which is required by binary operators at construction time (`OP(a, b)`). By promoting the operand types automatically when their base dtype (e.g., int or float) is the same can pass the test case (which is a valid model and failed previously due to `int32` in pool2d's topi conflicts `int64` in GPU attributes.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

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