Skip to content

Add opset version check - #2980

Closed
snnn wants to merge 1 commit into
masterfrom
snnn/p10
Closed

Add opset version check#2980
snnn wants to merge 1 commit into
masterfrom
snnn/p10

Conversation

@snnn

@snnn snnn commented Feb 6, 2020

Copy link
Copy Markdown
Contributor

Description:

If the model has a opset version newer than onnxruntime knows, throw an exception.

Motivation and Context

  • Why is this change required? What problem does it solve?

From: @pranavsharma
Sent: Friday, November 8, 2019 7:32 PM
Subject: Note about opset forward compatibility in ORT.

Dwayne from the WinML team apprised me of this issue today afternoon. ORT supports opset 11 in 1.0. Let's say the resize op undergoes a change in behavior in opset 12. The schema would be the same, but the behavior would be different (possibly a spec upgrade happened causing it’s behavior to change). Now if a model that is stamped with opset 12 is inferred by ORT (that implements only opset 11), ORT will use the opset 11 implementation of the op since it registered the op as 11->INF. This doesn’t seem correct because we silently pick the wrong op implementation instead of giving an error. If we clamp our op registration with the opset version we're implementing in the release (in this case opset 11), we will (correctly) throw an error for the unimplemented opset 12 resize op.

  • If it fixes an open issue, please link to the issue here.

@snnn
snnn requested a review from a team as a code owner February 6, 2020 00:20
auto domain_map = schema_registry->GetLatestOpsetVersions(false);
for (const auto& domain : domain_map) {
if (domain_to_version.find(domain.first) == domain_to_version.end()) {
auto iter = domain_to_version.find(domain.first);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we plan to consume the latest ONNX commits before the release (and thus taking in partial opset-12 schemas) to develop opset-12 ops and unblock converter testing then the domain to version map from ONNX would return 12 for the ONNX domain. I guess we need to find a way to re-usable mechanism to clamp it to a lower version that ORT claims full support for in a release ? (In this case 11)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It can be solved in the GetLatestOpsetVersions function.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, this PR will disallow opset 12 models from loaded until we update the onnx commit. Once we update onnx, this won't work unless we maintain the opset version we support in a given release somewhere and check against that. While we're in the master branch, we can store opset 12 in this MAX_SUPPORTED_OPSET variable to allow testing of opset 12 op implementations by others. When we cut a release, we should use opset 11 for this variable. Would this work? Is this PR going to address this?

@snnn

snnn commented Feb 6, 2020

Copy link
Copy Markdown
Contributor Author

Looks like we need to revisit the #2413 PR.

auto domain_map = schema_registry->GetLatestOpsetVersions(false);
for (const auto& domain : domain_map) {
if (domain_to_version.find(domain.first) == domain_to_version.end()) {
auto iter = domain_to_version.find(domain.first);

@snnn snnn Feb 6, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The major differ between this change and #2413 is: here it retrieves the domain version mapping from a local schema_registry, which has better support for custom ops and custom registries.

Also, this change covers all the domains, not just onnx domains.

@pranavsharma

Copy link
Copy Markdown
Contributor

Can we add a unit test please?

@snnn snnn closed this Feb 6, 2020
@snnn
snnn deleted the snnn/p10 branch February 6, 2020 19:11
@snnn

snnn commented Feb 6, 2020

Copy link
Copy Markdown
Contributor Author

This change is not needed.

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.

3 participants