ekalda commented on code in PR #16893:
URL: https://github.com/apache/tvm/pull/16893#discussion_r1567592059


##########
src/tir/transforms/vectorize_loop.cc:
##########
@@ -725,17 +728,33 @@ class Vectorizer : public StmtMutator, public 
ExprFunctor<PrimExpr(const PrimExp
 
 class LoopVectorizer : public StmtMutator {
  public:
+  LoopVectorizer(PrimFunc f) {
+    auto target = f->attrs.GetAttr<tvm::Target>(tvm::attr::kTarget);
+    if (target.defined()) {
+      target_ = Downcast<Target>(target);
+      has_sve_ = target_->GetFeature<Bool>("has_sve").value_or(Bool(false));
+    }
+  }
+
   Stmt VisitStmt_(const ForNode* op) final {
     if (op->kind == ForKind::kVectorized) {
+      auto* extent_as_int = op->extent.as<IntImmNode>();
+      if (!extent_as_int || extent_as_int->value < 1) {
+        bool is_scalable_expr = CheckContains::ExprContains(op->extent, 
arith::IsVScaleCall);
+        ICHECK(is_scalable_expr && has_sve_)
+            << "Failed to vectorize loop with extent " << op->extent << " for 
target " << target_;
+      }
       ICHECK(is_zero(op->min));
       return Vectorizer(op->loop_var, op->extent)(op->body);
     } else {
       return StmtMutator::VisitStmt_(op);
     }
   }
-};
 
-Stmt VectorizeLoop(Stmt stmt) { return LoopVectorizer()(std::move(stmt)); }

Review Comment:
   Is this function necessary? 



-- 
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-unsubscr...@tvm.apache.org

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

Reply via email to