microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.56k stars 2.92k forks source link

Is there a Python way to get the max supported ONNX IR version from ORT package? #14932

Open jcwchen opened 1 year ago

jcwchen commented 1 year ago

Describe the issue

ONNX Runtime will throw an error if the given ONNX model has a newer IR version which is not supported by the onnxruntime package yet: https://github.com/microsoft/onnxruntime/blob/f88b97ede272e54d67e7f4da165359df4b534a4a/onnxruntime/core/graph/model.cc#L147-L151

Before bumping into this error, I would like to know the max supported ONNX IR version by my onnxruntime package. Therefore I was wondering that currently is there a Python way to get this max supported ONNX IR version? If no, would it be useful to have this information in onnxruntime Python package?

To reproduce

import onnxruntime
from onnxruntime.datasets import get_example
import onnx

example = get_example("sigmoid.onnx")  # any ONNX model
model = onnx.load(example)
model.ir_version = 9  # unsupported ONNX IR version
onnx.save(model, "test.onnx")
onnxruntime.InferenceSession("test.onnx")

It will show Fail: [ONNXRuntimeError] : 1 : FAIL : Load model from test.onnx failed:D:\a\_work\1\s\onnxruntime\core\graph\model.cc:146 onnxruntime::Model::Model Unsupported model IR version: 9, max supported IR version: 8, which is good.

I am hoping there will be a onnxruntime Python API to get the max supported ONNX IR version like:

onnxruntime.max_supported_onnx_ir

Urgency

No

Platform

Windows

OS Version

Windows 11

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.14.1

ONNX Runtime API

Python

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

fdwr commented 1 year ago

@jcwchen: Do you think it useful to also return the range opset range per EP, given they vary? (e.g. current support here https://github.com/microsoft/onnxruntime/blob/main/docs/OperatorKernels.md)

jcwchen commented 1 year ago

@jcwchen: Do you think it useful to also return the range opset range per EP, given they vary? (e.g. current support here https://github.com/microsoft/onnxruntime/blob/main/docs/OperatorKernels.md)

That sounds useful, especially they are varied.

thiagocrepaldi commented 6 months ago

this is a ort-specific question

lix19937 commented 1 month ago

https://onnxruntime.ai/docs/reference/compatibility.html