diff --git a/_doc/examples/plot_time_tree_ensemble.py b/_doc/examples/plot_time_tree_ensemble.py index 77d55d57c..1b1d5e2a9 100644 --- a/_doc/examples/plot_time_tree_ensemble.py +++ b/_doc/examples/plot_time_tree_ensemble.py @@ -34,7 +34,6 @@ from xgboost import XGBClassifier from lightgbm import LGBMClassifier from onnxruntime import InferenceSession -from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn.ensemble import HistGradientBoostingClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.datasets import make_classification diff --git a/_doc/sphinxdoc/source/_exts/generate_automated_pages.py b/_doc/sphinxdoc/source/_exts/generate_automated_pages.py index c57620407..ec7178864 100644 --- a/_doc/sphinxdoc/source/_exts/generate_automated_pages.py +++ b/_doc/sphinxdoc/source/_exts/generate_automated_pages.py @@ -7,7 +7,6 @@ from pandas import DataFrame, read_excel, read_csv, concat, Series from sklearn.exceptions import ConvergenceWarning from sklearn.utils._testing import ignore_warnings -from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn.ensemble import AdaBoostRegressor, HistGradientBoostingRegressor from sklearn.gaussian_process import GaussianProcessClassifier import sphinx diff --git a/_doc/sphinxdoc/source/conf.py b/_doc/sphinxdoc/source/conf.py index 0e2a562f5..f467914c6 100644 --- a/_doc/sphinxdoc/source/conf.py +++ b/_doc/sphinxdoc/source/conf.py @@ -3,7 +3,6 @@ import os import alabaster from pyquickhelper.helpgen.default_conf import set_sphinx_variables -from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 try: from mlprodict.onnx_conv import register_converters, register_rewritten_operators except ImportError as e: diff --git a/_unittests/ut__skl2onnx/test_sklearn_label_encoder_converter.py b/_unittests/ut__skl2onnx/test_sklearn_label_encoder_converter.py index 558ee0399..24f9cda8a 100644 --- a/_unittests/ut__skl2onnx/test_sklearn_label_encoder_converter.py +++ b/_unittests/ut__skl2onnx/test_sklearn_label_encoder_converter.py @@ -51,7 +51,7 @@ def test_model_label_encoder_int(self): data = numpy.array([10, 3, 5, -34, 0], dtype=numpy.int64) model.fit(data) # opset=13, 14, ... - for op in sorted(set([9, 10, 11, 12, 13, 14, TARGET_OPSET])): + for op in sorted(set([9, 10, 11, 12, 13, 14, 15, TARGET_OPSET])): if op > TARGET_OPSET: continue with self.subTest(opset=op): diff --git a/_unittests/ut_asv_benchmark/test_template_benchmark.py b/_unittests/ut_asv_benchmark/test_template_asv_benchmark.py similarity index 100% rename from _unittests/ut_asv_benchmark/test_template_benchmark.py rename to _unittests/ut_asv_benchmark/test_template_asv_benchmark.py diff --git a/_unittests/ut_npy/test_wrappers.py b/_unittests/ut_npy/test_wrappers.py index 76bebbeb7..4a53e0985 100644 --- a/_unittests/ut_npy/test_wrappers.py +++ b/_unittests/ut_npy/test_wrappers.py @@ -28,7 +28,7 @@ def __init__(self, operator, inputs, outputs): class container_dummy: def __init__(self): - self.target_opset = 14 + self.target_opset = 15 class TestWrappers(ExtTestCase): diff --git a/_unittests/ut_onnx_conv/test_onnx_conv_knn.py b/_unittests/ut_onnx_conv/test_onnx_conv_knn.py index 02d449cde..aaad62155 100644 --- a/_unittests/ut_onnx_conv/test_onnx_conv_knn.py +++ b/_unittests/ut_onnx_conv/test_onnx_conv_knn.py @@ -244,7 +244,7 @@ def onnx_test_knn_single_classreg(self, dtype, n_targets=1, debug=False, if target_opset is None: opsets = list(sorted(set([ - 9, 10, 11, 12, 13, 14, get_opset_number_from_onnx()]))) # opset=13, 14, ... + 9, 10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]))) # opset=13, 14, ... else: opsets = [target_opset] for ops in opsets: @@ -475,7 +475,7 @@ def test_onnx_test_knn_transform(self): clr = NearestNeighbors(n_neighbors=3) clr.fit(X_train) - for to in (10, 11, 12, 13, 14): # opset=13, 14, ... + for to in (10, 11, 12, 13, 14, 15): # opset=13, 14, ... if to > get_opset_number_from_onnx(): break try: diff --git a/_unittests/ut_onnx_conv/test_skl2onnx_ensemble.py b/_unittests/ut_onnx_conv/test_skl2onnx_ensemble.py index ff3f3dccf..d86fcc0fe 100644 --- a/_unittests/ut_onnx_conv/test_skl2onnx_ensemble.py +++ b/_unittests/ut_onnx_conv/test_skl2onnx_ensemble.py @@ -12,7 +12,6 @@ ExtraTreesClassifier, ExtraTreesRegressor ) try: - from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn.ensemble import ( HistGradientBoostingClassifier, HistGradientBoostingRegressor diff --git a/_unittests/ut_onnxrt/test_benchmark_replay.py b/_unittests/ut_onnxrt/test_benchmark_replay.py index 6b87de6dc..ad1cdcae2 100644 --- a/_unittests/ut_onnxrt/test_benchmark_replay.py +++ b/_unittests/ut_onnxrt/test_benchmark_replay.py @@ -19,8 +19,8 @@ def test_benchmark_replay(self): FileNotFoundError) res = list(enumerate_validated_operator_opsets( # opset=13, 14, ... - 0, fLOG=None, models={"LogisticRegression"}, opset_min=14, - opset_max=14, benchmark=False, store_models=True, dump_all=True, + 0, fLOG=None, models={"LogisticRegression"}, opset_min=15, + opset_max=15, benchmark=False, store_models=True, dump_all=True, dump_folder=temp, filter_exp=lambda m, p: ( "64" not in p and "b-cl" in p and "dec" not in p))) self.assertNotEmpty(res) diff --git a/_unittests/ut_onnxrt/test_onnx_profiling.py b/_unittests/ut_onnxrt/test_onnx_profiling.py index 933aa0fb6..75825d7a0 100644 --- a/_unittests/ut_onnxrt/test_onnx_profiling.py +++ b/_unittests/ut_onnxrt/test_onnx_profiling.py @@ -41,7 +41,7 @@ def test_profile_onnxruntime1(self): del model_def.opset_import[:] # pylint: disable=E1101 op_set = model_def.opset_import.add() # pylint: disable=E1101 op_set.domain = '' - op_set.version = 14 # opset=13, 14, ... + op_set.version = 15 # opset=13, 14, ... X = (numpy.random.randn(4, 2) * 100000).astype( # pylint: disable=E1101 numpy.float32) diff --git a/_unittests/ut_onnxrt/test_onnxrt_python_runtime_.py b/_unittests/ut_onnxrt/test_onnxrt_python_runtime_.py index 1763f6c36..5a92db3d4 100644 --- a/_unittests/ut_onnxrt/test_onnxrt_python_runtime_.py +++ b/_unittests/ut_onnxrt/test_onnxrt_python_runtime_.py @@ -3204,7 +3204,7 @@ def test_onnxt_runtime_reduce_sum(self): X = numpy.array([[2, 1], [0, 1]], dtype=float) # opset=13, 14, ... - for opset in (10, 11, 12, 13, 14, get_opset_number_from_onnx()): + for opset in (10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()): if onnx_opset_version() < opset: continue if opset < 13: @@ -3314,7 +3314,7 @@ def test_onnxt_runtime_reduce_sum_noop(self): X = numpy.array([], dtype=float).reshape((2, 0)) # opset=13, 14, ... - for opset in (13, 14, get_opset_number_from_onnx()): + for opset in (13, 14, 15, get_opset_number_from_onnx()): if onnx_opset_version() < opset: continue @@ -3572,7 +3572,7 @@ def test_onnxt_runtime_slice(self): @wraplog() def test_onnxt_runtime_slice_step_none(self): # opset=13, 14, ... - for opset in [13, 14, get_opset_number_from_onnx()]: + for opset in [13, 14, 15, get_opset_number_from_onnx()]: if opset > get_opset_number_from_onnx(): continue with self.subTest(opset=opset): @@ -3593,7 +3593,7 @@ def test_onnxt_runtime_slice_step_none(self): @wraplog() def test_onnxt_runtime_split(self): # opset=13, 14, ... - for opset in [10, 11, 12, 13, 14, get_opset_number_from_onnx()]: + for opset in [10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]: if opset > get_opset_number_from_onnx(): continue with self.subTest(opset=opset): @@ -3645,7 +3645,7 @@ def test_onnxt_runtime_sqrt(self): @wraplog() def test_onnxt_runtime_squeeze(self): # opset=13, 14, ... - for opset in [10, 11, 12, 13, 14, get_opset_number_from_onnx()]: + for opset in [10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]: if opset > get_opset_number_from_onnx(): continue with self.subTest(opset=opset): @@ -3838,7 +3838,7 @@ def test_onnxt_runtime_transpose(self): @wraplog() def test_onnxt_runtime_unsqueeze(self): # opset=13, 14, ... - for opset in [10, 11, 12, 13, 14, get_opset_number_from_onnx()]: + for opset in [10, 11, 12, 13, 14, 15, get_opset_number_from_onnx()]: if opset > get_opset_number_from_onnx(): continue with self.subTest(opset=opset): @@ -4187,7 +4187,8 @@ def test_make_constant(self): (11, OnnxConstant_11), (9, OnnxConstant_9)] - expected_type = {14: Constant_12, 12: Constant_12, 13: Constant_12, + expected_type = {15: Constant_12, 14: Constant_12, + 12: Constant_12, 13: Constant_12, 11: Constant_11, 9: Constant_9} if (not sys.platform.startswith('win') or @@ -4227,7 +4228,7 @@ def test_make_constant(self): self.assertEqualArray(exp, got['Ad_C0']) def test_op_constant(self): - for opv in [9, 10, 11, 12, 13, 14]: # opset=13, 14, ... + for opv in [9, 10, 11, 12, 13, 14, 15]: # opset=13, 14, ... for dtype in [numpy.float32, numpy.float64, numpy.int32, numpy.int64]: with self.subTest(opv=opv, dtype=dtype): diff --git a/_unittests/ut_onnxrt/test_onnxrt_python_runtime_control_loop.py b/_unittests/ut_onnxrt/test_onnxrt_python_runtime_control_loop.py index bd5ef2222..f42295a57 100644 --- a/_unittests/ut_onnxrt/test_onnxrt_python_runtime_control_loop.py +++ b/_unittests/ut_onnxrt/test_onnxrt_python_runtime_control_loop.py @@ -62,8 +62,8 @@ def expect(node, inputs, outputs, name): del model_def.opset_import[:] # pylint: disable=E1101 op_set = model_def.opset_import.add() # pylint: disable=E1101 op_set.domain = '' - op_set.version = 14 - model_def.ir_version = 7 + op_set.version = 15 + model_def.ir_version = 8 test_cases = { 'at_back': [numpy.array([10, 11, 12]).astype(numpy.int64)], @@ -191,8 +191,8 @@ def test_loop(self): del model_def.opset_import[:] # pylint: disable=E1101 op_set = model_def.opset_import.add() # pylint: disable=E1101 op_set.domain = '' - op_set.version = 14 - model_def.ir_version = 7 + op_set.version = 15 + model_def.ir_version = 8 expected = numpy.array([ 1., 1., 2., 1., 2., 3., 1., 2., @@ -307,8 +307,8 @@ def test_loop_additional_input(self): del model_def.opset_import[:] # pylint: disable=E1101 op_set = model_def.opset_import.add() # pylint: disable=E1101 op_set.domain = '' - op_set.version = 14 - model_def.ir_version = 7 + op_set.version = 15 + model_def.ir_version = 8 expected = numpy.array([ 1., 1., 2., 1., 2., 3., 1., 2., diff --git a/_unittests/ut_onnxrt/test_onnxrt_python_runtime_ml_tree_rf.py b/_unittests/ut_onnxrt/test_onnxrt_python_runtime_ml_tree_rf.py index 0b6a136a6..a84a88b2c 100644 --- a/_unittests/ut_onnxrt/test_onnxrt_python_runtime_ml_tree_rf.py +++ b/_unittests/ut_onnxrt/test_onnxrt_python_runtime_ml_tree_rf.py @@ -10,7 +10,6 @@ from sklearn.utils._testing import ignore_warnings except ImportError: from sklearn.utils.testing import ignore_warnings -from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn.ensemble import RandomForestRegressor, HistGradientBoostingRegressor from pyquickhelper.loghelper import fLOG from pyquickhelper.pycode import ( diff --git a/_unittests/ut_onnxrt/test_onnxrt_switch_types.py b/_unittests/ut_onnxrt/test_onnxrt_switch_types.py index fd580b39f..28f201862 100644 --- a/_unittests/ut_onnxrt/test_onnxrt_switch_types.py +++ b/_unittests/ut_onnxrt/test_onnxrt_switch_types.py @@ -107,7 +107,7 @@ def test_onnxt_iris_gaussian_process_exp_sine_squared_13(self): model_def = to_onnx( clr, X_train.astype(numpy.float32), options={GaussianProcessRegressor: {'return_std': True}}, - target_opset=14) # opset=13, 14, ... + target_opset=15) # opset=13, 14, ... oinf = OnnxInference(model_def, runtime='python') res = oinf.run({'X': X_test.astype(numpy.float32)}) diff --git a/_unittests/ut_testing/test_skl2onnx_testing_check.py b/_unittests/ut_testing/test_skl2onnx_testing_check.py index dec89e37b..46b454922 100644 --- a/_unittests/ut_testing/test_skl2onnx_testing_check.py +++ b/_unittests/ut_testing/test_skl2onnx_testing_check.py @@ -8,7 +8,6 @@ from sklearn.datasets import make_classification from sklearn.model_selection import train_test_split try: - from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn.ensemble import HistGradientBoostingClassifier except ImportError: HistGradientBoostingClassifier = None diff --git a/_unittests/ut_tools/test_model_info.py b/_unittests/ut_tools/test_model_info.py index d61c06e8f..4aec64dc4 100644 --- a/_unittests/ut_tools/test_model_info.py +++ b/_unittests/ut_tools/test_model_info.py @@ -5,7 +5,6 @@ import inspect import unittest import numpy -from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn.datasets import load_iris from sklearn.linear_model import LogisticRegression, LinearRegression from sklearn.neighbors import KNeighborsClassifier diff --git a/_unittests/ut_tools/test_onnx_micro_runtime.py b/_unittests/ut_tools/test_onnx_micro_runtime.py index b29ef15cf..8fa35daa3 100644 --- a/_unittests/ut_tools/test_onnx_micro_runtime.py +++ b/_unittests/ut_tools/test_onnx_micro_runtime.py @@ -12,8 +12,10 @@ class TestOnnxMicroRuntime(ExtTestCase): + opset = 15 # opset=13, 14, ... + def test_onnx_micro_runtime(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset dtype = numpy.float32 x = numpy.array([1, 2, 4, 5, 5, 4]).astype( numpy.float32).reshape((3, 2)) @@ -32,7 +34,7 @@ def test_onnx_micro_runtime_exc1(self): self.assertRaise(lambda: OnnxMicroRuntime(None), TypeError) def test_onnx_micro_runtime_exc2(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset dtype = numpy.float32 x = numpy.array([1, 2, 4, 5, 5, 4]).astype( numpy.float32).reshape((3, 2)) @@ -45,7 +47,7 @@ def test_onnx_micro_runtime_exc2(self): self.assertRaise(lambda: rt.run(x), TypeError) def test_onnx_micro_runtime_shape(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset x = numpy.array([1, 2, 4, 5, 5, 4]).astype( numpy.float32).reshape((3, 2)) cop = OnnxShape('X', op_version=opset, output_names=['Y']) @@ -55,7 +57,7 @@ def test_onnx_micro_runtime_shape(self): self.assertEqual(numpy.array(x.shape, dtype=numpy.int64), out['Y']) def test_onnx_micro_runtime_transpose(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset x = numpy.array([1, 2, 4, 5, 5, 4]).astype( numpy.float32).reshape((3, 2)) cop = OnnxTranspose('X', perm=[1, 0], op_version=opset, @@ -66,7 +68,7 @@ def test_onnx_micro_runtime_transpose(self): self.assertEqual(x.T, out['Y']) def test_onnx_micro_runtime_matmul(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset x = numpy.array([1, 2, 4, 5]).astype( numpy.float32).reshape((2, 2)) cop = OnnxMatMul('X', 'X', op_version=opset, @@ -77,7 +79,7 @@ def test_onnx_micro_runtime_matmul(self): self.assertEqual(numpy.matmul(x, x), out['Y']) def test_onnx_micro_runtime_squeeze(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset x = numpy.array([1, 2, 4, 5]).astype( numpy.float32).reshape((2, 2, 1)) cop = OnnxSqueeze('X', numpy.array([2], dtype=numpy.int64), @@ -88,7 +90,7 @@ def test_onnx_micro_runtime_squeeze(self): self.assertEqual(numpy.squeeze(x), out['Y']) def test_onnx_micro_runtime_unsqueeze(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset x = numpy.array([1, 2, 4, 5]).astype( numpy.float32).reshape((2, 2)) cop = OnnxUnsqueeze('X', numpy.array([2], dtype=numpy.int64), @@ -99,7 +101,7 @@ def test_onnx_micro_runtime_unsqueeze(self): self.assertEqual(x.reshape((2, 2, 1)), out['Y']) def test_onnx_micro_runtime_gemm(self): - opset = 14 # opset=13, 14, ... + opset = TestOnnxMicroRuntime.opset x = numpy.array([1, 2, 4, 5]).astype( numpy.float32).reshape((2, 2)) for ta in [0, 1]: diff --git a/_unittests/ut_tools/test_ort.py b/_unittests/ut_tools/test_ort.py index cf6ce18b2..f6c066a16 100644 --- a/_unittests/ut_tools/test_ort.py +++ b/_unittests/ut_tools/test_ort.py @@ -12,8 +12,10 @@ class TestOrt(ExtTestCase): + opset = 15 # opset = 13, 14, ... + def test_prepare_c_profiling(self): - opset = 14 # opset=13, 14, ... + opset = TestOrt.opset dtype = numpy.float32 x = numpy.array([1, 2, 4, 5, 5, 4]).astype( numpy.float32).reshape((3, 2)) diff --git a/_unittests/ut_tools/test_sklearn_helper.py b/_unittests/ut_tools/test_sklearn_helper.py index 595f71885..c5ef64d23 100644 --- a/_unittests/ut_tools/test_sklearn_helper.py +++ b/_unittests/ut_tools/test_sklearn_helper.py @@ -70,11 +70,16 @@ def test_statistics_rf(self): res = inspect_sklearn_model(clr) self.assertEqual(res['max_depth'], 4) self.assertEqual(res['ntrees'], 10) - onx = to_onnx(clr, X_train[:1].astype(numpy.float32)) - ostats = onnx_statistics(onx) - for k, v in {'nnodes': 11, 'doc_string': '', 'domain': 'ai.onnx', 'model_version': 0, - 'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items(): - self.assertEqual(ostats[k], v) + for dtype in [numpy.float32, numpy.float64]: + with self.subTest(dtype=dtype): + onx = to_onnx(clr, X_train[:1].astype(dtype)) + ostats = onnx_statistics(onx) + for k, v in {'nnodes': 1, 'doc_string': '', + 'domain': 'ai.onnx', 'model_version': 0, + 'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items(): + if k == 'ai.onnx.ml' and k not in ostats: + continue + self.assertEqual(ostats[k], v) @ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning)) def test_statistics_adaboost(self): @@ -99,11 +104,17 @@ def test_statistics_pipeline_rf(self): self.assertEqual(res['max_depth'], 4) self.assertEqual(res['ntrees'], 10) self.assertEqual(res['nop'], 11) - onx = to_onnx(clr, X_train[:1].astype(numpy.float32)) - ostats = onnx_statistics(onx) - for k, v in {'nnodes': 12, 'doc_string': '', 'domain': 'ai.onnx', 'model_version': 0, - 'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items(): - self.assertEqual(ostats[k], v) + expected = {numpy.float32: 2, numpy.float64: 3} + for dtype in [numpy.float32, numpy.float64]: + with self.subTest(dtype=dtype): + onx = to_onnx(clr, X_train[:1].astype(dtype)) + ostats = onnx_statistics(onx) + for k, v in {'nnodes': expected[dtype], 'doc_string': '', + 'domain': 'ai.onnx', 'model_version': 0, + 'producer_name': 'skl2onnx', 'ai.onnx.ml': 1}.items(): + if k == 'ai.onnx.ml' and k not in ostats: + continue + self.assertEqual(ostats[k], v) @ignore_warnings(category=(UserWarning, RuntimeWarning, DeprecationWarning)) def test_statistics_lin(self): diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 39f59eaa0..553e962e6 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -167,7 +167,7 @@ jobs: # export MACOSX_DEPLOYMENT_TARGET=10.13 python setup.py build_ext --inplace displayName: 'Build package inplace' - - script: python -u setup.py unittests -g ".*((LONG)|(SKIP)|(notebooks)).*" -d 50 + - script: python -u setup.py unittests -g ".*((LONG)|(SKIP)|(notebooks)|(asv_benchmark)|(test_onnx_helper)|(test_onnx_inference)|(test_onnxrt_python_runtime_ml)|(test_custom_embedded_any_models)|(test_custom_)|(test_onnx_pipeline)|(test_onnx_speedup_cluster)).*" -d 7 displayName: 'Runs Unit Tests' - script: | python -m pip install cibuildwheel diff --git a/mlprodict/asv_benchmark/_create_asv_helper.py b/mlprodict/asv_benchmark/_create_asv_helper.py index 27a8a511d..b51efcd4c 100644 --- a/mlprodict/asv_benchmark/_create_asv_helper.py +++ b/mlprodict/asv_benchmark/_create_asv_helper.py @@ -378,8 +378,6 @@ def _additional_imports(model_name): """ if model_name == 'IterativeImputer': return ["from sklearn.experimental import enable_iterative_imputer # pylint: disable=W0611"] - if model_name in ('HistGradientBoostingClassifier', 'HistGradientBoostingClassifier'): - return ["from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611"] return None diff --git a/mlprodict/onnx_tools/onnx_export.py b/mlprodict/onnx_tools/onnx_export.py index 2e44de6cb..da78dc2fd 100644 --- a/mlprodict/onnx_tools/onnx_export.py +++ b/mlprodict/onnx_tools/onnx_export.py @@ -6,8 +6,6 @@ .. versionadded:: 0.7 """ import numpy -from jinja2 import Template -import autopep8 import onnx from onnx import numpy_helper from .onnx2py_helper import ( @@ -37,6 +35,9 @@ def export_template(model_onnx, templates, opset=None, verbose=True, name=None, :param autopep_options: :epkg:`autopep8` options :return: python code """ + # delayed import to avoid raising an exception if not installed. + import autopep8 + def number2name(n): n += 1 seq = [] @@ -177,6 +178,7 @@ def rename_name(name): mark_inits = {} # First rendering to detect any unused or replaced initializer. + from jinja2 import Template # delayed import template = Template(templates) final = template.render( enumerate=enumerate, sorted=sorted, len=len, diff --git a/mlprodict/onnxrt/doc/doc_helper.py b/mlprodict/onnxrt/doc/doc_helper.py index 42b403dc7..ffae0816a 100644 --- a/mlprodict/onnxrt/doc/doc_helper.py +++ b/mlprodict/onnxrt/doc/doc_helper.py @@ -5,8 +5,6 @@ import keyword import textwrap import re -from jinja2 import Template -from jinja2.runtime import Undefined from onnx.defs import OpSchema from ...tools import change_style @@ -38,6 +36,7 @@ def type_mapping(name): def _get_doc_template(): + from jinja2 import Template # delayed import return Template(textwrap.dedent(""" {% for sch in schemas %} @@ -139,6 +138,7 @@ def get_rst_doc(op_name): The function relies on module :epkg:`jinja2` or replaces it with a simple rendering if not present. """ + from jinja2.runtime import Undefined from ..ops_cpu._op import _schemas schemas = [_schemas.get(op_name, NewOperatorSchema(op_name))] diff --git a/mlprodict/onnxrt/doc/doc_write_helper.py b/mlprodict/onnxrt/doc/doc_write_helper.py index 56b999852..f672473bc 100644 --- a/mlprodict/onnxrt/doc/doc_write_helper.py +++ b/mlprodict/onnxrt/doc/doc_write_helper.py @@ -5,7 +5,6 @@ from logging import getLogger from textwrap import indent, dedent import numpy -from jinja2 import Template from pandas import DataFrame, notnull from sklearn.linear_model import LinearRegression from pyquickhelper.loghelper import noLOG @@ -49,6 +48,7 @@ def enumerate_visual_onnx_representation_into_rst(sub, fLOG=noLOG): Returns content for pages such as :ref:`l-skl2onnx-linear_model`. """ + from jinja2 import Template # delayed import logger = getLogger('skl2onnx') logger.disabled = True diff --git a/mlprodict/onnxrt/validate/validate_problems.py b/mlprodict/onnxrt/validate/validate_problems.py index b24f181fa..01bf501f9 100644 --- a/mlprodict/onnxrt/validate/validate_problems.py +++ b/mlprodict/onnxrt/validate/validate_problems.py @@ -25,7 +25,6 @@ from sklearn.feature_extraction import DictVectorizer, FeatureHasher from sklearn.feature_extraction.text import ( CountVectorizer, TfidfVectorizer, TfidfTransformer) -from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn.ensemble import ( HistGradientBoostingRegressor, HistGradientBoostingClassifier) diff --git a/mlprodict/onnxrt/validate/validate_scenarios.py b/mlprodict/onnxrt/validate/validate_scenarios.py index 0a954e3cc..4a6ad15a2 100644 --- a/mlprodict/onnxrt/validate/validate_scenarios.py +++ b/mlprodict/onnxrt/validate/validate_scenarios.py @@ -2,7 +2,6 @@ @file @brief Scenarios for validation. """ -from sklearn.experimental import enable_hist_gradient_boosting # pylint: disable=W0611 from sklearn import __all__ as sklearn__all__, __version__ as sklearn_version from sklearn.cluster import KMeans from sklearn.calibration import CalibratedClassifierCV diff --git a/mlprodict/testing/einsum/einsum_bench.py b/mlprodict/testing/einsum/einsum_bench.py index 4c44055b4..422261238 100644 --- a/mlprodict/testing/einsum/einsum_bench.py +++ b/mlprodict/testing/einsum/einsum_bench.py @@ -11,7 +11,7 @@ from .einsum_impl import decompose_einsum_equation, apply_einsum_sequence -def _make_einsum_model(equation, opset=14): # opset=13, 14, ... +def _make_einsum_model(equation, opset=15): # opset=13, 14, ... from skl2onnx.common._topology import OPSET_TO_IR_VERSION # pylint: disable=E0611,E0001 inputs = equation.split('->')[0].split(',') @@ -57,7 +57,7 @@ def _make_inputs(equation, shapes): def einsum_benchmark(equation="abc,cd->abd", shape=30, perm=False, runtime='python', use_tqdm=False, - number=5, repeat=5, opset=14): # opset=13, 14, ... + number=5, repeat=5, opset=15): # opset=13, 14, ... """ Investigates whether or not the decomposing einsum is faster. diff --git a/mlprodict/tools/asv_options_helper.py b/mlprodict/tools/asv_options_helper.py index e1b5b9802..b7743dbfb 100644 --- a/mlprodict/tools/asv_options_helper.py +++ b/mlprodict/tools/asv_options_helper.py @@ -74,7 +74,7 @@ def benchmark_version(): from mlprodict.tools.asv_options_helper import benchmark_version print(benchmark_version()) """ - return [14] # opset=13, 14, ... + return [15] # opset=13, 14, ... def ir_version(): diff --git a/requirements.txt b/requirements.txt index 276c6b6b4..980273fb3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ numba numpy>=1.19.0 pandas pillow -scikit-learn>=0.24 +scikit-learn>=1.0 scipy>=1.7.0 Sphinx wheel @@ -47,5 +47,5 @@ xgboost # onnx onnx>=1.10.1 -onnxruntime>=1.8.1 -skl2onnx>=1.9.3 +onnxruntime>=1.9.0 +skl2onnx>=1.10.0 diff --git a/setup.py b/setup.py index a019cd1a2..e331ba245 100644 --- a/setup.py +++ b/setup.py @@ -384,14 +384,14 @@ def get_extensions(): install_requires=["pybind11", "numpy>=1.17", "onnx>=1.7.0", 'scipy>=1.0.0', 'jinja2', 'cython'], extras_require={ - 'npy': ['scikit-learn>=0.24', 'skl2onnx>=1.9.3'], - 'onnx_conv': ['scikit-learn>=0.24', 'skl2onnx>=1.9.3', + 'npy': ['scikit-learn>=0.24', 'skl2onnx>=1.10.0'], + 'onnx_conv': ['scikit-learn>=0.24', 'skl2onnx>=1.10.0', 'joblib', 'threadpoolctl', 'mlinsights>=0.3', 'lightgbm', 'xgboost'], - 'onnx_val': ['scikit-learn>=0.24', 'skl2onnx>=1.9.3', + 'onnx_val': ['scikit-learn>=0.24', 'skl2onnx>=1.10.0', 'onnxruntime>=1.6.0', 'joblib', 'threadpoolctl'], 'sklapi': ['scikit-learn>=0.24', 'joblib', 'threadpoolctl'], - 'all': ['scikit-learn>=0.24', 'skl2onnx>=1.9.3', + 'all': ['scikit-learn>=0.24', 'skl2onnx>=1.10.0', 'onnxruntime>=1.6.0', 'scipy' 'joblib', 'pandas', 'threadpoolctl', 'mlinsights>=0.3', 'lightgbm', 'xgboost', 'mlstatpy>=0.3.593'],