Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Deprecated Functions in benchmark.py Related to treelite #80

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions benchmarks/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import onnxruntime as rt
import pandas as pd
import treelite
import treelite_runtime
import tl2cgen
from onnxconverter_common import FloatTensorType

from benchmarks.train_NYC_model import feature_enginering
from train_NYC_model import feature_enginering
from lleaves import Model


Expand Down Expand Up @@ -58,20 +58,21 @@ def _setup(self, data, n_threads):
# disable thread pinning, which modifies (and never resets!) process-global pthreads state
os.environ["TREELITE_BIND_THREADS"] = "0"
treelite_model = treelite.Model.load(self.model_file, model_format="lightgbm")
treelite_model.export_lib(
tl2cgen.export_lib(
model=treelite_model,
toolchain="gcc",
libpath="/tmp/treelite_model.so",
params={"parallel_comp": 4},
verbose=False,
)
self.model = treelite_runtime.Predictor(
self.model = tl2cgen.Predictor(
"/tmp/treelite_model.so",
nthread=n_threads,
)

def predict(self, data, index, batchsize, n_threads):
return self.model.predict(
treelite_runtime.DMatrix(data[index : index + batchsize])
tl2cgen.DMatrix(data[index : index + batchsize])
)


Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dependencies:
# benchmarks
- benchmark
- treelite
- tlc2gen
- compilers
- onnxruntime
- onnxmltools
Expand Down
Loading