yzh119 commented on a change in pull request #10420:
URL: https://github.com/apache/tvm/pull/10420#discussion_r817268218



##########
File path: src/tir/schedule/analysis/analysis.cc
##########
@@ -363,6 +363,26 @@ void CheckCompleteOrReductionBlock(const ScheduleState& 
self, const StmtSRef& bl
                                          reduction_block_error_code);
 }
 
+StmtSRef GetInnermostDominantSubBlockSRef(const ScheduleState& self, const 
StmtSRef& block_sref) {
+  // return the innermost dominant sub-block.
+  const BlockNode* block = TVM_SREF_TO_BLOCK(block, block_sref);
+  bool all_iter_vars_data_parallel = true;
+  for (const IterVar& iter_var : block->iter_vars) {
+    if (iter_var->iter_type != kDataPar) {
+      all_iter_vars_data_parallel = false;
+    }
+  }
+  Array<StmtSRef> child_block_srefs = GetChildBlockSRefOnSRefTree(self, 
block_sref);
+  if (!block->init.defined() && child_block_srefs.size() == 1 && 
all_iter_vars_data_parallel) {
+    const StmtSRef& child_block_sref = child_block_srefs[0];
+    if (IsDominantBlock(self->GetBlockScope(block_sref), child_block_sref)) {

Review comment:
       This is to avoid something like:
   ```python
   with T.block("outer"):
       vi, vj = T.axis.remap("SS", [i, j])
       b[vi, vj, 0] = b[vi, vj, 1] + b[vi, vj, 2]
       for k, l in T.grid(16, 16):
           with T.block("inner"):
               vk, vl = T.axis.remap("SR", [k, l])
               with T.init():
                   b[vi, vj, vk] = 0.0
               b[vi, vj, vk] = b[vi, vj, vk] + a[vi, vj, vk, vl]
   ```
   
   But unfortunately the `IsDominantBlock` return true here...




-- 
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]


Reply via email to