# SPDX-License-Identifier: Apache-2.0# Rather than using ONNX protobuf definition throughout our codebase,# we import ONNX protobuf definition here so that we can conduct quick# fixes by overwriting ONNX functions without changing any lines# elsewhere.fromonnximportonnx_pbasonnx_protofromonnximportdefs# Overwrite the make_tensor defined in onnx.helper because of a bug# (string tensor get assigned twice)fromonnx.onnx_pbimportTensorProto,ValueInfoPrototry:# noqa: SIM105fromonnx.onnx_pbimportSparseTensorProtoexceptImportError:# onnx is too old.passdefget_opset_number_from_onnx():""" Returns the latest opset version supported by the *onnx* package. """returndefs.onnx_opset_version()
[docs]defget_latest_tested_opset_version():""" This module relies on *onnxruntime* to test every converter. The function returns the most recent target opset tested with *onnxruntime* or the opset version specified by *onnx* package if this one is lower (return by `onnx.defs.onnx_opset_version()`). """from..import__max_supported_opset__returnmin(__max_supported_opset__,get_opset_number_from_onnx())