New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FAQ entry about value names #180
base: main
Are you sure you want to change the base?
Conversation
@@ -179,3 +179,7 @@ use in `test.op`), whereas iterating on the "users" of `%0` would yield directly | |||
twice a user of `%0`, it's up to the call site to use a set to unique these if needed. | |||
[The tutorial on use-def chains](https://mlir.llvm.org/docs/Tutorials/UnderstandingTheIRStructure/#traversing-the-def-use-chains) may help understand the details as well. | |||
|
|||
## How to programmatically obtain the "name" of the SSA value (`%foo`)? | |||
|
|||
It is impossible in general. The values names are _not part of the IR_ and are only there to make textual representation of the IR easier for humans to read. They are generated by the IR printer on-the-fly and may differ depending on the printer configuration. It is, however, possible to ask the printer to generate specific names by having the operation that defines the value implement [`OpAsmOpInterface`](https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/OpAsmInterface.td). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But even if you specify a name, when there is a clash, the printer will insert a counter to the end (ex. %foo1
) to avoid clashes. So even in that case, it is not possible to always get the name.
Perhaps just allude to the fact that those are not names, but counters, would make it easier to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use "identifier" instead of "counters" I think (the latter makes me think it’s numerical)
(but maybe "identifier" does not help to express clearly what you're looking for by going away from "name")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identifier implies identity... Rephrased to mention specifically that one can control the prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"identity" seems right though: in the textual format it is supposed to be exactly this isn't it?
@@ -179,3 +179,7 @@ use in `test.op`), whereas iterating on the "users" of `%0` would yield directly | |||
twice a user of `%0`, it's up to the call site to use a set to unique these if needed. | |||
[The tutorial on use-def chains](https://mlir.llvm.org/docs/Tutorials/UnderstandingTheIRStructure/#traversing-the-def-use-chains) may help understand the details as well. | |||
|
|||
## How to programmatically obtain the "name" of the SSA value (`%foo`)? | |||
|
|||
It is impossible in general. The values names are _not part of the IR_ and are only there to make textual representation of the IR easier for humans to read. They are generated by the IR printer on-the-fly and may differ depending on the printer configuration. It is, however, possible to ask the printer to generate specific names by having the operation that defines the value implement [`OpAsmOpInterface`](https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/IR/OpAsmInterface.td). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd not say its impossible (you can create the AsmState, print, retrieve, create map and well, technically, reuse the AsmState to ensure it is kept, but given the naming is deterministic, if you are doing a non-local variant it should remain the same). That's not the problem, the problem is folks having an expectation that it is consistent across mutations etc. The expectation of these being "attached" names that are somehow fixed is more problematic.
Can you mdformat? |
This question gets asked a lot so clarify that names are not part of the IR.
Github doesn't seem to pick up the changes, here's the branch: main...ftynse-patch-1 |
This question gets asked a lot so clarify that names are not part of the IR.