gemini-code-assist[bot] commented on code in PR #18843:
URL: https://github.com/apache/tvm/pull/18843#discussion_r2867019921
##########
src/s_tir/schedule/primitive/layout_transformation.cc:
##########
@@ -887,6 +894,18 @@ class TransformLayoutRewriter : private
arith::IRMutatorWithAnalyzer {
auto* n = block.CopyOnWrite();
RewriteAccessRegion(&n->reads, infered_access_regions[0]);
RewriteAccessRegion(&n->writes, infered_access_regions[1]);
+ // Update match_buffers whose source references old_buffer_
+ n->match_buffers.MutateByApply([this](const MatchBufferRegion& match_buf) {
+ if (match_buf->source->buffer.same_as(old_buffer_)) {
+ auto new_source = match_buf->source;
+ auto* source_n = new_source.CopyOnWrite();
+ source_n->buffer = new_buffer_;
+ auto new_match = match_buf;
+ new_match.CopyOnWrite()->source = new_source;
+ return new_match;
Review Comment:

This logic for updating the `match_buffer` is correct, but it can be made
more concise and idiomatic by chaining the `CopyOnWrite` calls. This improves
readability without changing the functionality.
```suggestion
auto new_match = match_buf;
auto* n = new_match.CopyOnWrite();
n->source.CopyOnWrite()->buffer = new_buffer_;
return new_match;
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]