You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/03/28 20:43:00 UTC

[GitHub] [tvm] junrushao1994 commented on a change in pull request #10638: [TIR] Change the behavior of read/write region analysis for reduction blocks.

junrushao1994 commented on a change in pull request #10638:
URL: https://github.com/apache/tvm/pull/10638#discussion_r836832510



##########
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:
       @masahi thanks for reporting this! I'm not sure why the IRModule is mutated in place after decompose-reduction (not sure if i understand correctly), but would be great to have a minimal reproducible example after you returning from vacation :-)
   
   @yzh119 would you mind taking a look at the particular case Masa mentions and perhaps add a regression test? 




-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org