This repository was archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
[v1.x] ONNX: fix error handling when op is not registered #20261
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,7 @@ | |
|
|
||
| # coding: utf-8 | ||
| # pylint: disable=invalid-name,too-many-locals,no-self-use,too-many-arguments, | ||
| # pylint: disable=maybe-no-member,too-many-nested-blocks | ||
| # pylint: disable=maybe-no-member,too-many-nested-blocks,logging-not-lazy | ||
| """MXNet to ONNX graph converter functions""" | ||
| import logging | ||
| import json | ||
|
|
@@ -91,15 +91,23 @@ def convert_layer(node, **kwargs): | |
|
|
||
| op = str(node["op"]) | ||
| opset_version = kwargs.get("opset_version", onnx_opset_version()) | ||
| # fallback to older opset versions if op is not registered in current version | ||
| if opset_version < 12: | ||
| logging.warning('Your ONNX op set version is %s, ' % str(opset_version) + | ||
| 'which is lower than then lowest tested op set (12), please consider ' | ||
| 'updating ONNX') | ||
| opset_version = 12 | ||
| # Fallback to older opset versions if op is not registered in current version | ||
| convert_func = None | ||
| for op_version in range(opset_version, 11, -1): | ||
| if op_version not in MXNetGraph.registry_ or op not in MXNetGraph.registry_[op_version]: | ||
| if opset_version == 12: | ||
| raise AttributeError("No conversion function registered for op type %s yet." % op) | ||
| continue | ||
| convert_func = MXNetGraph.registry_[op_version][op] | ||
| break | ||
|
|
||
| # The conversion logic is not implemented | ||
| if convert_func is None: | ||
| raise AttributeError("No conversion function registered for op type %s yet." % op) | ||
|
Contributor
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. can you add a comment here to explain why this would happen? (ie. is it because the op is not supported or because the installed version of onnx is too old?)
Contributor
Author
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. added! |
||
|
|
||
| ret = convert_func(node, **kwargs) | ||
| # in case the conversion function does not specify the returned dtype, we just return None | ||
| # as the second value | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 some variable we can use to print the op set version instead of hard coding "12" in this message? its likely we may forget to update it later...
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 think unlike cuda where we keep a supported window, the minimum supported version for onnx is fixed at 12 (latest is 14). When new opeset is released we can add support for it without removing the previous opset support