Skip to content

Commit

Permalink
Test: Default blocksize yields 3 blocks (NYC_Taxi)
Browse files Browse the repository at this point in the history
  • Loading branch information
siboehm committed Sep 26, 2021
1 parent adc6600 commit 9813a47
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

A LLVM-based compiler for LightGBM decision trees.

`lleaves` converts trained LightGBM models to optimized machine code, speeding-up inference by ≥10x.
`lleaves` converts trained LightGBM models to optimized machine code, speeding-up prediction by ≥10x.

## Example

Expand Down Expand Up @@ -51,9 +51,9 @@ mix of categorical and numerical features.
|``lleaves`` | 5.90ms | 56.96ms | 388.88ms |

## Advanced usage
To avoid any Python overhead during inference you can link against the generated binary.
For an example of how to do this see `benchmarks/c_bench/`.
The function signature might change between major versions.
To avoid any Python overhead during prediction you can link directly against the generated binary.
See `benchmarks/c_bench/` for an example of how to do this.
The function signature can change between major versions.

## Development
```bash
Expand Down
9 changes: 7 additions & 2 deletions tests/test_compile_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ def NYC_data():
return feature_enginering().fit_transform(df).astype(np.float64)


# we don't test the default, which is 34
@pytest.mark.parametrize("blocksize", [1, 100])
@pytest.mark.parametrize("blocksize", [1, 34, 100])
def test_cache_blocksize(blocksize, NYC_data):
llvm_model = Model(model_file="tests/models/NYC_taxi/model.txt")
lgbm_model = Booster(model_file="tests/models/NYC_taxi/model.txt")
Expand All @@ -39,6 +38,12 @@ def test_cache_blocksize(blocksize, NYC_data):
assert "instr-block-setup.1:" in stdout
assert "instr-block-setup.99:" in stdout
assert "instr-block-setup.100:" not in stdout
if blocksize == 34:
# NYC_taxi has 100 trees, hence blocksize 34 should create 3 blocks
assert "instr-block-setup.1:" in stdout
assert "instr-block-setup.2:" in stdout
assert "instr-block-setup.3:" not in stdout
assert "instr-block-setup.4:" not in stdout
if blocksize == 100:
assert "instr-block-setup.1:" not in stdout
assert "instr-block-setup.2:" not in stdout
Expand Down

0 comments on commit 9813a47

Please sign in to comment.