Skip to content

Commit

Permalink
Fix for onnx 1.7 release (#381)
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/xgboost/test_xgboost_pipeline.py
  • Loading branch information
wenbingl committed Apr 3, 2020
1 parent 89213bc commit e4dbacc
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions onnxmltools/proto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ def _check_onnx_version():
import pkg_resources
min_required_version = pkg_resources.parse_version('1.0.1')
current_version = pkg_resources.get_distribution('onnx').parsed_version
assert current_version >= min_required_version , 'ONNXMLTools requires ONNX version 1.0.1 or a newer one'
assert current_version >= min_required_version, 'ONNXMLTools requires ONNX version 1.0.1 or a newer one'


_check_onnx_version()

# Rather than using ONNX protobuf definition throughout our codebase, we import ONNX protobuf definition here so that
Expand All @@ -21,6 +23,8 @@ def _check_onnx_version():
from onnx import mapping
from onnx.onnx_pb import TensorProto
from onnx.helper import split_complex_to_pairs


def _make_tensor_fixed(name, data_type, dims, vals, raw=False):
'''
Make a TensorProto with specified arguments. If raw is False, this
Expand Down Expand Up @@ -51,4 +55,13 @@ def _make_tensor_fixed(name, data_type, dims, vals, raw=False):


def get_opset_number_from_onnx():
return onnx.defs.onnx_opset_version()
# since the method was widely used among while it is buggy to get the opset number...
# ... blindly, so change it to be safer without the name change.

default_max_opset = 11
try:
from onnxconverter_common.topology import DEFAULT_OPSET_NUMBER
default_max_opset = DEFAULT_OPSET_NUMBER
except: # noqa
pass
return min(default_max_opset, onnx.defs.onnx_opset_version())

0 comments on commit e4dbacc

Please sign in to comment.