You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "guan404ming (via GitHub)" <gi...@apache.org> on 2026/06/29 08:10:55 UTC

[PR] [TIRx] Reuse pass-through input names for inverse index map vars [tvm]

guan404ming opened a new pull request, #19905:
URL: https://github.com/apache/tvm/pull/19905

   ## Why
   
   Inverse index map input variables were always named axis0, axis1, ..., making generated IR harder to read.
   
   ## How
   
   - Name a pass-through inverse input after its source Var instead of axis{i}.
   - Keep the axis{i} fallback for computed (non-pass-through) indices.
   - Add test_inverse_preserves_passthrough_var_names covering a transpose map.


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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIRx] Reuse pass-through input names for inverse index map vars [tvm]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #19905:
URL: https://github.com/apache/tvm/pull/19905#discussion_r3490201330


##########
src/tirx/ir/index_map.cc:
##########
@@ -76,14 +76,18 @@ std::pair<IndexMap, PrimExpr> IndexMapInverseImpl(const IndexMap& self,
   ffi::Array<Var> output_vars;
   for (size_t i = 0; i < self->final_indices.size(); i++) {
     PrimExpr index = self->final_indices[i];
-    // TODO(Lunderberg): Better names for these variables.  A variable
-    // that is passed through unmodified (`index` is an element of
-    // `initial_indices`) should use that input index's name.  A pair
-    // of output indices variables split from a single input index
-    // should be named (X.outer,X.inner).
-    std::stringstream ss;
-    ss << "axis" << i;
-    Var var_index(ss.str(), index.ty());
+    // A pass-through index keeps the input variable's name for readability.
+    // TODO(Lunderberg): Name a pair of output indices split from a single
+    // input index as (X.outer, X.inner).
+    std::string name;
+    if (auto* var = index.as<VarNode>()) {
+      name = var->name_hint;
+    } else {
+      std::stringstream ss;
+      ss << "axis" << i;
+      name = ss.str();
+    }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using `std::stringstream` to format a simple string with an integer is less efficient and more verbose than using `std::to_string`. Since `std::to_string` is already used elsewhere in this file (e.g., line 56), we should use it here as well to keep the codebase consistent, clean, and performant.
   
   ```c
       } else {
         name = "axis" + std::to_string(i);
       }
   ```



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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIRx] Reuse pass-through input names for inverse index map vars [tvm]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming closed pull request #19905: [TIRx] Reuse pass-through input names for inverse index map vars
URL: https://github.com/apache/tvm/pull/19905


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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIRx] Reuse pass-through input names for inverse index map vars [tvm]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming closed pull request #19905: [TIRx] Reuse pass-through input names for inverse index map vars
URL: https://github.com/apache/tvm/pull/19905


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

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


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org