-
Notifications
You must be signed in to change notification settings - Fork 332
[Refactor] Backup Analyzer to get the appropriate arith informations #1311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
cfc429d
d9560ea
7484f05
be0d319
ab44b74
6221326
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,7 +45,7 @@ struct VectorizePlanResult { | |||||||
| PrimExpr condition; | ||||||||
| }; | ||||||||
|
|
||||||||
| class VectorizeFindGlobalAccess : public arith::IRVisitorWithAnalyzer { | ||||||||
| class VectorizeFindGlobalAccess : public StmtExprVisitor { | ||||||||
| public: | ||||||||
| VectorizeFindGlobalAccess() = default; | ||||||||
|
|
||||||||
|
|
@@ -60,19 +60,21 @@ class VectorizeFindGlobalAccess : public arith::IRVisitorWithAnalyzer { | |||||||
| void VisitStmt_(const BufferStoreNode *node) final { | ||||||||
| if (node->buffer.scope() == "global") | ||||||||
| has_global_access_ = true; | ||||||||
| return arith::IRVisitorWithAnalyzer::VisitStmt_(node); | ||||||||
| return StmtExprVisitor::VisitStmt_(node); | ||||||||
| } | ||||||||
LeiWang1999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
|
|
||||||||
| void VisitExpr_(const BufferLoadNode *node) final { | ||||||||
| if (node->buffer.scope() == "global") | ||||||||
| has_global_access_ = true; | ||||||||
| return arith::IRVisitorWithAnalyzer::VisitExpr_(node); | ||||||||
| return StmtExprVisitor::VisitExpr_(node); | ||||||||
| } | ||||||||
LeiWang1999 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| }; | ||||||||
|
|
||||||||
| class VectorizePlanner : public arith::IRVisitorWithAnalyzer { | ||||||||
| class VectorizePlanner : public arith::IRMutatorWithAnalyzer { | ||||||||
| public: | ||||||||
| VectorizePlanner() = default; | ||||||||
| VectorizePlanner() : arith::IRMutatorWithAnalyzer(new arith::Analyzer()) {} | ||||||||
| explicit VectorizePlanner(arith::Analyzer *analyzer) | ||||||||
| : arith::IRMutatorWithAnalyzer(analyzer) {} | ||||||||
|
|
||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| int Plan(const For &node) { | ||||||||
| tvm::transform::PassContext ctxt = tvm::transform::PassContext::Current(); | ||||||||
|
|
@@ -92,21 +94,31 @@ class VectorizePlanner : public arith::IRVisitorWithAnalyzer { | |||||||
| } | ||||||||
|
|
||||||||
| private: | ||||||||
| void VisitStmt_(const ForNode *node) final { | ||||||||
| Stmt VisitStmt_(const ForNode *node) final { | ||||||||
| inner_for_ = node; | ||||||||
| auto extent_ptr = as_const_int(analyzer_.Simplify(node->extent)); | ||||||||
| // Here I disable dynamic shape completely, | ||||||||
| // In order to do it, the Planner should accept an analyzer with | ||||||||
| // arithmetic info outside to prove the dividiblity of vector size | ||||||||
| if (!extent_ptr) { | ||||||||
| vector_size_ = 1; | ||||||||
| return; | ||||||||
| bool contains_nested_for = false; | ||||||||
| // Must analysis vectorization on the innermost loop | ||||||||
| PostOrderVisit(Downcast<Stmt>(node), [&](const ObjectRef &obj) { | ||||||||
| if (obj.as<ForNode>()) { | ||||||||
|
||||||||
| if (obj.as<ForNode>()) { | |
| const ForNode* for_node = obj.as<ForNode>(); | |
| if (for_node && for_node != node) { |
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Nov 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing FloorMod(simplified_expr, target_size_for_expr) against zero is incorrect. The result of FloorMod has the same dtype as simplified_expr (i.e., expr.dtype()), but zero has type var.dtype(). These types may differ, causing the comparison to fail. Use make_const(expr.dtype(), 0) instead of zero.
| zero)) { | |
| make_const(expr.dtype(), 0))) { |
Uh oh!
There was an error while loading. Please reload this page.