siboehm / lleaves

Compiler for LightGBM gradient-boosted trees, based on LLVM. Speeds up prediction by ≥10x.
https://lleaves.readthedocs.io/en/latest/
MIT License
354 stars 29 forks source link

Compile using pre-existing cache file #53

Closed fitzpk closed 1 year ago

fitzpk commented 1 year ago

Hi there,

Based on the docs and other issues here it seems that once compile is called the first time we can cache a file, and then run the same code again to avoid compiling additional times.

If I already created the cached file and have it stored, how would I go about using this file on the first compile run in a different script?

siboehm commented 1 year ago

You just call compile(cache=)! There's nothing fancy happening regarding the cache file, if you pass the cache= args and the file exists, then lleaves loads it and calls the froot_func_name function in that object file to execute the tree.

So if you want to use it from a new script, just pass cache= and make sure the froot_fun_name is the same as you used to compile (or leave it empty to use the default).

fitzpk commented 1 year ago

Ah ok thank you this did help, I have things working now so just a blunder on my part - thank you again for clarifying!