You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I create an Onnx Runtime model with python -m onnxruntime.tools.convert_onnx_models_to_ort to convert a Light GBM .onnx model the resulting .ort is 2-3 times larger than the original .onnx file. I think I understand that the ORT format primarily allows us to have a smaller build, but I was surprised that the model size increased.
Is this expected in general? Or could it be specific to LGBM/tree based model?
To reproduce
from onnxmltools import convert_lightgbm
from onnxmltools.convert.lightgbm.operator_converters.LightGbm import (
convert_lightgbm,
)
from skl2onnx import convert_sklearn, update_registered_converter
from skl2onnx.common.data_types import FloatTensorType
from skl2onnx.common.shape_calculator import (
calculate_linear_classifier_output_shapes,
)
from lightgbm import LGBMClassifier
from sklearn.datasets import load_iris
X, y = load_iris(return_X_y=True)
model = LGBMClassifier().fit(X, y)
update_registered_converter(
LGBMClassifier,
"LightGbmLGBMClassifier",
calculate_linear_classifier_output_shapes,
convert_lightgbm,
options={"nocl": [True, False], "zipmap": [True, False]},
)
dim = len(model.feature_name_)
initial_type = [("float_input", FloatTensorType([None, dim]))]
onnx_model = convert_sklearn(
model,
initial_types=initial_type,
options={id(model): {"zipmap": False, "nocl": True}},
)
with open("lgbm_iris_test.onnx", "wb") as f:
f.write(onnx_model.SerializeToString())
Removing platform:web tag as this is not really a Web issue. Not sure what the appropriate tag is (probably a new tag tools as this is a question about the ONNX->ORT model conversion tool ?)
It's expected when the model has traditional ML operators as we don't currently pack integers. e.g. the ids in a TreeEnsembleClassifier node would use 64 bits in the ORT format model flatbuffer but would be packed into just the required bits when saved in an onnx protobuf.
We've considered adding this but there's never been a production use case that required it. Doing so would also mean you couldn't reference the data directly in the ORT format model flatbuffer so it would potentially cost more memory at runtime.
This issue has been automatically marked as stale due to inactivity and will be closed in 7 days if no further activity occurs. If further support is needed, please provide an update and/or more details.
Describe the issue
When I create an Onnx Runtime model with
python -m onnxruntime.tools.convert_onnx_models_to_ort
to convert a Light GBM.onnx
model the resulting.ort
is 2-3 times larger than the original.onnx
file. I think I understand that the ORT format primarily allows us to have a smaller build, but I was surprised that the model size increased.Is this expected in general? Or could it be specific to LGBM/tree based model?
To reproduce
Gives
lgbm_iris_test.onnx
with size of 142.3kbpython -m onnxruntime.tools.convert_onnx_models_to_ort "lgbm_iris_test.onnx" --output_dir "lgbm_iris_ort"
Results in
lgnb_iris_ort/lgbm_iris_test.ort
with size 337kbUrgency
No response
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.16
Execution Provider
Other / Unknown
The text was updated successfully, but these errors were encountered: