masahi commented on a change in pull request #10638:
URL: https://github.com/apache/tvm/pull/10638#discussion_r836849738
##########
File path: src/tir/schedule/primitive/reduction.cc
##########
@@ -284,7 +284,22 @@ StmtSRef DecomposeReduction(ScheduleState self, const
StmtSRef& block_sref,
/*body=*/body);
}
body = Substitute(body, loop_var_map);
- // Step 6. Mutate IR
+ // Step 6. Add write regions back to read regions in update block.
+ Array<BufferRegion> new_reads;
+ std::unordered_set<const BufferNode*> read_bufs;
+ for (const BufferRegion& read_access : block->reads) {
+ read_bufs.insert(read_access->buffer.get());
+ }
+ for (const BufferRegion& write_access : block->writes) {
+ if (read_bufs.find(write_access->buffer.get()) == read_bufs.end()) {
+ new_reads.push_back(write_access);
+ }
+ }
+ for (const BufferRegion& read_access : block->reads) {
+ new_reads.push_back(read_access);
+ }
+ (const_cast<BlockNode*>(block))->reads = std::move(new_reads);
Review comment:
yeah, I can prepare a repro. It's a bit complicated since it involves
scheduling, database stuff, and `ApplyHistoryBest`. I know the issue comes from
this PR since I bisected it.
So when `decompose_reduction` is called, we are now executing
https://github.com/yzh119/tvm/blob/cd42ab101ab993edae2956fdc0415561be5f9718/src/tir/schedule/primitive/reduction.cc#L301
and I'm guessing that this in-place update propagates all the way up to the
committed `prim_mod` in the tuning database.
--
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]