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:

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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]