-
Notifications
You must be signed in to change notification settings - Fork 238
[Pass] Introduce flag to diable cp async lowering #633
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,8 +165,8 @@ class BufferRegionCollector : public StmtExprVisitor { | |
|
||
class PipelinePlanner : public StmtExprMutator { | ||
public: | ||
static Stmt Substitute(const PrimFunc &f) { | ||
PipelinePlanner substituter; | ||
static Stmt Substitute(const PrimFunc &f, bool use_async_copy = true) { | ||
PipelinePlanner substituter(use_async_copy); | ||
for (const auto &[_, buffer] : f->buffer_map) { | ||
substituter.buffer_data_to_buffer_.Set(buffer->data, buffer); | ||
} | ||
|
@@ -179,6 +179,7 @@ class PipelinePlanner : public StmtExprMutator { | |
|
||
private: | ||
PipelinePlanner() = default; | ||
PipelinePlanner(bool use_async_copy) : use_async_copy_(use_async_copy) {} | ||
|
||
/*! \brief Information about a pipeline stage | ||
* | ||
|
@@ -262,7 +263,7 @@ class PipelinePlanner : public StmtExprMutator { | |
} | ||
} | ||
annotations.Set(tir::attr::software_pipeline_stage, stage_anno); | ||
if (TargetHasAsyncCopy(target_)) | ||
if (TargetHasAsyncCopy(target_) && use_async_copy_) | ||
annotations.Set(tir::attr::software_pipeline_async_stages, | ||
Array<Integer>{0}); | ||
auto for_node = GetRef<For>(loop); | ||
|
@@ -459,7 +460,7 @@ class PipelinePlanner : public StmtExprMutator { | |
|
||
annotations.Set(tir::attr::software_pipeline_stage, Array<Integer>(stages)); | ||
annotations.Set(tir::attr::software_pipeline_order, Array<Integer>(orders)); | ||
if (TargetHasAsyncCopy(target_)) | ||
if (TargetHasAsyncCopy(target_) && use_async_copy_) | ||
annotations.Set(tir::attr::software_pipeline_async_stages, | ||
Array<Integer>{0}); | ||
|
||
|
@@ -480,13 +481,16 @@ class PipelinePlanner : public StmtExprMutator { | |
|
||
Map<Var, Buffer> buffer_data_to_buffer_; | ||
Target target_; | ||
bool use_async_copy_; | ||
}; | ||
|
||
tvm::transform::Pass PipelinePlanning() { | ||
using namespace tir::transform; | ||
auto pass_func = [=](PrimFunc f, IRModule m, PassContext ctx) { | ||
bool use_async_copy = | ||
ctx->GetConfig<Bool>("tir.use_async_copy", Bool(true)).value(); | ||
PrimFuncNode *fptr = f.CopyOnWrite(); | ||
fptr->body = PipelinePlanner::Substitute(f); | ||
fptr->body = PipelinePlanner::Substitute(f, use_async_copy); | ||
return f; | ||
}; | ||
return CreatePrimFuncPass(pass_func, 0, "tl.PipelinePlanning", {}); | ||
Comment on lines
487
to
496
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The configuration key
"tir.use_async_copy"
is a bit generic. Since this pass is part oftilelang
, it would be better to namespace the configuration key to avoid potential conflicts with other TIR passes and to make its scope clearer. Suggest using a more specific key, like"tl.pipeline.use_async_copy"
.