-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[Frontend][ONNX] Replace :
in input name with _
#13011
Conversation
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.
Hmm, I think the current code is a bit confusing, can you try to clean it up?
Regardless, I suspect this might not be the best approach. This PR is designed to fix a problem in the parser, why not fix the problem in the parser? Or is the grammar of relay fundamentally incompatible with ":"?
I only say this because you can make a relay variable with ":". If this is allowed in the relay language it should also be supported by the parser.
@@ -5642,9 +5643,11 @@ def _parse_graph_input(self, graph): | |||
continue | |||
else: |
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 notice you only handle the else branch here. Will we not have the same parsing error from the other branches?
@@ -5629,6 +5629,7 @@ def _parse_graph_initializers(self, graph): | |||
|
|||
def _parse_graph_input(self, graph): | |||
for i in graph.input: | |||
i_name_compatible = None |
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.
this seems a bit messy as now i_name_compatible can be of types [None, str].
This is actually an issue since the python str of "" is not truthy (it is false) which may be able to be an onnx name (correct me if im wrong). If this is the intention it is a bit unclear and deserves a comment.
Why can't we just do something like:
new_name = i.name.replace(":", "_")
self._renames[i.name] = new_name
i.name = new_name
i_name_compatible, shape=i_shape, dtype=dtype | ||
) | ||
|
||
if i_name_compatible: |
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.
In it's current state it seems the intention this branch will always be evaluated in the else branch on line 5643.
The issue is fixed with this PR: |
This PR changes onnx frontend to rename input with
:
character. This will fix this issue:#12362