Supported Models

The vollo-trees-compiler converts ONNX models containing a TreeEnsembleRegressor node into Vollo programs.

The skl2onnx and onnxmltools python libraries provide functionality for converting decision tree regressors from various machine learning libraries into ONNX.

For example, to convert a scikit-learn RandomForestRegressor into a Vollo program:

import numpy as np
import vollo_trees_compiler as vtc
from sklearn.ensemble import RandomForestRegressor
from skl2onnx.common.data_types import FloatTensorType
from skl2onnx import convert_sklearn

n_estimators = 256
max_depth = 8
n_features = 256
n_samples = 2**max_depth
X = np.random.rand(n_samples, n_features)
y = np.random.rand(n_samples)

random_forest = RandomForestRegressor(
    n_estimators=n_estimators, max_depth=max_depth
)

# Fit some given data X, y
random_forest.fit(X, y)

# Convert the model to ONNX
initial_type = [("input", FloatTensorType([1, n_features]))]
onnx_model = convert_sklearn(
    random_forest,
    initial_types=initial_type,
    target_opset=12
)

with open("sklearn_model.onnx", "wb") as f:
  f.write(onnx_model.SerializeToString())

config = vtc.Config.ia420f_u128()

forest = vtc.Forest.from_onnx("sklearn_model.onnx")
program = forest.to_program_bf16(config)
program.save("sklearn_model.vollo")

See the sklearn-onnx documentation for details on converting from LightGBM, XGBoost and CatBoost to ONNX.