-
Notifications
You must be signed in to change notification settings - Fork 24.8k
[dynamo] Use the new get_unique_name_wrt
helper when applicable
#146950
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
Changes from all commits
d88c73e
40e0155
22fa82f
1c0e9f3
ca550f0
c0437a0
9cea75d
df46a20
9ff44fb
7d8cf62
8118a93
bae3c97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1542,15 +1542,7 @@ def dedup_pass(self): | |
return dict() | ||
|
||
def install_subgraph(self, name, sub_gm): | ||
next_name = None | ||
i = 0 | ||
while not next_name: | ||
candidate = f"{name}_{i}" | ||
if candidate in self.nn_modules: | ||
i += 1 | ||
else: | ||
next_name = candidate | ||
|
||
next_name = get_unique_name_wrt(name, self.nn_modules, requires_suffix=True) | ||
sub_gm.__name__ = next_name | ||
sub_gm.torchdynamo_force_dynamic = False | ||
# This graph module is not present in the user space, so it can't be | ||
|
@@ -2256,14 +2248,7 @@ def create_graph_input( | |
TracingContext.extract_stack() | ||
) | ||
|
||
# unique | ||
if name in self.input_name_to_proxy: | ||
for i in itertools.count(): | ||
candidate_name = f"{name}_{i}" | ||
if candidate_name not in self.input_name_to_proxy: | ||
name = candidate_name | ||
break | ||
|
||
name = get_unique_name_wrt(name, self.input_name_to_proxy) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way to get this to always append a number, like before? I'm not sure that it matters but it's nice for the invariant to be "the name is foobar_i" where i is a number There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah lemme try that, otherwise there's too many tests to update lol. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sad -- either way we'll need to update a bunch of test so I added a |
||
if self.input_name_to_proxy: | ||
prev_name = next(reversed(self.input_name_to_proxy)) | ||
node = self.input_name_to_proxy[prev_name].node | ||
|
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.
is there a way to get this to always append a number, like before?