junrushao commented on code in PR #13743:
URL: https://github.com/apache/tvm/pull/13743#discussion_r1071639058


##########
src/script/printer/tir/block.cc:
##########
@@ -67,6 +110,30 @@ Doc PrintBlock(IRDocsifier d, tir::Block block, ObjectPath 
block_p,  //
     }
     (*frame)->stmts.push_back(AssignDoc(DefineVar(iter_var->var, *frame, d), 
rhs, NullOpt));
   }
+
+  // Step 1.4. Construct block var bindings of T.axis.remap
+  if (remap_vars.size()) {
+    int m = remap_vars.size();
+    Array<ExprDoc> lhs;
+    Array<ExprDoc> loop_var_doc;
+    lhs.reserve(m);
+    loop_var_doc.reserve(m);
+    std::string binding_type = "";
+    for (int i = 0; i < n_vars; ++i) {
+      tir::IterVar iter_var = block->iter_vars[i];
+      ObjectPath iter_var_p = block_p->Attr("iter_var")->ArrayIndex(i);
+      if (remap_vars.count(iter_var)) {
+        lhs.push_back(DefineVar(iter_var->var, *frame, d));
+        loop_var_doc.push_back(d->AsDoc<ExprDoc>(realize->iter_values[i],
+                                                 
realize_p->Attr("iter_values")->ArrayIndex(i)));
+        binding_type += iter_var->iter_type == tir::IterVarType::kDataPar ? 
"S" : "R";
+      }
+    }
+    ExprDoc rhs = TIR("axis")->Attr("remap");
+    rhs = rhs->Call({LiteralDoc::Str(binding_type), ListDoc(loop_var_doc)});
+    (*frame)->stmts.push_back(AssignDoc(TupleDoc(lhs), rhs, NullOpt));

Review Comment:
   The ordering of iter vars are important and cannot be arbitrarily reordered. 
Therefore, we have to remap only the adjacent ones



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