Skip to content

Commit

Permalink
Upgrade CI to onnx==1.16.0 (#689)
Browse files Browse the repository at this point in the history
* upgrade to onnx==1.16.0

Signed-off-by: Xavier Dupre <[email protected]>

* doc

Signed-off-by: Xavier Dupre <[email protected]>

* black

Signed-off-by: Xavier Dupre <[email protected]>

* black

Signed-off-by: Xavier Dupre <[email protected]>

* fix opset

Signed-off-by: Xavier Dupre <[email protected]>

---------

Signed-off-by: Xavier Dupre <[email protected]>
  • Loading branch information
xadupre authored Apr 3, 2024
1 parent b1e1068 commit a105247
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 46 deletions.
6 changes: 3 additions & 3 deletions .azure-pipelines/linux-conda-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
strategy:
matrix:

Python311-1150-RT117-xgb2-lgbm40:
Python311-1160-RT1171-xgb2-lgbm40:
python.version: '3.11'
ONNX_PATH: 'onnx==1.15.0'
ONNXRT_PATH: 'onnxruntime==1.17'
ONNX_PATH: 'onnx==1.16.0'
ONNXRT_PATH: 'onnxruntime==1.17.1'
COREML_PATH: NONE
lightgbm.version: '>=4.0'
xgboost.version: '>=2'
Expand Down
22 changes: 11 additions & 11 deletions .azure-pipelines/win32-conda-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,61 +15,61 @@ jobs:
strategy:
matrix:

Python311-1150-RT117:
Python311-1160-RT1171:
python.version: '3.11'
ONNX_PATH: 'onnx==1.15.0'
ONNXRT_PATH: 'onnxruntime==1.17'
ONNX_PATH: 'onnx==1.16.0'
ONNXRT_PATH: 'onnxruntime==1.17.1'
COREML_PATH: NONE
numpy.version: ''
xgboost.version: '2.0.2'
xgboost.version: '>=2.0'

Python311-1150-RT1163:
python.version: '3.11'
ONNX_PATH: 'onnx==1.15.0'
ONNXRT_PATH: 'onnxruntime==1.16.3'
COREML_PATH: NONE
numpy.version: ''
xgboost.version: '2.0.2'
xgboost.version: '==2.0.2'

Python311-1150-RT1162:
python.version: '3.11'
ONNX_PATH: 'onnx==1.15.0'
ONNXRT_PATH: 'onnxruntime==1.16.2'
COREML_PATH: NONE
numpy.version: ''
xgboost.version: '2.0.2'
xgboost.version: '==2.0.2'

Python311-1141-RT1162:
python.version: '3.11'
ONNX_PATH: 'onnx==1.14.1'
ONNXRT_PATH: 'onnxruntime==1.16.2'
COREML_PATH: NONE
numpy.version: ''
xgboost.version: '1.7.5'
xgboost.version: '==1.7.5'

Python310-1141-RT1151:
python.version: '3.10'
ONNX_PATH: 'onnx==1.14.1'
ONNXRT_PATH: 'onnxruntime==1.15.1'
COREML_PATH: NONE
numpy.version: ''
xgboost.version: '1.7.5'
xgboost.version: '==1.7.5'

Python310-1141-RT1140:
python.version: '3.10'
ONNX_PATH: 'onnx==1.14.1'
ONNXRT_PATH: onnxruntime==1.14.0
COREML_PATH: NONE
numpy.version: ''
xgboost.version: '1.7.5'
xgboost.version: '==1.7.5'

Python39-1141-RT1140:
python.version: '3.9'
ONNX_PATH: 'onnx==1.14.1'
ONNXRT_PATH: onnxruntime==1.14.0
COREML_PATH: NONE
numpy.version: ''
xgboost.version: '1.7.5'
xgboost.version: '==1.7.5'

maxParallel: 3

Expand All @@ -96,7 +96,7 @@ jobs:
call activate py$(python.version)
python -m pip install --upgrade scikit-learn
python -m pip install --upgrade lightgbm
python -m pip install "xgboost==$(xgboost.version)"
python -m pip install "xgboost$(xgboost.version)"
displayName: 'Install scikit-learn'
- script: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/black-ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@193ee766ca496871f93621d6b58d57a6564ff81b # stable 23.7.0
- uses: psf/black@e42f1ffbe159018c8e887f775c0fd7b51b3cf787 # stable 24.3.0
with:
options: "--diff --check"
src: "."
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 1.13.0 (development)

* Handle issue with binary classifier setting output to [N,1] vs [N,2],
[#681](https://github.com/onnx/onnxmltools/pull/681)
* Add missing dependency onnxconverter_common, fix multi regression with xgboost,
[#679](https://github.com/onnx/onnxmltools/pull/679),
fixes issues [No module named 'onnxconverter_common'](https://github.com/onnx/onnxmltools/issues/673),
Expand Down
18 changes: 9 additions & 9 deletions onnxmltools/convert/coreml/operator_converters/TreeEnsemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def convert_tree_ensemble_model(scope, operator, container):
op_type = "TreeEnsembleClassifier"
prefix = "class"
nodes = raw_model.treeEnsembleClassifier.treeEnsemble.nodes
attrs[
"base_values"
] = raw_model.treeEnsembleClassifier.treeEnsemble.basePredictionValue
attrs["base_values"] = (
raw_model.treeEnsembleClassifier.treeEnsemble.basePredictionValue
)
attrs["post_transform"] = get_onnx_tree_post_transform(
raw_model.treeEnsembleClassifier.postEvaluationTransform
)
Expand All @@ -72,12 +72,12 @@ def convert_tree_ensemble_model(scope, operator, container):
op_type = "TreeEnsembleRegressor"
prefix = "target"
nodes = raw_model.treeEnsembleRegressor.treeEnsemble.nodes
attrs[
"base_values"
] = raw_model.treeEnsembleRegressor.treeEnsemble.basePredictionValue
attrs[
"n_targets"
] = raw_model.treeEnsembleRegressor.treeEnsemble.numPredictionDimensions
attrs["base_values"] = (
raw_model.treeEnsembleRegressor.treeEnsemble.basePredictionValue
)
attrs["n_targets"] = (
raw_model.treeEnsembleRegressor.treeEnsemble.numPredictionDimensions
)
attrs["post_transform"] = get_onnx_tree_post_transform(
raw_model.treeEnsembleRegressor.postEvaluationTransform
)
Expand Down
48 changes: 30 additions & 18 deletions onnxmltools/convert/sparkml/ops_input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,16 @@ def build_io_name_map():
lambda model: [model.getOrDefault("predictionCol")],
),
"pyspark.ml.feature.ImputerModel": (
lambda model: model.getOrDefault("inputCols")
if model.isSet("inputCols")
else [model.getOrDefault("inputCol")],
lambda model: model.getOrDefault("outputCols")
if model.isSet("outputCols")
else [model.getOrDefault("outputCol")],
lambda model: (
model.getOrDefault("inputCols")
if model.isSet("inputCols")
else [model.getOrDefault("inputCol")]
),
lambda model: (
model.getOrDefault("outputCols")
if model.isSet("outputCols")
else [model.getOrDefault("outputCol")]
),
),
"pyspark.ml.feature.MaxAbsScalerModel": (
lambda model: [model.getOrDefault("inputCol")],
Expand Down Expand Up @@ -177,20 +181,28 @@ def build_io_name_map():
],
),
"pyspark.ml.feature.OneHotEncoderModel": (
lambda model: model.getOrDefault("inputCols")
if model.isSet("inputCols")
else [model.getOrDefault("inputCol")],
lambda model: model.getOrDefault("outputCols")
if model.isSet("outputCols")
else [model.getOrDefault("outputCol")],
lambda model: (
model.getOrDefault("inputCols")
if model.isSet("inputCols")
else [model.getOrDefault("inputCol")]
),
lambda model: (
model.getOrDefault("outputCols")
if model.isSet("outputCols")
else [model.getOrDefault("outputCol")]
),
),
"pyspark.ml.feature.StringIndexerModel": (
lambda model: model.getOrDefault("inputCols")
if model.isSet("inputCols")
else [model.getOrDefault("inputCol")],
lambda model: model.getOrDefault("outputCols")
if model.isSet("outputCols")
else [model.getOrDefault("outputCol")],
lambda model: (
model.getOrDefault("inputCols")
if model.isSet("inputCols")
else [model.getOrDefault("inputCol")]
),
lambda model: (
model.getOrDefault("outputCols")
if model.isSet("outputCols")
else [model.getOrDefault("outputCol")]
),
),
"pyspark.ml.feature.VectorAssembler": (
lambda model: model.getOrDefault("inputCols"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def calculate_xgboost_classifier_output_shapes(operator):
objective = params["objective"]
n_estimators = get_n_estimators_classifier(xgb_node, params, js_trees)
num_class = params.get("num_class", None)

if objective == "binary:logistic":
ncl = 2
elif num_class is not None:
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ exclude = [
# Same as Black.
line-length = 95

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"**/__init__.py" = ["F401"]
"onnxmltools/convert/coreml/operator_converters/GLMClassifier.py" = ["E501"]
"onnxmltools/convert/coreml/operator_converters/SVC.py" = ["E501"]
Expand Down
4 changes: 3 additions & 1 deletion tests/xgboost/test_xgboost_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def xgbregressor_shape_calculator(operator):
initial_type = [("float_input", FloatTensorType([None, X.shape[1]]))]

# Convert XGBoost model to ONNX
onnx_model = convert_sklearn(model, initial_types=initial_type, target_opset=12)
onnx_model = convert_sklearn(
model, initial_types=initial_type, target_opset={"": 12, "ai.onnx.ml": 3}
)
self.assertIn("dim_value: 2", str(onnx_model.graph.output))

sess = onnxruntime.InferenceSession(
Expand Down

0 comments on commit a105247

Please sign in to comment.