[core] fix slow predict-caching with many classes (#3109)

* fix prediction caching inefficiency for multiclass

* silence some warnings

* redundant if

* workaround for R v3.4.3 bug; fixes #3081
This commit is contained in:
Vadim Khotilovich
2018-02-15 18:31:42 -06:00
committed by GitHub
parent cf19caa46a
commit 9ffe8596f2
5 changed files with 31 additions and 32 deletions

View File

@@ -100,12 +100,8 @@ class CPUPredictor : public Predictor {
const gbm::GBTreeModel& model, int tree_begin,
unsigned ntree_limit) {
// TODO(Rory): Check if this specialisation actually improves performance
if (model.param.num_output_group == 1) {
PredLoopSpecalize(dmat, out_preds, model, 1, tree_begin, ntree_limit);
} else {
PredLoopSpecalize(dmat, out_preds, model, model.param.num_output_group,
tree_begin, ntree_limit);
}
PredLoopSpecalize(dmat, out_preds, model, model.param.num_output_group,
tree_begin, ntree_limit);
}
public:
@@ -132,10 +128,9 @@ class CPUPredictor : public Predictor {
this->PredLoopInternal(dmat, out_preds, model, tree_begin, ntree_limit);
}
void UpdatePredictionCache(
const gbm::GBTreeModel& model,
std::vector<std::unique_ptr<TreeUpdater>>* updaters,
int num_new_trees) override {
void UpdatePredictionCache(const gbm::GBTreeModel& model,
std::vector<std::unique_ptr<TreeUpdater>>* updaters,
int num_new_trees) override {
int old_ntree = model.trees.size() - num_new_trees;
// update cache entry
for (auto& kv : cache_) {