Skip to content

Commit 8ac872b

Browse files
authored
Fixes for onnx==1.11.0 (#527)
* add onnx==1.11.0 * Fixes one unit test involving sklearn-onnx. * use CPUExecutionProvider * remove one unnecessary initializer
1 parent 2f96f95 commit 8ac872b

File tree

9 files changed

+24
-10
lines changed

9 files changed

+24
-10
lines changed

.azure-pipelines/linux-conda-CI.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ jobs:
1414
vmImage: 'ubuntu-latest'
1515
strategy:
1616
matrix:
17+
Python39-1110-RT1100:
18+
python.version: '3.9'
19+
ONNX_PATH: onnx==1.11.0 # '-i https://test.pypi.org/simple/ onnx==1.9.101'
20+
ONNXRT_PATH: onnxruntime==1.10.0
21+
COREML_PATH: git+https://github.com/apple/[email protected]
22+
xgboost.version: '>=1.2'
1723
Python39-1101-RT190:
1824
python.version: '3.9'
19-
ONNX_PATH: onnx==1.10.1 # '-i https://test.pypi.org/simple/ onnx==1.9.101'
25+
ONNX_PATH: onnx==1.10.1
2026
ONNXRT_PATH: onnxruntime==1.9.0
2127
COREML_PATH: git+https://github.com/apple/[email protected]
2228
xgboost.version: '>=1.2'

.azure-pipelines/win32-conda-CI.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,15 @@ jobs:
1414
vmImage: 'windows-latest'
1515
strategy:
1616
matrix:
17-
Python39-1101-RT190:
17+
Python39-1110-RT190:
1818
python.version: '3.9'
19-
ONNX_PATH: 'onnx==1.10.1' # '-i https://test.pypi.org/simple/ onnx==1.9.101'
19+
ONNX_PATH: 'onnx==1.11.0' # '-i https://test.pypi.org/simple/ onnx==1.9.101'
20+
ONNXRT_PATH: onnxruntime==1.10.0
21+
COREML_PATH: git+https://github.com/apple/[email protected]
22+
23+
Python39-1102-RT190:
24+
python.version: '3.9'
25+
ONNX_PATH: 'onnx==1.10.2' # '-i https://test.pypi.org/simple/ onnx==1.9.101'
2026
ONNXRT_PATH: onnxruntime==1.9.0
2127
COREML_PATH: git+https://github.com/apple/[email protected]
2228

onnxmltools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
This framework converts any machine learned model into onnx format
66
which is a common language to describe any machine learned model.
77
"""
8-
__version__ = "1.10.0"
8+
__version__ = "1.11.0"
99
__author__ = "Microsoft"
1010
__producer__ = "OnnxMLTools"
1111
__producer_version__ = __version__

onnxmltools/convert/sparkml/operator_converters/word2vec.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ def convert_word2vec(scope, operator, container):
2828
container.add_initializer(one, onnx_proto.TensorProto.INT64, [1], [1])
2929
zero = scope.get_unique_variable_name('zero_tensor')
3030
container.add_initializer(zero, onnx_proto.TensorProto.INT64, [1], [0])
31-
word_count_tensor = scope.get_unique_variable_name('word_count_tensor')
32-
container.add_initializer(word_count_tensor, onnx_proto.TensorProto.INT64, [1], [word_count])
3331

3432
sliced_outputs = []
3533
for i in range(0, word_count):

tests/lightgbm/test_LightGbmTreeEnsembleConvertersPkl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
TARGET_OPSET = min(DEFAULT_OPSET_NUMBER, onnx_opset_version())
1919

20+
ort_version = ".".join(onnxruntime.__version__.split('.')[:2])
21+
2022

2123
class TestLightGbmTreeEnsembleModelsPkl(unittest.TestCase):
2224

@@ -37,7 +39,7 @@ def test_root_leave(self):
3739
@unittest.skipIf(sys.platform.startswith('lin'), reason="recover linux CI build, needs to be fixed")
3840
@unittest.skipIf(not hummingbird_installed(), reason="Hummingbird is not installed")
3941
@unittest.skipIf(
40-
StrictVersion(onnxruntime.__version__) < StrictVersion('1.0.0'), reason="Hummingbird supports only latest versions of ORT"
42+
StrictVersion(ort_version) < StrictVersion('1.0.0'), reason="Hummingbird supports only latest versions of ORT"
4143
)
4244
def test_root_leave_onnx_only(self):
4345
this = os.path.abspath(os.path.dirname(__file__))

tests/lightgbm/test_LightGbmTreeEnsembleConverters_split.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323

2424
TARGET_OPSET = min(DEFAULT_OPSET_NUMBER, onnx_opset_version())
25+
ort_version = ".".join(ort_version.split('.')[:2])
2526

2627

2728
class TestLightGbmTreeEnsembleModelsSplit(unittest.TestCase):

tests/lightgbm/test_objective_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def _assert_almost_equal(actual: np.array, desired: np.array, decimal: int=7, fr
7171
success_rel = success_abs / len(actual)
7272
assert success_rel >= frac, f"Only {success_abs} out of {len(actual)} rows are almost equal to {decimal} decimals."
7373

74-
@unittest.skipIf(tuple(int(ver) for ver in onnxruntime.__version__.split(".")) < (1, 3), "not supported in this library version")
74+
@unittest.skipIf(tuple(int(ver) for ver in onnxruntime.__version__.split(".")[:2]) < (1, 3), "not supported in this library version")
7575
def test_objective(self):
7676
"""
7777
Test if a LGBMRegressor a with certain objective (e.g. 'poisson') can be converted to ONNX

tests/sparkml/sparkml_test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def save_data_models(input, expected, model, onnx_model, basename="model", folde
7171

7272

7373
def run_onnx_model(output_names, input, onnx_model):
74-
sess = onnxruntime.InferenceSession(onnx_model)
74+
sess = onnxruntime.InferenceSession(onnx_model, providers=['CPUExecutionProvider'])
7575
if isinstance(input, dict):
7676
inputs = input
7777
elif isinstance(input, list):

tests/xgboost/test_xgboost_pipeline.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535

3636
TARGET_OPSET = min(DEFAULT_OPSET_NUMBER, onnx_opset_version())
37+
TARGET_OPSET_ML = 2
3738

3839

3940
@unittest.skipIf(sys.version_info[:2] <= (3, 5), reason="not available")
@@ -134,7 +135,7 @@ def common_test_xgboost_10_skl(self, missing, replace=False):
134135
input_xgb[input_xgb[:, :] == missing] = np.nan
135136
onnx_last = convert_sklearn(model.steps[1][-1],
136137
initial_types=[('X', FloatTensorType(shape=[None, input_xgb.shape[1]]))],
137-
target_opset=TARGET_OPSET)
138+
target_opset={'': TARGET_OPSET, 'ai.onnx.ml': TARGET_OPSET_ML})
138139
session = rt.InferenceSession(onnx_last.SerializeToString())
139140
pred_skl = model.steps[1][-1].predict(input_xgb).ravel()
140141
pred_onx = session.run(None, {'X': input_xgb})[0].ravel()

0 commit comments

Comments
 (0)