MasterJH5574 commented on a change in pull request #8855:
URL: https://github.com/apache/tvm/pull/8855#discussion_r696813532
##########
File path: src/tir/transforms/plan_update_buffer_allocation_location.cc
##########
@@ -85,11 +83,22 @@ class BufferAllocationLocator : public StmtExprMutator {
buffer_data_to_buffer_.Set(buf->data, buf);
}
}
+ for (const MatchBufferRegion match_buffer : op->match_buffers) {
+ const Var& target_var = match_buffer->buffer->data;
+ const Var& source_var = match_buffer->source->buffer->data;
+ ICHECK(buffer_data_to_buffer_.count(source_var));
+ buffer_data_to_buffer_.Set(target_var, match_buffer->buffer);
+ }
Stmt stmt = StmtMutator::VisitStmt_(op);
op = stmt.as<BlockNode>();
ICHECK(op != nullptr);
- // Ignore buffer allocated inside the block when getting access region.
+ // Ignore buffer created by match_buffer inside the block when updating
access region.
Review comment:
Using "we no longer consider" might be a better expression. WDYT?
```suggestion
// No longer consider buffers created by match_buffer inside the block
when updating access region.
```
##########
File path: src/tir/transforms/plan_update_buffer_allocation_location.cc
##########
@@ -85,11 +83,22 @@ class BufferAllocationLocator : public StmtExprMutator {
buffer_data_to_buffer_.Set(buf->data, buf);
}
}
+ for (const MatchBufferRegion match_buffer : op->match_buffers) {
+ const Var& target_var = match_buffer->buffer->data;
+ const Var& source_var = match_buffer->source->buffer->data;
+ ICHECK(buffer_data_to_buffer_.count(source_var));
+ buffer_data_to_buffer_.Set(target_var, match_buffer->buffer);
+ }
Stmt stmt = StmtMutator::VisitStmt_(op);
op = stmt.as<BlockNode>();
ICHECK(op != nullptr);
- // Ignore buffer allocated inside the block when getting access region.
+ // Ignore buffer created by match_buffer inside the block when updating
access region.
+ for (const MatchBufferRegion match_buffer : op->match_buffers) {
+ const Var& target_var = match_buffer->buffer->data;
+ buffer_data_to_buffer_.erase(target_var);
+ }
+ // Ignore buffer allocated inside the block when updating access region.
Review comment:
Ditto.
```suggestion
// No longer consider buffers allocated inside the block when updating
access region.
```
##########
File path: src/tir/transforms/plan_update_buffer_allocation_location.cc
##########
@@ -127,8 +133,18 @@ class BufferAllocationLocator : public StmtExprMutator {
return std::move(realize);
}
+ Array<BufferRegion> UpdateRegion(const Array<BufferRegion>& region) const {
Review comment:
It would be greater to name the function in a more informative way.
After all, what we do is removing stuffs instead of updating stuffs. What about
`RemoveRedundantBufferRegion`? Although I admit that it is quite long...
--
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]