From 56a55d446d8eb2bae66a7b0616f526949b962f2f Mon Sep 17 00:00:00 2001 From: xadupre Date: Mon, 8 Apr 2024 11:00:18 +0000 Subject: [PATCH 1/2] better comments --- onnx_array_api/_command_lines_parser.py | 6 ++++++ onnx_array_api/reference/evaluator_yield.py | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/onnx_array_api/_command_lines_parser.py b/onnx_array_api/_command_lines_parser.py index 15ee153..d3b6feb 100644 --- a/onnx_array_api/_command_lines_parser.py +++ b/onnx_array_api/_command_lines_parser.py @@ -123,8 +123,14 @@ def _cmd_compare(argv: List[Any]): parser = get_parser_compare() args = parser.parse_args(argv[1:]) + if args.verbose in ("1", 1, "True", True): + print(f"[compare] first model {args.model1!r}") + print(f"[compare] second model {args.model2!r}") onx1 = onnx.load(args.model1) onx2 = onnx.load(args.model2) + if args.verbose in ("1", 1, "True", True): + print(f"[compare] first model has {len(onx1.graph.node)} nodes") + print(f"[compare] second model has {len(onx2.graph.node)} nodes") res1, res2, align, dc = compare_onnx_execution( onx1, onx2, diff --git a/onnx_array_api/reference/evaluator_yield.py b/onnx_array_api/reference/evaluator_yield.py index 88c8a1f..6d6ff48 100644 --- a/onnx_array_api/reference/evaluator_yield.py +++ b/onnx_array_api/reference/evaluator_yield.py @@ -642,7 +642,7 @@ def compare_onnx_execution( print("[compare_onnx_execution] loading first model") proto1 = load(model1) if isinstance(model1, str) else model1 if verbose: - print("[compare_onnx_execution] loading first model") + print("[compare_onnx_execution] loading second model") proto2 = load(model2) if isinstance(model2, str) else model2 res1 = list(_enumerate_result_no_execution(proto1)) res2 = list(_enumerate_result_no_execution(proto2)) @@ -650,7 +650,8 @@ def compare_onnx_execution( return if verbose: - print(f"[compare_onnx_execution] got {len(res2)} results") + print(f"[compare_onnx_execution] got {len(res1)} results (first model)") + print(f"[compare_onnx_execution] got {len(res2)} results (second model)") print("[compare_onnx_execution] compute edit distance") dc = DistanceExecution() _, align = dc.distance_sequence(res1, res2) From ff1a8e35cc54c159c6b728538284015e14fba204 Mon Sep 17 00:00:00 2001 From: Xavier Dupre Date: Mon, 8 Apr 2024 23:49:28 +0200 Subject: [PATCH 2/2] status --- _doc/examples/plot_benchmark_rf.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/_doc/examples/plot_benchmark_rf.py b/_doc/examples/plot_benchmark_rf.py index 423669c..c844d74 100644 --- a/_doc/examples/plot_benchmark_rf.py +++ b/_doc/examples/plot_benchmark_rf.py @@ -22,8 +22,6 @@ import numpy import pandas from lightgbm import LGBMRegressor -from onnxmltools.convert.lightgbm.operator_converters.LightGbm import convert_lightgbm -from onnxmltools.convert.xgboost.operator_converters.XGBoost import convert_xgboost from onnxruntime import InferenceSession, SessionOptions from psutil import cpu_count from sphinx_runpython.runpython import run_cmd @@ -33,9 +31,14 @@ from sklearn.ensemble import RandomForestRegressor from tqdm import tqdm from xgboost import XGBRegressor +from onnxmltools.convert.xgboost.operator_converters.XGBoost import convert_xgboost def skl2onnx_convert_lightgbm(scope, operator, container): + from onnxmltools.convert.lightgbm.operator_converters.LightGbm import ( + convert_lightgbm, + ) + options = scope.get_options(operator.raw_operator) if "split" in options: operator.split = options["split"]