From 9813a47e63f2afc3b3be48910c54de7e846e29ba Mon Sep 17 00:00:00 2001 From: Simon Boehm Date: Sun, 26 Sep 2021 18:21:43 +0200 Subject: [PATCH] Test: Default blocksize yields 3 blocks (NYC_Taxi) --- README.md | 8 ++++---- tests/test_compile_flags.py | 9 +++++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6daf0e7..1e62390 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/tests/test_compile_flags.py b/tests/test_compile_flags.py index bacd6ad..b63fd1b 100644 --- a/tests/test_compile_flags.py +++ b/tests/test_compile_flags.py @@ -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") @@ -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