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

Handle inconsistent opset placement in ONNX models #150

Open
pcolange opened this issue Apr 9, 2024 · 0 comments
Open

Handle inconsistent opset placement in ONNX models #150

pcolange opened this issue Apr 9, 2024 · 0 comments

Comments

@pcolange
Copy link
Contributor

pcolange commented Apr 9, 2024

The current opset retrieval function assumes the default opset (ai.onnx) domain is always at the first index as shown below:

def get_opset(model: onnx.ModelProto) -> int:
return getattr(model.opset_import[0], "version", None)

However, some ONNX models may have this domain located elsewhere, leading to incorrect opset identification, for example:

image

Proposed solution:

def get_opset(model: onnx.ModelProto) -> int:
    opset = [x.version for x in model.opset_import if x.domain == ""]
    if opset:
        return opset[0]
    else:
        return None

Note that in the above code snippet x.domain == "" indicates the default domain which is ai.onnx.

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

No branches or pull requests

1 participant