MasterJH5574 commented on a change in pull request #8641:
URL: https://github.com/apache/tvm/pull/8641#discussion_r682631254
##########
File path: src/tir/transforms/compact_buffer_region.cc
##########
@@ -452,11 +452,17 @@ class BufferCompactor : public StmtExprMutator {
};
PrimFunc CompactBufferAllocation(PrimFunc f) {
- PrimFuncNode* fptr = f.CopyOnWrite();
- std::unordered_map<Buffer, Region, ObjectPtrHash, ObjectPtrEqual> region =
- BufferAccessRegionCollector::Collect(f);
- fptr->body = BufferCompactor::Compact(f, region);
- return f;
+ // Only apply this pass to TIR that is not from TE schedules
+ Optional<Bool> from_legacy_te_schedule =
f->GetAttr("from_legacy_te_schedule", Bool(false));
+ if (!from_legacy_te_schedule.value()) {
+ PrimFuncNode* fptr = f.CopyOnWrite();
+ std::unordered_map<Buffer, Region, ObjectPtrHash, ObjectPtrEqual> region =
+ BufferAccessRegionCollector::Collect(f);
+ fptr->body = BufferCompactor::Compact(f, region);
+ return f;
+ } else {
+ return f;
+ }
Review comment:
It seems that this part can only be passed to the helper using a lambda.
I wonder whether it would mess up the code?
##########
File path: src/tir/transforms/compact_buffer_region.cc
##########
@@ -452,11 +452,17 @@ class BufferCompactor : public StmtExprMutator {
};
PrimFunc CompactBufferAllocation(PrimFunc f) {
- PrimFuncNode* fptr = f.CopyOnWrite();
- std::unordered_map<Buffer, Region, ObjectPtrHash, ObjectPtrEqual> region =
- BufferAccessRegionCollector::Collect(f);
- fptr->body = BufferCompactor::Compact(f, region);
- return f;
+ // Only apply this pass to TIR that is not from TE schedules
+ Optional<Bool> from_legacy_te_schedule =
f->GetAttr("from_legacy_te_schedule", Bool(false));
+ if (!from_legacy_te_schedule.value()) {
+ PrimFuncNode* fptr = f.CopyOnWrite();
+ std::unordered_map<Buffer, Region, ObjectPtrHash, ObjectPtrEqual> region =
+ BufferAccessRegionCollector::Collect(f);
+ fptr->body = BufferCompactor::Compact(f, region);
+ return f;
+ } else {
+ return f;
+ }
Review comment:
Got it. That's all right.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]