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 2021/03/27 14:09:19 UTC

[GitHub] [tvm] spectrometerHBH opened a new pull request #7759: [ARITH] normalize iter affine map expr to PrimExpr

spectrometerHBH opened a new pull request #7759:
URL: https://github.com/apache/tvm/pull/7759


   cc @tqchen 


-- 
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] [tvm] tqchen commented on pull request #7759: [ARITH] normalize iter affine map expr to PrimExpr

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


   cc @hzfan @Hzfengsy @jinhongyii 
   


-- 
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] [tvm] tqchen merged pull request #7759: [ARITH] normalize iter affine map expr to PrimExpr

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


   


-- 
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] [tvm] spectrometerHBH commented on pull request #7759: [ARITH] normalize iter affine map expr to PrimExpr

Posted by GitBox <gi...@apache.org>.
spectrometerHBH commented on pull request #7759:
URL: https://github.com/apache/tvm/pull/7759#issuecomment-808859323


   The CI error looks wired to me. I don't know what leads to the error


-- 
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] [tvm] hzfan commented on a change in pull request #7759: [ARITH] normalize iter affine map expr to PrimExpr

Posted by GitBox <gi...@apache.org>.
hzfan commented on a change in pull request #7759:
URL: https://github.com/apache/tvm/pull/7759#discussion_r603032508



##########
File path: src/arith/iter_affine_map.cc
##########
@@ -1028,5 +1028,61 @@ PrimExpr IterMapRewriter::VisitExpr_(const FloorModNode* op) {
   }
 }
 
+/*! * \brief Given an IterVarMapExpr, transform it to normal PrimExpr. */
+class IterMapToExprNormalizer {
+ public:
+  explicit IterMapToExprNormalizer(Analyzer* analyzer) : analyzer_(analyzer) {}
+
+  PrimExpr Convert(const IterMapExpr& expr) {
+    if (const auto* op = expr.as<IterSplitExprNode>()) {
+      return ConvertIterSplitExpr(GetRef<IterSplitExpr>(op));
+    } else if (const auto* op = expr.as<IterSumExprNode>()) {
+      return ConvertIterSumExpr(GetRef<IterSumExpr>(op));
+    } else {
+      ICHECK(expr.defined());
+      LOG(FATAL) << "Unknown IterMapExpr type " << expr->GetTypeKey();
+      return 0;
+    }
+  }
+
+  PrimExpr ConvertIterSumExpr(const IterSumExpr& expr) {
+    PrimExpr res = 0;
+    for (const IterSplitExpr& arg : expr->args) {
+      res += ConvertIterSplitExpr(arg);
+    }
+    res += expr->base;
+    return res;
+  }
+
+  PrimExpr ConvertIterSplitExpr(const IterSplitExpr& expr) {
+    PrimExpr source;
+    if (const auto* op = expr->source->source.as<VarNode>()) {
+      source = GetRef<Var>(op);
+    } else if (const auto& op = expr->source->source.as<IterSumExprNode>()) {

Review comment:
       ```suggestion
       } else if (const auto* op = expr->source->source.as<IterSumExprNode>()) {
   ```

##########
File path: src/arith/iter_affine_map.cc
##########
@@ -1028,5 +1028,61 @@ PrimExpr IterMapRewriter::VisitExpr_(const FloorModNode* op) {
   }
 }
 
+/*! * \brief Given an IterVarMapExpr, transform it to normal PrimExpr. */
+class IterMapToExprNormalizer {
+ public:
+  explicit IterMapToExprNormalizer(Analyzer* analyzer) : analyzer_(analyzer) {}
+
+  PrimExpr Convert(const IterMapExpr& expr) {
+    if (const auto* op = expr.as<IterSplitExprNode>()) {
+      return ConvertIterSplitExpr(GetRef<IterSplitExpr>(op));
+    } else if (const auto* op = expr.as<IterSumExprNode>()) {
+      return ConvertIterSumExpr(GetRef<IterSumExpr>(op));
+    } else {
+      ICHECK(expr.defined());
+      LOG(FATAL) << "Unknown IterMapExpr type " << expr->GetTypeKey();
+      return 0;
+    }
+  }
+
+  PrimExpr ConvertIterSumExpr(const IterSumExpr& expr) {
+    PrimExpr res = 0;
+    for (const IterSplitExpr& arg : expr->args) {
+      res += ConvertIterSplitExpr(arg);
+    }
+    res += expr->base;
+    return res;
+  }
+
+  PrimExpr ConvertIterSplitExpr(const IterSplitExpr& expr) {
+    PrimExpr source;
+    if (const auto* op = expr->source->source.as<VarNode>()) {
+      source = GetRef<Var>(op);
+    } else if (const auto& op = expr->source->source.as<IterSumExprNode>()) {
+      source = ConvertIterSumExpr(GetRef<IterSumExpr>(op));
+    }

Review comment:
       Do we need to LOG(FATAL) if it falls in neither of the if?




-- 
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] [tvm] tqchen commented on pull request #7759: [ARITH] normalize iter affine map expr to PrimExpr

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


   Thanks @spectrometerHBH can you add a few testcases for normalize_iter_map_to_expr? Thank you!


-- 
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] [tvm] tqchen commented on pull request #7759: [ARITH] normalize iter affine map expr to PrimExpr

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


   Thanks @spectrometerHBH @jinhongyii @Hzfengsy @hzfan 


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