Skip to content

Commit 88dca66

Browse files
authored
Simplify name uniquification in inliner (microsoft#1953)
The current implementation of using the entire call-stack to produce unique names produces very long names, which makes debugging harder. Simplify this for now. (We may need some investigation to produce more meaningful names, which is future work.)
1 parent 8c8417d commit 88dca66

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

onnxscript/optimizer/_inliner.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@
2525
def _make_unique_name(name: str, callstack: CallStack, used_names: set[str]) -> str:
2626
"""Generate a unique name from a name, calling-context, and set of used names.
2727
28-
When a value X in a function is inlined into a graph, we rename X by adding a prefix
29-
representing the call-stack of the function. This should typically avoid name clashes.
30-
If there is a name clash, even after this, we add a numeric suffix to the name to make
28+
If there is a name clash, we add a numeric suffix to the name to make
3129
it unique. We use the same strategy to make node names unique.
30+
31+
TODO: We can use the callstack in generating a name for a value X in a function
32+
that is inlined into a graph. This is not yet implemented. Using the full callstack
33+
leads to very long and hard to read names. Some investigation is needed to find
34+
a good naming strategy that will produce useful names for debugging.
3235
"""
33-
prefix = "_".join(callstack)
34-
name = prefix + "_" + name
3536
candidate = name
3637
i = 1
3738
while candidate in used_names:

0 commit comments

Comments
 (0)