Skip to content
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

Bump Upsample to Opset 10 and change the opset versioning to allow to skip over opset versions if a newer, backwards compatible one exists. #3065

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jorickert
Copy link
Collaborator

@jorickert jorickert commented Feb 3, 2025

Upsample was marked as deprecated with Opset 10

This is a non-functional change, the only difference is that Upsample was marked as deprecated with Opset 10

Signed-off-by: Rickert, Jonas <[email protected]>
@jorickert jorickert requested a review from tungld February 3, 2025 15:51
@@ -210,7 +210,7 @@ op_dialect_version_map_["TreeEnsembleClassifier"] = {1};
op_dialect_version_map_["TreeEnsembleRegressor"] = {1};
op_dialect_version_map_["Unique"] = {11};
op_dialect_version_map_["Unsqueeze"] = {13, 11};
op_dialect_version_map_["Upsample"] = {9, 7};
op_dialect_version_map_["Upsample"] = {10, 7};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we have to keep 9 in the set, e.g. {10, 9, 7}. And defining a simple rule in decompose.cpp for UpsampleV9Op.

@jorickert jorickert changed the title Bump Upsample to Opset 10 Bump Upsample to Opset 10 and change the opset versioning to allow to skip over opset versions if a newer, backwards compatible one exists. Feb 7, 2025
@jorickert
Copy link
Collaborator Author

jorickert commented Feb 7, 2025

Supporting multiple different versions required to write simple decomposition/upgrade rule to rewrite the older opset version to a newer one.
I extended this PR with a new built-time generated map that contains all versions of an operation as defined by onnx.
To determine the opset version for a node/op:

  1. Determine the latest valid opset version. This is the newest version in this opset-version-map that is older or equal to the current graph opset.

  2. Select the newest version from the versions supported by onnx-mlir that is equal or newer to the latest valid opset version. This allows it to skip over opset versions, that have a newer backwards compatible version.
    Example:
    Versions in onnx and supported by onnx-mlir: [3, 5].
    Graph opset version to node version: 3 -> 3, 4 -> 3, 5 -> 5

    Versions in onnx: [7, 9, 10]. Version 10 is backwards compatible to version 9.
    Version supported by onnx-mlir: [7, 10].
    Graph opset version to node version: 7 -> 7, 8 -> 7, 9 -> 10, 10 -> 10

This changes allows it to not have duplicates of ops that changed in a backwards-compatible way, instead only versions with breaking changes need to be supported by onnx-mlir

…opset to use.

Introduces a new built-time generated map that contains all versions of an operation as defined by onnx.
To determine the opset version for a node/op:
1.	Determine the latest valid opset version. This is the newest version in this opset-version-map that is older or equal to the current graph opset.
2.	Select the newest version from the versions supported by onnx-mlir that is equal or newer to the latest valid opset version. This allows it to skip over opset versions, that have a newer backwards compatible version.
Example:
	Versions in onnx and supported by onnx-mlir: [3, 5].
	Graph opset version to node version: 3 -> 3, 4 -> 3, 5 -> 5

	Versions in onnx: [7, 9, 10]. Version 10 is backwards compatible to version 9.
	Version supported by onnx-mlir: [7, 10].
	Graph opset version to node version: 7 -> 7, 8 -> 7, 9 -> 10, 10 -> 10

Signed-off-by: Rickert, Jonas <[email protected]>
@jorickert jorickert force-pushed the jrickert.upstream.bump_upsample branch from 457d89d to 4dd9c93 Compare February 7, 2025 17:27
@jorickert
Copy link
Collaborator Author

@tungld @AlexandreEichenberger I extend this PR to include a mechanism to determine the opset version to use based on the opsets supported by onnx-mlir and the opsets defined by onnx. It would be great if you could comment on it and if you prefer this approach or the one of using trivial decompose/upgrade rules in onnx-mlir to handle the "skiipping" of backwards compatible opset versions.
Implementation note: I extended gen_onnx_mlir.py to build the opset map at build time, alternatively FronendDialectTransformer could be extended to read this information at runtime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants