GBTree::Predict performance fix: removed excess thread_temp initialization
This commit is contained in:
parent
fd8439ffbc
commit
c0853967d5
@ -138,9 +138,12 @@ class GBTree : public IGradBooster {
|
|||||||
{
|
{
|
||||||
nthread = omp_get_num_threads();
|
nthread = omp_get_num_threads();
|
||||||
}
|
}
|
||||||
thread_temp.resize(nthread, tree::RegTree::FVec());
|
int prev_thread_temp_size = thread_temp.size();
|
||||||
for (int i = 0; i < nthread; ++i) {
|
if(prev_thread_temp_size < nthread) {
|
||||||
thread_temp[i].Init(mparam.num_feature);
|
thread_temp.resize(nthread, tree::RegTree::FVec());
|
||||||
|
for (int i = prev_thread_temp_size; i < nthread; ++i) {
|
||||||
|
thread_temp[i].Init(mparam.num_feature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::vector<float> &preds = *out_preds;
|
std::vector<float> &preds = *out_preds;
|
||||||
const size_t stride = info.num_row * mparam.num_output_group;
|
const size_t stride = info.num_row * mparam.num_output_group;
|
||||||
@ -194,9 +197,12 @@ class GBTree : public IGradBooster {
|
|||||||
{
|
{
|
||||||
nthread = omp_get_num_threads();
|
nthread = omp_get_num_threads();
|
||||||
}
|
}
|
||||||
thread_temp.resize(nthread, tree::RegTree::FVec());
|
int prev_thread_temp_size = thread_temp.size();
|
||||||
for (int i = 0; i < nthread; ++i) {
|
if(prev_thread_temp_size < nthread) {
|
||||||
thread_temp[i].Init(mparam.num_feature);
|
thread_temp.resize(nthread, tree::RegTree::FVec());
|
||||||
|
for (int i = prev_thread_temp_size; i < nthread; ++i) {
|
||||||
|
thread_temp[i].Init(mparam.num_feature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this->PredPath(p_fmat, info, out_preds, ntree_limit);
|
this->PredPath(p_fmat, info, out_preds, ntree_limit);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user