forked from microsoft/LightGBM
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[profiling] Profile fast predict methods
- Loading branch information
Alberto Ferreira
committed
Apr 11, 2020
1 parent
ce384e9
commit d965ba1
Showing
3 changed files
with
67 additions
and
0 deletions.
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
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 vals[] = { 158.0, 311.4, 2.08207657E7, 10841.0, 0.0, 1.0, 2.0}; // 0.23829552970680268 | ||
|
||
int64_t dummy; | ||
|
||
double score[1]; | ||
for (size_t i = 0; i < 1e5; ++i) { | ||
LGBM_BoosterPredictForMatSingleRow(boosterHandle, vals, C_API_DTYPE_FLOAT64, 7, 1, C_API_PREDICT_NORMAL, num_iterations, "num_threads=1", &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,33 @@ | ||
#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[] = {158.0, 311.4, 2.08207657E7, 10841.0, 0.0, 1.0, 2.0}; // 0.23829552970680268 | ||
|
||
|
||
FastConfigHandle fastConfigHandle; | ||
LGBM_BoosterPredictForMatSingleRowFastInit(boosterHandle, values, C_API_DTYPE_FLOAT64, 7, "num_threads=1", &fastConfigHandle); | ||
|
||
int64_t dummy; | ||
double score[1]; | ||
for (size_t i = 0; i < 1e5; ++i) { | ||
LGBM_BoosterPredictForMatSingleRowFast(fastConfigHandle, C_API_PREDICT_NORMAL, num_iterations, &dummy, score); | ||
} | ||
|
||
LGBM_FastConfigFree(fastConfigHandle); | ||
|
||
cout << "len=" << dummy << endl; | ||
|
||
cout << "Score = " << score[0] << "\n"; | ||
|
||
cout << "end\n"; | ||
} |