-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Feat/optimize single prediction #2992
Merged
StrikerRUS
merged 15 commits into
microsoft:master
from
AlbertoEAF:feat/optimize-single-prediction
Jul 15, 2020
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9895b39
[performance] Add Fast methods to C API for SingleRow Predictions
524233d
Code syle cleanup
c9288c7
Fix lint errors
05e2269
[performance] Revert FastConfig improvement to pass data at init
AlbertoEAF a507d3e
[performance] Introduce Fast variants for SingleRow predictors.
AlbertoEAF 41d3465
[tests/profiling] Profile Fast predict methods
1da1ae3
Update comment on CMakeLists.
AlbertoEAF 462f8c3
Fix doxygen-introduced issue (#threads)
AlbertoEAF c8d9724
Fix conflicts due to new RowFunctionFromCSR signature in master
AlbertoEAF 4813251
Change FastConfig ncol to int32_t.
AlbertoEAF e36381e
Removed profiling folder
AlbertoEAF 1062588
fix doxygen typo include/LightGBM/c_api.h
AlbertoEAF 3dd7a8e
fix doxygen typo include/LightGBM/c_api.h
AlbertoEAF 08a7f92
fix doxygen typo include/LightGBM/c_api.h
AlbertoEAF d8c37c0
Doxygen: change new docstrings to double back-quote
AlbertoEAF File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <iostream> | ||
#include "LightGBM/c_api.h" | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
cout << "start\n"; | ||
|
||
BoosterHandle boosterHandle; | ||
int num_iterations; | ||
LGBM_BoosterCreateFromModelfile("./LightGBM_model.txt", &num_iterations, &boosterHandle); | ||
cout << "Model iterations " << num_iterations<< "\n"; | ||
|
||
double values[] = {1.000000000000000000e+00,8.692932128906250000e-01,-6.350818276405334473e-01,2.256902605295181274e-01,3.274700641632080078e-01,-6.899932026863098145e-01,7.542022466659545898e-01,-2.485731393098831177e-01,-1.092063903808593750e+00,0.000000000000000000e+00,1.374992132186889648e+00,-6.536741852760314941e-01,9.303491115570068359e-01,1.107436060905456543e+00,1.138904333114624023e+00,-1.578198313713073730e+00,-1.046985387802124023e+00,0.000000000000000000e+00,6.579295396804809570e-01,-1.045456994324922562e-02,-4.576716944575309753e-02,3.101961374282836914e+00,1.353760004043579102e+00,9.795631170272827148e-01,9.780761599540710449e-01,9.200048446655273438e-01,7.216574549674987793e-01,9.887509346008300781e-01,8.766783475875854492e-01}; // score = 0.487278 | ||
|
||
int64_t dummy; | ||
|
||
double score[1]; | ||
for (size_t i = 0; i < 3e5; ++i) { | ||
LGBM_BoosterPredictForMatSingleRow(boosterHandle, values, C_API_DTYPE_FLOAT64, 28, 1, C_API_PREDICT_NORMAL, num_iterations, "", &dummy, score); | ||
} | ||
cout << "len=" << dummy << endl; | ||
|
||
cout << "Score = " << score[0] << "\n"; | ||
|
||
cout << "end\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <iostream> | ||
#include "LightGBM/c_api.h" | ||
|
||
using namespace std; | ||
|
||
int main() { | ||
cout << "start\n"; | ||
|
||
BoosterHandle boosterHandle; | ||
int num_iterations; | ||
LGBM_BoosterCreateFromModelfile("./LightGBM_model.txt", &num_iterations, &boosterHandle); | ||
cout << "Model iterations " << num_iterations<< "\n"; | ||
|
||
double values[] = {1.000000000000000000e+00,8.692932128906250000e-01,-6.350818276405334473e-01,2.256902605295181274e-01,3.274700641632080078e-01,-6.899932026863098145e-01,7.542022466659545898e-01,-2.485731393098831177e-01,-1.092063903808593750e+00,0.000000000000000000e+00,1.374992132186889648e+00,-6.536741852760314941e-01,9.303491115570068359e-01,1.107436060905456543e+00,1.138904333114624023e+00,-1.578198313713073730e+00,-1.046985387802124023e+00,0.000000000000000000e+00,6.579295396804809570e-01,-1.045456994324922562e-02,-4.576716944575309753e-02,3.101961374282836914e+00,1.353760004043579102e+00,9.795631170272827148e-01,9.780761599540710449e-01,9.200048446655273438e-01,7.216574549674987793e-01,9.887509346008300781e-01,8.766783475875854492e-01}; // score = 0.487278 | ||
|
||
FastConfigHandle fastConfigHandle; | ||
LGBM_BoosterPredictForMatSingleRowFastInit(boosterHandle, C_API_DTYPE_FLOAT64, 28, "", &fastConfigHandle); | ||
|
||
int64_t dummy_out_len; | ||
double score[1]; | ||
for (size_t i = 0; i < 3e5; ++i) { | ||
LGBM_BoosterPredictForMatSingleRowFast(fastConfigHandle, values, C_API_PREDICT_NORMAL, num_iterations, &dummy_out_len, score); | ||
} | ||
|
||
LGBM_FastConfigFree(fastConfigHandle); | ||
|
||
cout << "len=" << dummy_out_len << endl; | ||
|
||
cout << "Score = " << score[0] << "\n"; | ||
|
||
cout << "end\n"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure that we should add profiling part into the repo... @guolinke WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is the decision should I also remove the new profiling folder and its contents?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's wait for some other opinions.
I think yes. Right now
profiling
folder looks a little bit unnatural here. I believe we should transform it into a test during the work on #261 or integrate it into other benchmarks (https://github.com/guolinke/boosting_tree_benchmarks).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gently ping @guolinke for your opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, it is better to remove this in the official repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we can keep a branch for the profiling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guolinke I believe that a separate repo (just like for benchmarks) will be more intuitive.
@AlbertoEAF OK, seems that we got a decision. Please exclude profiling from this PR, but also save the corresponding code for some time somewhere in your fork.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the input :)
I just removed it and kept it in a branch in my fork.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I've just come the thought that you can simply post the content of profiling files or the output of
git diff
command (I remember there were not so many files) in comment for this PR or original issue. 🙂