From 1093838fc17b059699e58ae4f15893b2c5c00800 Mon Sep 17 00:00:00 2001 From: xadupre Date: Mon, 16 Jan 2023 17:28:54 +0100 Subject: [PATCH 01/18] Update CI with latext onnxruntime, xgboost Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 10 ++++++++-- .azure-pipelines/win32-conda-CI.yml | 6 ++++++ onnxmltools/utils/utils_backend_onnxruntime.py | 4 ++-- tests/xgboost/test_xgboost_13.py | 2 +- tests/xgboost/test_xgboost_converters.py | 12 ++++++------ tests/xgboost/test_xgboost_pipeline.py | 2 +- 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index 94547e89..11f10f3d 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -14,12 +14,18 @@ jobs: vmImage: 'ubuntu-latest' strategy: matrix: + Python310-1130-RT1131-xgb173: + python.version: '3.10' + ONNX_PATH: 'onnx==1.13.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' + ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' + COREML_PATH: git+https://github.com/apple/coremltools@3.1 + xgboost.version: '>=1.7.3' Python310-1120-RT1121-xgb161: - python.version: '3.9' + python.version: '3.10' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.12.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: git+https://github.com/apple/coremltools@3.1 - xgboost.version: '>=1.6.1' + xgboost.version: '==1.6.1' Python39-1120-RT1110-xgb161: python.version: '3.9' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index 128e7789..57f1d8f6 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -15,6 +15,12 @@ jobs: strategy: matrix: + Python310-1130-RT1131: + python.version: '3.10' + ONNX_PATH: 'onnx==1.13.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' + ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' + COREML_PATH: git+https://github.com/apple/coremltools@3.1 + Python39-1120-RT1110: python.version: '3.9' ONNX_PATH: 'onnx==1.12.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' diff --git a/onnxmltools/utils/utils_backend_onnxruntime.py b/onnxmltools/utils/utils_backend_onnxruntime.py index 74622069..bb755a78 100644 --- a/onnxmltools/utils/utils_backend_onnxruntime.py +++ b/onnxmltools/utils/utils_backend_onnxruntime.py @@ -52,7 +52,7 @@ def compare_runtime(test, decimal=5, options=None, verbose=False, context=None): return try: - sess = onnxruntime.InferenceSession(onx) + sess = onnxruntime.InferenceSession(onx, providers=["CPUExecutionProvider"]) except ExpectedAssertionError as expe: raise expe except Exception as e: @@ -312,7 +312,7 @@ def run_with_runtime(inputs, model_path): ''' try: import onnxruntime - session = onnxruntime.InferenceSession(model_path) + session = onnxruntime.InferenceSession(model_path, providers=["CPUExecutionProvider"]) output = session.run(None, inputs) return (output, session) except Exception as e: diff --git a/tests/xgboost/test_xgboost_13.py b/tests/xgboost/test_xgboost_13.py index ef599aef..ac877a57 100644 --- a/tests/xgboost/test_xgboost_13.py +++ b/tests/xgboost/test_xgboost_13.py @@ -41,7 +41,7 @@ def test_xgb_regressor(self): initial_type = [('float_input', FloatTensorType([None, 797]))] onx = convert_xgboost(clr, initial_types=initial_type, target_opset=TARGET_OPSET) expected = clr.predict(X_test), clr.predict_proba(X_test) - sess = InferenceSession(onx.SerializeToString()) + sess = InferenceSession(onx.SerializeToString(), providers=["CPUExecutionProvider"]) X_test = X_test.values.astype(np.float32) got = sess.run(None, {'float_input': X_test}) assert_almost_equal(expected[1], got[1]) diff --git a/tests/xgboost/test_xgboost_converters.py b/tests/xgboost/test_xgboost_converters.py index 21e40eba..5af6c3f6 100644 --- a/tests/xgboost/test_xgboost_converters.py +++ b/tests/xgboost/test_xgboost_converters.py @@ -235,7 +235,7 @@ def test_xgboost_classifier_i5450_softmax(self): clr.fit(X_train, y_train, eval_set=[(X_test, y_test)], early_stopping_rounds=40) initial_type = [('float_input', FloatTensorType([None, 4]))] onx = convert_xgboost(clr, initial_types=initial_type, target_opset=TARGET_OPSET) - sess = InferenceSession(onx.SerializeToString()) + sess = InferenceSession(onx.SerializeToString(), providers=["CPUExecutionProvider"]) input_name = sess.get_inputs()[0].name label_name = sess.get_outputs()[1].name predict_list = [1., 20., 466., 0.] @@ -255,7 +255,7 @@ def test_xgboost_classifier_i5450(self): clr.fit(X_train, y_train, eval_set=[(X_test, y_test)], early_stopping_rounds=40) initial_type = [('float_input', FloatTensorType([None, 4]))] onx = convert_xgboost(clr, initial_types=initial_type, target_opset=TARGET_OPSET) - sess = InferenceSession(onx.SerializeToString()) + sess = InferenceSession(onx.SerializeToString(), providers=["CPUExecutionProvider"]) input_name = sess.get_inputs()[0].name label_name = sess.get_outputs()[1].name predict_list = [1., 20., 466., 0.] @@ -304,7 +304,7 @@ def test_xgb_empty_tree(self): xgb, initial_types=[ ('input', FloatTensorType(shape=[None, X.shape[1]]))], target_opset=TARGET_OPSET) - sess = InferenceSession(conv_model.SerializeToString()) + sess = InferenceSession(conv_model.SerializeToString(), providers=["CPUExecutionProvider"]) res = sess.run(None, {'input': X.astype(np.float32)}) assert_almost_equal(xgb.predict_proba(X), res[1]) assert_almost_equal(xgb.predict(X), res[0]) @@ -325,7 +325,7 @@ def test_xgb_best_tree_limit(self): onx_loaded = convert_xgboost( bst_original, initial_types=initial_type, target_opset=TARGET_OPSET) - sess = InferenceSession(onx_loaded.SerializeToString()) + sess = InferenceSession(onx_loaded.SerializeToString(), providers=["CPUExecutionProvider"]) res = sess.run(None, {'float_input': X_test.astype(np.float32)}) assert_almost_equal(bst_original.predict(dtest, output_margin=True), res[1], decimal=5) assert_almost_equal(bst_original.predict(dtest), res[0]) @@ -342,7 +342,7 @@ def test_xgb_best_tree_limit(self): onx_loaded = convert_xgboost( bst_loaded, initial_types=initial_type, target_opset=TARGET_OPSET) - sess = InferenceSession(onx_loaded.SerializeToString()) + sess = InferenceSession(onx_loaded.SerializeToString(), providers=["CPUExecutionProvider"]) res = sess.run(None, {'float_input': X_test.astype(np.float32)}) assert_almost_equal(bst_loaded.predict(dtest, output_margin=True), res[1], decimal=5) assert_almost_equal(bst_loaded.predict(dtest), res[0]) @@ -364,7 +364,7 @@ def test_onnxrt_python_xgbclassifier(self): model_skl, initial_types=[('X', FloatTensorType([None, x.shape[1]]))], target_opset=TARGET_OPSET) with self.subTest(base_score=bm, n_estimators=n_est): - oinf = InferenceSession(model_onnx_skl.SerializeToString()) + oinf = InferenceSession(model_onnx_skl.SerializeToString(), providers=["CPUExecutionProvider"]) res2 = oinf.run(None, {'X': x_test}) assert_almost_equal(model_skl.predict_proba(x_test), res2[1]) diff --git a/tests/xgboost/test_xgboost_pipeline.py b/tests/xgboost/test_xgboost_pipeline.py index 64bd81a0..4a3d62d7 100644 --- a/tests/xgboost/test_xgboost_pipeline.py +++ b/tests/xgboost/test_xgboost_pipeline.py @@ -136,7 +136,7 @@ def common_test_xgboost_10_skl(self, missing, replace=False): onnx_last = convert_sklearn(model.steps[1][-1], initial_types=[('X', FloatTensorType(shape=[None, input_xgb.shape[1]]))], target_opset={'': TARGET_OPSET, 'ai.onnx.ml': TARGET_OPSET_ML}) - session = rt.InferenceSession(onnx_last.SerializeToString()) + session = rt.InferenceSession(onnx_last.SerializeToString(), providers=["CPUExecutionProvider"]) pred_skl = model.steps[1][-1].predict(input_xgb).ravel() pred_onx = session.run(None, {'X': input_xgb})[0].ravel() assert_almost_equal(pred_skl, pred_onx) From c1414233942011250aac43885c3e594499a45842 Mon Sep 17 00:00:00 2001 From: xadupre Date: Mon, 16 Jan 2023 18:08:23 +0100 Subject: [PATCH 02/18] add one unit test for issue 601 Signed-off-by: xadupre --- tests/xgboost/test_xgboost_converters.py | 114 ++++++++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/tests/xgboost/test_xgboost_converters.py b/tests/xgboost/test_xgboost_converters.py index 5af6c3f6..c9dea27a 100644 --- a/tests/xgboost/test_xgboost_converters.py +++ b/tests/xgboost/test_xgboost_converters.py @@ -9,7 +9,7 @@ from numpy.testing import assert_almost_equal import pandas from sklearn.datasets import ( - load_diabetes, load_iris, make_classification, load_digits) + load_diabetes, load_iris, make_classification, load_digits, make_regression) from sklearn.model_selection import train_test_split from xgboost import XGBRegressor, XGBClassifier, train, DMatrix, Booster, train as train_xgb from sklearn.preprocessing import StandardScaler @@ -24,6 +24,20 @@ TARGET_OPSET = min(DEFAULT_OPSET_NUMBER, onnx_opset_version()) +def fct_cl2(y): + y[y == 2] = 0 + return y + + +def fct_cl3(y): + y[y == 0] = 6 + return y + + +def fct_id(y): + return y + + def _fit_classification_model(model, n_classes, is_str=False, dtype=None): x, y = make_classification(n_classes=n_classes, n_features=100, n_samples=1000, @@ -368,7 +382,103 @@ def test_onnxrt_python_xgbclassifier(self): res2 = oinf.run(None, {'X': x_test}) assert_almost_equal(model_skl.predict_proba(x_test), res2[1]) + def test_xgb_cost(self): + obj_classes = { + 'reg:logistic': (XGBClassifier, fct_cl2, + make_classification(n_features=4, n_classes=2, + n_clusters_per_class=1)), + 'binary:logistic': (XGBClassifier, fct_cl2, + make_classification(n_features=4, n_classes=2, + n_clusters_per_class=1)), + 'multi:softmax': (XGBClassifier, fct_id, + make_classification(n_features=4, n_classes=3, + n_clusters_per_class=1)), + 'multi:softprob': (XGBClassifier, fct_id, + make_classification(n_features=4, n_classes=3, + n_clusters_per_class=1)), + 'reg:squarederror': (XGBRegressor, fct_id, + make_regression(n_features=4, n_targets=1)), + 'reg:squarederror2': (XGBRegressor, fct_id, + make_regression(n_features=4, n_targets=2)), + } + nb_tests = 0 + for objective in obj_classes: # pylint: disable=C0206 + for n_estimators in [1, 2]: + with self.subTest(objective=objective, n_estimators=n_estimators): + probs = [] + cl, fct, prob = obj_classes[objective] + + iris = load_iris() + X, y = iris.data, iris.target + y = fct(y) + X_train, X_test, y_train, _ = train_test_split( + X, y, random_state=11) + probs.append((X_train, X_test, y_train)) + + X_train, X_test, y_train, _ = train_test_split( + *prob, random_state=11) + probs.append((X_train, X_test, y_train)) + + for X_train, X_test, y_train in probs: + obj = objective.replace( + 'reg:squarederror2', 'reg:squarederror') + obj = obj.replace( + 'multi:softmax2', 'multi:softmax') + clr = cl(objective=obj, n_estimators=n_estimators) + if len(y_train.shape) == 2: + y_train = y_train[:, 1] + try: + clr.fit(X_train, y_train) + except ValueError as e: + raise AssertionError( + "Unable to train with objective %r and data %r." % ( + objective, y_train)) from e + + model_def = convert_xgboost( + clr, initial_types=[('X', FloatTensorType([None, X.shape[1]]))], + target_opset=TARGET_OPSET) + + oinf = InferenceSession(model_def.SerializeToString(), + providers=["CPUExecutionProvider"]) + y = oinf.run(None, {'X': X_test.astype(np.float32)}) + if cl == XGBRegressor: + exp = clr.predict(X_test) + assert_almost_equal(exp, y[0].ravel(), decimal=5) + else: + if 'softmax' not in obj: + exp = clr.predict_proba(X_test) + got = pandas.DataFrame(y[1]).values + assert_almost_equal(exp, got, decimal=5) + + exp = clr.predict(X_test[:10]) + assert_almost_equal(exp, y[0][:10]) + + nb_tests += 1 + + self.assertGreater(nb_tests, 8) + + def test_xgb_classifier_601(self): + model = XGBClassifier( + base_score=0.5, booster='gbtree', colsample_bylevel=1, + colsample_bynode=1, colsample_bytree=1, gamma=0, + importance_type='gain', interaction_constraints='', + learning_rate=0.3, max_delta_step=0, max_depth=6, + min_child_weight=1, missing=np.nan, + n_estimators=3, n_jobs=0, num_parallel_tree=1, + objective='multi:softprob', random_state=0, reg_alpha=0, + reg_lambda=1, scale_pos_weight=None, subsample=1, + tree_method='exact', validate_parameters=1) + xgb, x_test = _fit_classification_model(model, 3) + conv_model = convert_xgboost( + xgb, initial_types=[('input', FloatTensorType(shape=[None, None]))], + target_opset=TARGET_OPSET) + self.assertTrue(conv_model is not None) + dump_data_and_model( + x_test, xgb, conv_model, + basename="SklearnXGBClassifier601") + + if __name__ == "__main__": # TestXGBoostModels().test_xgboost_booster_classifier_multiclass_softprob() - unittest.main() + unittest.main(verbosity=2) From 415786ee1e38e60299faf262351ff160c08ed818 Mon Sep 17 00:00:00 2001 From: xadupre Date: Mon, 16 Jan 2023 18:20:18 +0100 Subject: [PATCH 03/18] fix iterable Signed-off-by: xadupre --- .../sparkml/operator_converters/aft_survival_regression.py | 5 ++++- .../convert/sparkml/operator_converters/linear_regressor.py | 6 ++++-- onnxmltools/proto/__init__.py | 5 +---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/onnxmltools/convert/sparkml/operator_converters/aft_survival_regression.py b/onnxmltools/convert/sparkml/operator_converters/aft_survival_regression.py index 5ae267ec..c1e4512d 100644 --- a/onnxmltools/convert/sparkml/operator_converters/aft_survival_regression.py +++ b/onnxmltools/convert/sparkml/operator_converters/aft_survival_regression.py @@ -15,7 +15,10 @@ def convert_aft_survival_regression(scope, operator, container): coefficients = op.coefficients.toArray().astype(float) coefficients_tensor = scope.get_unique_variable_name('coefficients_tensor') container.add_initializer(coefficients_tensor, onnx_proto.TensorProto.FLOAT, [1, len(coefficients)], coefficients) - intercepts = op.intercept.astype(float) if isinstance(op.intercept, collections.Iterable) else [float(op.intercept)] + intercepts = ( + op.intercept.astype(float) + if isinstance(op.intercept, collections.abc.Iterable) + else [float(op.intercept)]) intercepts_tensor = scope.get_unique_variable_name('intercepts_tensor') container.add_initializer(intercepts_tensor, onnx_proto.TensorProto.FLOAT, [len(intercepts)], intercepts) diff --git a/onnxmltools/convert/sparkml/operator_converters/linear_regressor.py b/onnxmltools/convert/sparkml/operator_converters/linear_regressor.py index d5b65e59..bf09b9aa 100644 --- a/onnxmltools/convert/sparkml/operator_converters/linear_regressor.py +++ b/onnxmltools/convert/sparkml/operator_converters/linear_regressor.py @@ -13,8 +13,10 @@ def convert_sparkml_linear_regressor(scope, operator, container): attrs = { 'name': scope.get_unique_operator_name(op_type), 'coefficients': op.coefficients.astype(float), - 'intercepts': op.intercept.astype(float) if isinstance(op.intercept, collections.Iterable) else [ - float(op.intercept)] + 'intercepts': ( + op.intercept.astype(float) + if isinstance(op.intercept, collections.abc.Iterable) + else [float(op.intercept)]) } container.add_node(op_type, operator.input_full_names, operator.output_full_names, op_domain='ai.onnx.ml', **attrs) diff --git a/onnxmltools/proto/__init__.py b/onnxmltools/proto/__init__.py index 009252ba..ff24c446 100644 --- a/onnxmltools/proto/__init__.py +++ b/onnxmltools/proto/__init__.py @@ -21,7 +21,7 @@ def _check_onnx_version(): _check_onnx_version() -def _make_tensor_fixed(name, data_type, dims, vals, raw=False): +def make_tensor_fixed(name, data_type, dims, vals, raw=False): ''' Make a TensorProto with specified arguments. If raw is False, this function will choose the corresponding proto field to store the @@ -45,6 +45,3 @@ def _make_tensor_fixed(name, data_type, dims, vals, raw=False): tensor.dims.extend(dims) return tensor - - -helper.make_tensor = _make_tensor_fixed From e948b5c2aac0d0926ab4907f1a786382247aad23 Mon Sep 17 00:00:00 2001 From: xadupre Date: Mon, 16 Jan 2023 18:38:23 +0100 Subject: [PATCH 04/18] fix .str_ Signed-off-by: xadupre --- tests/h2o/test_h2o_converters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/h2o/test_h2o_converters.py b/tests/h2o/test_h2o_converters.py index 5c3825ae..713cfa11 100644 --- a/tests/h2o/test_h2o_converters.py +++ b/tests/h2o/test_h2o_converters.py @@ -91,7 +91,7 @@ def _prepare_one_hot(file, y, exclude_cols=None): def _train_test_split_as_frames(x, y, is_str=False, is_classifier=False): - y = y.astype(np.str) if is_str else y.astype(np.int64) + y = y.astype(np.str_) if is_str else y.astype(np.int64) x_train, x_test, y_train, _ = train_test_split(x, y, test_size=0.3, random_state=42) f_train_x = H2OFrame(x_train) f_train_y = H2OFrame(y_train) From af8f885fe8d5d09e0d906f6e569ce8c9b335214c Mon Sep 17 00:00:00 2001 From: xadupre Date: Mon, 16 Jan 2023 19:20:39 +0100 Subject: [PATCH 05/18] hinge Signed-off-by: xadupre --- onnxmltools/convert/xgboost/convert.py | 9 ++++ .../xgboost/operator_converters/XGBoost.py | 46 ++++++++++++++----- tests/xgboost/test_xgboost_converters.py | 14 +++++- 3 files changed, 57 insertions(+), 12 deletions(-) diff --git a/onnxmltools/convert/xgboost/convert.py b/onnxmltools/convert/xgboost/convert.py index 0592550e..debc05c2 100644 --- a/onnxmltools/convert/xgboost/convert.py +++ b/onnxmltools/convert/xgboost/convert.py @@ -41,4 +41,13 @@ def convert(model, name=None, initial_types=None, doc_string='', target_opset=No topology = parse_xgboost(model, initial_types, target_opset, custom_conversion_functions, custom_shape_calculators) topology.compile() onnx_model = convert_topology(topology, name, doc_string, target_opset, targeted_onnx) + opsets = {d.domain: d.version for d in onnx_model.opset_import} + if '' in opsets and opsets[''] < 9 and target_opset >= 9: + # a bug? + opsets[''] = 9 + del onnx_model.opset_import[:] + for k, v in opsets.items(): + opset = onnx_model.opset_import.add() + opset.domain = k + opset.version = v return onnx_model diff --git a/onnxmltools/convert/xgboost/operator_converters/XGBoost.py b/onnxmltools/convert/xgboost/operator_converters/XGBoost.py index eebe9b2f..2f483286 100644 --- a/onnxmltools/convert/xgboost/operator_converters/XGBoost.py +++ b/onnxmltools/convert/xgboost/operator_converters/XGBoost.py @@ -2,6 +2,7 @@ import json import numpy as np +from onnx import TensorProto from xgboost import XGBClassifier from ...common._registration import register_converter from ..common import get_xgb_params @@ -241,14 +242,17 @@ def convert(scope, operator, container): raise RuntimeError("XGBoost model is empty.") if ncl <= 1: ncl = 2 - # See https://github.com/dmlc/xgboost/blob/master/src/common/math.h#L23. - attr_pairs['post_transform'] = "LOGISTIC" - attr_pairs['class_ids'] = [0 for v in attr_pairs['class_treeids']] - if js_trees[0].get('leaf', None) == 0: - attr_pairs['base_values'] = [0.5] - elif base_score != 0.5: - cst = - np.log(1 / np.float32(base_score) - 1.) - attr_pairs['base_values'] = [cst] + if objective == 'binary:logistic': + # See https://github.com/dmlc/xgboost/blob/master/src/common/math.h#L23. + attr_pairs['post_transform'] = "LOGISTIC" + attr_pairs['class_ids'] = [0 for v in attr_pairs['class_treeids']] + if js_trees[0].get('leaf', None) == 0: + attr_pairs['base_values'] = [0.5] + elif base_score != 0.5: + cst = - np.log(1 / np.float32(base_score) - 1.) + attr_pairs['base_values'] = [cst] + else: + attr_pairs['base_values'] = [base_score] else: # See https://github.com/dmlc/xgboost/blob/master/src/common/math.h#L35. attr_pairs['post_transform'] = "SOFTMAX" @@ -264,13 +268,33 @@ def convert(scope, operator, container): attr_pairs['classlabels_strings'] = classes # add nodes - if objective == "binary:logistic": + if objective in ("binary:logistic", "binary:hinge"): ncl = 2 - container.add_node('TreeEnsembleClassifier', operator.input_full_names, - operator.output_full_names, + if objective == "binary:hinge": + attr_pairs['post_transform'] = 'NONE' + output_names = [operator.output_full_names[0], + scope.get_unique_variable_name("output_prob")] + else: + output_names = operator.output_full_names + container.add_node('TreeEnsembleClassifier', + operator.input_full_names, + output_names, op_domain='ai.onnx.ml', name=scope.get_unique_operator_name('TreeEnsembleClassifier'), **attr_pairs) + if objective == "binary:hinge": + if container.target_opset < 9: + raise RuntimeError( + f"hinge function cannot be implemented because " + f"opset={container.target_opset}<9.") + zero = scope.get_unique_variable_name("zero") + one = scope.get_unique_variable_name("one") + container.add_initializer(zero, TensorProto.FLOAT, [1], [0.]) + container.add_initializer(one, TensorProto.FLOAT, [1], [1.]) + greater = scope.get_unique_variable_name("output_prob") + container.add_node("Greater", [output_names[1], zero], [greater]) + container.add_node('Where', [greater, one, zero], + operator.output_full_names[1]) elif objective in ("multi:softprob", "multi:softmax"): ncl = len(js_trees) // params['n_estimators'] if objective == 'multi:softmax': diff --git a/tests/xgboost/test_xgboost_converters.py b/tests/xgboost/test_xgboost_converters.py index c9dea27a..9845c1e0 100644 --- a/tests/xgboost/test_xgboost_converters.py +++ b/tests/xgboost/test_xgboost_converters.py @@ -42,7 +42,7 @@ def _fit_classification_model(model, n_classes, is_str=False, dtype=None): x, y = make_classification(n_classes=n_classes, n_features=100, n_samples=1000, random_state=42, n_informative=7) - y = y.astype(np.str) if is_str else y.astype(np.int64) + y = y.astype(np.str_) if is_str else y.astype(np.int64) x_train, x_test, y_train, _ = train_test_split(x, y, test_size=0.5, random_state=42) if dtype is not None: @@ -477,6 +477,18 @@ def test_xgb_classifier_601(self): x_test, xgb, conv_model, basename="SklearnXGBClassifier601") + def test_xgb_classifier_hinge(self): + model = XGBClassifier( + n_estimators=3, objective='binary:hinge', random_state=0, + max_depth=2) + xgb, x_test = _fit_classification_model(model, 2) + conv_model = convert_xgboost( + xgb, initial_types=[('input', FloatTensorType(shape=[None, None]))], + target_opset=TARGET_OPSET) + dump_data_and_model( + x_test, xgb, conv_model, + basename="SklearnXGBClassifierHinge") + if __name__ == "__main__": From 87f78b5f1f3a2799164bafde6ab335bf90fff36e Mon Sep 17 00:00:00 2001 From: xadupre Date: Mon, 16 Jan 2023 19:23:23 +0100 Subject: [PATCH 06/18] fix hinge Signed-off-by: xadupre --- onnxmltools/convert/xgboost/operator_converters/XGBoost.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/onnxmltools/convert/xgboost/operator_converters/XGBoost.py b/onnxmltools/convert/xgboost/operator_converters/XGBoost.py index 2f483286..4ae246ab 100644 --- a/onnxmltools/convert/xgboost/operator_converters/XGBoost.py +++ b/onnxmltools/convert/xgboost/operator_converters/XGBoost.py @@ -242,7 +242,7 @@ def convert(scope, operator, container): raise RuntimeError("XGBoost model is empty.") if ncl <= 1: ncl = 2 - if objective == 'binary:logistic': + if objective != 'binary:hinge': # See https://github.com/dmlc/xgboost/blob/master/src/common/math.h#L23. attr_pairs['post_transform'] = "LOGISTIC" attr_pairs['class_ids'] = [0 for v in attr_pairs['class_treeids']] From d715311c35688d6e224f162e476af9f87f48dee6 Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 17 Jan 2023 10:58:18 +0100 Subject: [PATCH 07/18] fix str Signed-off-by: xadupre --- tests/h2o/test_h2o_converters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/h2o/test_h2o_converters.py b/tests/h2o/test_h2o_converters.py index 713cfa11..a4d8a214 100644 --- a/tests/h2o/test_h2o_converters.py +++ b/tests/h2o/test_h2o_converters.py @@ -138,7 +138,7 @@ def predict_with_probabilities(self, data): return [preds.to_numpy()] else: return [ - preds.iloc[:, 0].to_numpy().astype(np.str), + preds.iloc[:, 0].to_numpy().astype(np.str_), preds.iloc[:, 1:].to_numpy() ] From cef3119f26060fcd8eec80682fad74c72a333360 Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 17 Jan 2023 11:31:22 +0100 Subject: [PATCH 08/18] update CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 5 +++-- .azure-pipelines/win32-conda-CI.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index 11f10f3d..7e896599 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -18,7 +18,7 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: git+https://github.com/apple/coremltools@3.1 + COREML_PATH: '' xgboost.version: '>=1.7.3' Python310-1120-RT1121-xgb161: python.version: '3.10' @@ -155,7 +155,7 @@ jobs: displayName: 'pytest - h2o' - script: | - pip install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html + pip install torch --extra-index-url https://download.pytorch.org/whl/cpu pip install hummingbird-ml --no-deps displayName: 'Install hummingbird-ml' @@ -168,6 +168,7 @@ jobs: export PYTHONPATH=. pytest tests/coreml --durations=0 displayName: 'pytest - coreml' + condition: not(eq('$(python.version)', '3.10')) - task: PublishTestResults@2 inputs: diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index 57f1d8f6..01e6d375 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -19,7 +19,7 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: git+https://github.com/apple/coremltools@3.1 + COREML_PATH: '' Python39-1120-RT1110: python.version: '3.9' @@ -93,6 +93,7 @@ jobs: call activate py$(python.version) python -m pip install %COREML_PATH% displayName: 'Install coremltools' + condition: not(eq('$(python.version)', '3.10')) - script: | call activate py$(python.version) @@ -166,7 +167,7 @@ jobs: - script: | call activate py$(python.version) - python -m pip install torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html + python -m pip install torch python -m pip install hummingbird-ml --no-deps displayName: 'Install hummingbird-ml' From 665bcb08c5f98da63883650d796e8493fcc9388b Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 17 Jan 2023 12:22:43 +0100 Subject: [PATCH 09/18] fix yml Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index 7e896599..b4e35a88 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -91,7 +91,6 @@ jobs: pip install xgboost$(xgboost.version) pip install $(ONNX_PATH) pip install $(ONNXRT_PATH) - pip install $(COREML_PATH) displayName: 'Install xgboost, onnxruntime' - script: | @@ -166,6 +165,7 @@ jobs: - script: | export PYTHONPATH=. + pip install $(COREML_PATH) pytest tests/coreml --durations=0 displayName: 'pytest - coreml' condition: not(eq('$(python.version)', '3.10')) From 6a8ce9a932207ea8f87f1ca6d69f7f59f29f5670 Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 17 Jan 2023 15:11:38 +0100 Subject: [PATCH 10/18] fix coreml issue Signed-off-by: xadupre --- tests/baseline/test_convert_baseline.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/baseline/test_convert_baseline.py b/tests/baseline/test_convert_baseline.py index 962e8529..ddabacac 100644 --- a/tests/baseline/test_convert_baseline.py +++ b/tests/baseline/test_convert_baseline.py @@ -9,7 +9,10 @@ from onnx.defs import onnx_opset_version from onnxmltools.convert import convert_coreml from onnxconverter_common.onnx_ex import DEFAULT_OPSET_NUMBER -import coremltools +try: + import coremltools +except ImportError: + coremltools = None TARGET_OPSET = min(DEFAULT_OPSET_NUMBER, onnx_opset_version()) @@ -24,6 +27,8 @@ def check_baseline(self, input_file, ref_file): def get_diff(self, input_file, ref_file): this = os.path.dirname(__file__) coreml_file = os.path.join(this, "models", input_file) + if coremltools is None: + return [] cml = coremltools.utils.load_spec(coreml_file) onnx_model = convert_coreml(cml, target_opset=TARGET_OPSET) output_dir = os.path.join(this, "outmodels") From ff371d9030eea21e77c0eb21fd7a8d2ddb0ca6b7 Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 17 Jan 2023 19:24:32 +0100 Subject: [PATCH 11/18] update CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 12 +++++++++++- .azure-pipelines/win32-conda-CI.yml | 17 +++++++++++------ 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index b4e35a88..3cd33ee6 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -20,53 +20,62 @@ jobs: ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: '' xgboost.version: '>=1.7.3' + numpy.version: '' Python310-1120-RT1121-xgb161: python.version: '3.10' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.12.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: git+https://github.com/apple/coremltools@3.1 xgboost.version: '==1.6.1' + numpy.version: '' Python39-1120-RT1110-xgb161: python.version: '3.9' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.11.0 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: git+https://github.com/apple/coremltools@3.1 xgboost.version: '>=1.6.1' + numpy.version: '' Python39-1120-RT1110-xgb142: python.version: '3.9' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.11.0 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: git+https://github.com/apple/coremltools@3.1 xgboost.version: '==1.4.2' + numpy.version: '' Python39-1110-RT1110: python.version: '3.9' ONNX_PATH: onnx==1.11.0 # '-i https://test.pypi.org/simple/ onnx==1.9.101' ONNXRT_PATH: onnxruntime==1.11.0 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '' Python39-1110-RT1100: python.version: '3.9' ONNX_PATH: onnx==1.11.0 # '-i https://test.pypi.org/simple/ onnx==1.9.101' ONNXRT_PATH: onnxruntime==1.10.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 xgboost.version: '>=1.2' + numpy.version: '' Python39-1101-RT190: python.version: '3.9' ONNX_PATH: onnx==1.10.1 ONNXRT_PATH: onnxruntime==1.9.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 xgboost.version: '>=1.2' + numpy.version: '<=1.23.5' Python39-190-RT180-xgb11: python.version: '3.9' ONNX_PATH: onnx==1.9.0 ONNXRT_PATH: onnxruntime==1.8.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 xgboost.version: '>=1.2' + numpy.version: '<=1.23.5' Python38-181-RT170-xgb11: python.version: '3.8' ONNX_PATH: onnx==1.8.1 ONNXRT_PATH: onnxruntime==1.7.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 xgboost.version: '>=1.2' + numpy.version: '<=1.23.5' maxParallel: 3 @@ -91,6 +100,7 @@ jobs: pip install xgboost$(xgboost.version) pip install $(ONNX_PATH) pip install $(ONNXRT_PATH) + pip install "numpy$(numpy.version)" displayName: 'Install xgboost, onnxruntime' - script: | @@ -168,7 +178,7 @@ jobs: pip install $(COREML_PATH) pytest tests/coreml --durations=0 displayName: 'pytest - coreml' - condition: not(eq('$(python.version)', '3.10')) + condition: ne('$(COREML_PATH)', '') - task: PublishTestResults@2 inputs: diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index 01e6d375..b17d1921 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -20,48 +20,56 @@ jobs: ONNX_PATH: 'onnx==1.13.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: '' + numpy.version: '' Python39-1120-RT1110: python.version: '3.9' ONNX_PATH: 'onnx==1.12.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.11.0 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '' Python39-1110-RT1110: python.version: '3.9' ONNX_PATH: onnx==1.11.0 # '-i https://test.pypi.org/simple/ onnx==1.9.101' ONNXRT_PATH: onnxruntime==1.11.0 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '' Python39-1110-RT190: python.version: '3.9' ONNX_PATH: 'onnx==1.11.0' # '-i https://test.pypi.org/simple/ onnx==1.9.101' ONNXRT_PATH: onnxruntime==1.10.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '' Python39-1102-RT190: python.version: '3.9' ONNX_PATH: 'onnx==1.10.2' # '-i https://test.pypi.org/simple/ onnx==1.9.101' ONNXRT_PATH: onnxruntime==1.9.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '<=1.23.5' Python39-190-RT181: python.version: '3.9' ONNX_PATH: 'onnx==1.9.0' ONNXRT_PATH: onnxruntime==1.8.1 COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '<=1.23.5' Python39-190-RT180: python.version: '3.9' ONNX_PATH: onnx==1.9.0 ONNXRT_PATH: onnxruntime==1.8.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '<=1.23.5' Python38-181-RT170: python.version: '3.8' ONNX_PATH: onnx==1.8.1 ONNXRT_PATH: onnxruntime==1.7.0 COREML_PATH: git+https://github.com/apple/coremltools@3.1 + numpy.version: '<=1.23.5' maxParallel: 3 @@ -89,16 +97,11 @@ jobs: python -m pip install --upgrade scikit-learn displayName: 'Install scikit-learn' - - script: | - call activate py$(python.version) - python -m pip install %COREML_PATH% - displayName: 'Install coremltools' - condition: not(eq('$(python.version)', '3.10')) - - script: | call activate py$(python.version) python -m pip install %ONNX_PATH% python -m pip install %ONNXRT_PATH% + python -m pip install "numpy$(numpy.version)" displayName: 'Install onnxruntime' - script: | @@ -132,8 +135,10 @@ jobs: - script: | call activate py$(python.version) export PYTHONPATH=. + python -m pip install %COREML_PATH% python -m pytest tests/coreml --durations=0 displayName: 'pytest coreml' + condition: ne('$(COREML_PATH)', '')) - script: | call activate py$(python.version) From 75a55537918053df60ec96624c568ec0b506c698 Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 17 Jan 2023 19:35:21 +0100 Subject: [PATCH 12/18] update CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 2 +- .azure-pipelines/win32-conda-CI.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index 3cd33ee6..77042a6d 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -177,7 +177,7 @@ jobs: export PYTHONPATH=. pip install $(COREML_PATH) pytest tests/coreml --durations=0 - displayName: 'pytest - coreml' + displayName: 'pytest - coreml [$(COREML_PATH)]' condition: ne('$(COREML_PATH)', '') - task: PublishTestResults@2 diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index b17d1921..02eaa495 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -137,8 +137,8 @@ jobs: export PYTHONPATH=. python -m pip install %COREML_PATH% python -m pytest tests/coreml --durations=0 - displayName: 'pytest coreml' - condition: ne('$(COREML_PATH)', '')) + displayName: 'pytest coreml - [$(COREML_PATH)]' + condition: ne('$(COREML_PATH)', '') - script: | call activate py$(python.version) From b70327216d738a1a1b5712ff4b0dda13e81bead2 Mon Sep 17 00:00:00 2001 From: xadupre Date: Wed, 18 Jan 2023 12:04:58 +0100 Subject: [PATCH 13/18] fix CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 6 +++--- .azure-pipelines/win32-conda-CI.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index 77042a6d..e82d2214 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -18,14 +18,14 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: '' + COREML_PATH: '-' xgboost.version: '>=1.7.3' numpy.version: '' Python310-1120-RT1121-xgb161: python.version: '3.10' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.12.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: git+https://github.com/apple/coremltools@3.1 + COREML_PATH: '-' xgboost.version: '==1.6.1' numpy.version: '' Python39-1120-RT1110-xgb161: @@ -178,7 +178,7 @@ jobs: pip install $(COREML_PATH) pytest tests/coreml --durations=0 displayName: 'pytest - coreml [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', '') + condition: ne('$(COREML_PATH)', '-') - task: PublishTestResults@2 inputs: diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index 02eaa495..5e5a452e 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -19,7 +19,7 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: '' + COREML_PATH: '-' numpy.version: '' Python39-1120-RT1110: @@ -138,7 +138,7 @@ jobs: python -m pip install %COREML_PATH% python -m pytest tests/coreml --durations=0 displayName: 'pytest coreml - [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', '') + condition: ne('$(COREML_PATH)', '-') - script: | call activate py$(python.version) From 2e710ec97d8419e8db3c48bffde74f10450af472 Mon Sep 17 00:00:00 2001 From: xadupre Date: Wed, 18 Jan 2023 12:54:12 +0100 Subject: [PATCH 14/18] fix CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 6 +++--- .azure-pipelines/win32-conda-CI.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index e82d2214..23f58071 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -18,14 +18,14 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: '-' + COREML_PATH: 'NONE' xgboost.version: '>=1.7.3' numpy.version: '' Python310-1120-RT1121-xgb161: python.version: '3.10' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.12.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: '-' + COREML_PATH: 'NONE' xgboost.version: '==1.6.1' numpy.version: '' Python39-1120-RT1110-xgb161: @@ -178,7 +178,7 @@ jobs: pip install $(COREML_PATH) pytest tests/coreml --durations=0 displayName: 'pytest - coreml [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', '-') + condition: ne('$(COREML_PATH)', 'NONE') - task: PublishTestResults@2 inputs: diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index 5e5a452e..ab6f1d31 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -19,7 +19,7 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: '-' + COREML_PATH: 'NONE' numpy.version: '' Python39-1120-RT1110: @@ -138,7 +138,7 @@ jobs: python -m pip install %COREML_PATH% python -m pytest tests/coreml --durations=0 displayName: 'pytest coreml - [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', '-') + condition: ne('$(COREML_PATH)', 'NONE') - script: | call activate py$(python.version) From f4f1e86bef1832ecc58d81d92463525c7b4465bb Mon Sep 17 00:00:00 2001 From: xadupre Date: Wed, 18 Jan 2023 14:39:03 +0100 Subject: [PATCH 15/18] update CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 2 +- .azure-pipelines/win32-conda-CI.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index 23f58071..cd913312 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -178,7 +178,7 @@ jobs: pip install $(COREML_PATH) pytest tests/coreml --durations=0 displayName: 'pytest - coreml [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', 'NONE') + condition: ne($(COREML_PATH), 'NONE') - task: PublishTestResults@2 inputs: diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index ab6f1d31..51d4a8d0 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -138,7 +138,7 @@ jobs: python -m pip install %COREML_PATH% python -m pytest tests/coreml --durations=0 displayName: 'pytest coreml - [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', 'NONE') + condition: ne($(COREML_PATH), 'NONE') - script: | call activate py$(python.version) From 18aa1ad9d87aa7c6635fef3dda0728f0faf6639f Mon Sep 17 00:00:00 2001 From: xadupre Date: Wed, 18 Jan 2023 16:25:28 +0100 Subject: [PATCH 16/18] update CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 6 +++--- .azure-pipelines/win32-conda-CI.yml | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index cd913312..504cb21c 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -18,14 +18,14 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: 'NONE' + COREML_PATH: NONE xgboost.version: '>=1.7.3' numpy.version: '' Python310-1120-RT1121-xgb161: python.version: '3.10' ONNX_PATH: 'onnx==1.12.0' #'-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.12.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: 'NONE' + COREML_PATH: NONE xgboost.version: '==1.6.1' numpy.version: '' Python39-1120-RT1110-xgb161: @@ -178,7 +178,7 @@ jobs: pip install $(COREML_PATH) pytest tests/coreml --durations=0 displayName: 'pytest - coreml [$(COREML_PATH)]' - condition: ne($(COREML_PATH), 'NONE') + condition: ne('$(COREML_PATH)', 'NONE') - task: PublishTestResults@2 inputs: diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index 51d4a8d0..309987e5 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -19,7 +19,7 @@ jobs: python.version: '3.10' ONNX_PATH: 'onnx==1.13.0' # '-i https://test.pypi.org/simple/ onnx==1.12.0rc4' ONNXRT_PATH: onnxruntime==1.13.1 #'-i https://test.pypi.org/simple/ ort-nightly==1.11.0.dev20220311003' - COREML_PATH: 'NONE' + COREML_PATH: NONE numpy.version: '' Python39-1120-RT1110: @@ -138,7 +138,7 @@ jobs: python -m pip install %COREML_PATH% python -m pytest tests/coreml --durations=0 displayName: 'pytest coreml - [$(COREML_PATH)]' - condition: ne($(COREML_PATH), 'NONE') + condition: ne('$(COREML_PATH)', 'NONE') - script: | call activate py$(python.version) From 1f754fb91cc159ef676ebfd8dac5e8c67662822e Mon Sep 17 00:00:00 2001 From: xadupre Date: Wed, 18 Jan 2023 17:49:53 +0100 Subject: [PATCH 17/18] update CI Signed-off-by: xadupre --- .azure-pipelines/linux-conda-CI.yml | 13 +++++++++---- .azure-pipelines/win32-conda-CI.yml | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/linux-conda-CI.yml b/.azure-pipelines/linux-conda-CI.yml index 504cb21c..c11a89da 100644 --- a/.azure-pipelines/linux-conda-CI.yml +++ b/.azure-pipelines/linux-conda-CI.yml @@ -174,11 +174,16 @@ jobs: displayName: 'pytest - hummingbirdml' - script: | - export PYTHONPATH=. - pip install $(COREML_PATH) - pytest tests/coreml --durations=0 + if [ '$(COREML_PATH)' == 'NONE' ] + then + echo "required version of coremltools does not work on python 3.10" + else + export PYTHONPATH=. + pip install $(COREML_PATH) + pytest tests/coreml --durations=0 + fi displayName: 'pytest - coreml [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', 'NONE') + # condition: ne('$(COREML_PATH)', 'NONE') - task: PublishTestResults@2 inputs: diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index 309987e5..ed04c868 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -135,10 +135,10 @@ jobs: - script: | call activate py$(python.version) export PYTHONPATH=. - python -m pip install %COREML_PATH% - python -m pytest tests/coreml --durations=0 + if "$(COREML_PATH)" neq "NONE" python -m pip install %COREML_PATH% + if "$(COREML_PATH)" neq "NONE" python -m pytest tests/coreml --durations=0 displayName: 'pytest coreml - [$(COREML_PATH)]' - condition: ne('$(COREML_PATH)', 'NONE') + #condition: ne('$(COREML_PATH)', 'NONE') - script: | call activate py$(python.version) From c54ec1813522890e4bee5c88dd856f6073d47f91 Mon Sep 17 00:00:00 2001 From: xadupre Date: Wed, 18 Jan 2023 18:21:27 +0100 Subject: [PATCH 18/18] update CI Signed-off-by: xadupre --- .azure-pipelines/win32-conda-CI.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/win32-conda-CI.yml b/.azure-pipelines/win32-conda-CI.yml index ed04c868..2d44629b 100644 --- a/.azure-pipelines/win32-conda-CI.yml +++ b/.azure-pipelines/win32-conda-CI.yml @@ -134,7 +134,7 @@ jobs: - script: | call activate py$(python.version) - export PYTHONPATH=. + set PYTHONPATH=. if "$(COREML_PATH)" neq "NONE" python -m pip install %COREML_PATH% if "$(COREML_PATH)" neq "NONE" python -m pytest tests/coreml --durations=0 displayName: 'pytest coreml - [$(COREML_PATH)]'