From 4b892c2b30cf1a65f6bd4ce33d5c7cd18b8fa43b Mon Sep 17 00:00:00 2001 From: trivialfis Date: Sun, 7 Oct 2018 07:22:15 +1300 Subject: [PATCH] Remove obsoleted QuantileHistMaker. (#3761) Fix #3755. --- src/tree/updater_histmaker.cc | 124 ---------------------------------- 1 file changed, 124 deletions(-) diff --git a/src/tree/updater_histmaker.cc b/src/tree/updater_histmaker.cc index e0167afa4..0beb623e2 100644 --- a/src/tree/updater_histmaker.cc +++ b/src/tree/updater_histmaker.cc @@ -746,130 +746,6 @@ class GlobalProposalHistMaker: public CQHistMaker { std::vector cached_cut_; }; - -template -class QuantileHistMaker: public HistMaker { - protected: - using WXQSketch = common::WXQuantileSketch; - void ResetPosAndPropose(const std::vector &gpair, - DMatrix *p_fmat, - const std::vector &fset, - const RegTree &tree) override { - const MetaInfo &info = p_fmat->Info(); - // initialize the data structure - const int nthread = omp_get_max_threads(); - sketchs_.resize(this->qexpand_.size() * tree.param.num_feature); - for (size_t i = 0; i < sketchs_.size(); ++i) { - sketchs_[i].Init(info.num_row_, this->param_.sketch_eps); - } - // start accumulating statistics - for (const auto &batch : p_fmat->GetRowBatches()) { - // parallel convert to column major format - common::ParallelGroupBuilder - builder(&col_ptr_, &col_data_, &thread_col_ptr_); - builder.InitBudget(tree.param.num_feature, nthread); - - const bst_omp_uint nbatch = static_cast(batch.Size()); - #pragma omp parallel for schedule(static) - for (bst_omp_uint i = 0; i < nbatch; ++i) { - SparsePage::Inst inst = batch[i]; - const bst_uint ridx = static_cast(batch.base_rowid + i); - int nid = this->position_[ridx]; - if (nid >= 0) { - if (!tree[nid].IsLeaf()) { - this->position_[ridx] = nid = HistMaker::NextLevel(inst, tree, nid); - } - if (this->node2workindex_[nid] < 0) { - this->position_[ridx] = ~nid; - } else { - for (auto& ins : inst) { - builder.AddBudget(ins.index, omp_get_thread_num()); - } - } - } - } - builder.InitStorage(); - #pragma omp parallel for schedule(static) - for (bst_omp_uint i = 0; i < nbatch; ++i) { - SparsePage::Inst inst = batch[i]; - const bst_uint ridx = static_cast(batch.base_rowid + i); - const int nid = this->position_[ridx]; - if (nid >= 0) { - for (auto& ins : inst) { - builder.Push(ins.index, - Entry(nid, ins.fvalue), - omp_get_thread_num()); - } - } - } - // start putting things into sketch - const bst_omp_uint nfeat = col_ptr_.size() - 1; - #pragma omp parallel for schedule(dynamic, 1) - for (bst_omp_uint k = 0; k < nfeat; ++k) { - for (size_t i = col_ptr_[k]; i < col_ptr_[k+1]; ++i) { - const Entry &e = col_data_[i]; - const int wid = this->node2workindex_[e.index]; - sketchs_[wid * tree.param.num_feature + k].Push(e.fvalue, gpair[e.index].GetHess()); - } - } - } - // setup maximum size - unsigned max_size = this->param_.MaxSketchSize(); - // synchronize sketch - summary_array_.resize(sketchs_.size()); - for (size_t i = 0; i < sketchs_.size(); ++i) { - common::WQuantileSketch::SummaryContainer out; - sketchs_[i].GetSummary(&out); - summary_array_[i].Reserve(max_size); - summary_array_[i].SetPrune(out, max_size); - } - - size_t nbytes = WXQSketch::SummaryContainer::CalcMemCost(max_size); - sreducer_.Allreduce(dmlc::BeginPtr(summary_array_), nbytes, summary_array_.size()); - // now we get the final result of sketch, setup the cut - this->wspace_.cut.clear(); - this->wspace_.rptr.clear(); - this->wspace_.rptr.push_back(0); - for (size_t wid = 0; wid < this->qexpand_.size(); ++wid) { - for (int fid = 0; fid < tree.param.num_feature; ++fid) { - const WXQSketch::Summary &a = summary_array_[wid * tree.param.num_feature + fid]; - for (size_t i = 1; i < a.size; ++i) { - bst_float cpt = a.data[i].value - kRtEps; - if (i == 1 || cpt > this->wspace_.cut.back()) { - this->wspace_.cut.push_back(cpt); - } - } - // push a value that is greater than anything - if (a.size != 0) { - bst_float cpt = a.data[a.size - 1].value; - // this must be bigger than last value in a scale - bst_float last = cpt + fabs(cpt) + kRtEps; - this->wspace_.cut.push_back(last); - } - this->wspace_.rptr.push_back(this->wspace_.cut.size()); - } - // reserve last value for global statistics - this->wspace_.cut.push_back(0.0f); - this->wspace_.rptr.push_back(this->wspace_.cut.size()); - } - CHECK_EQ(this->wspace_.rptr.size(), - (tree.param.num_feature + 1) * this->qexpand_.size() + 1); - } - - private: - // summary array - std::vector summary_array_; - // reducer for summary - rabit::SerializeReducer sreducer_; - // local temp column data structure - std::vector col_ptr_; - // local storage of column data - std::vector col_data_; - std::vector > thread_col_ptr_; - // per node, per feature sketch - std::vector > sketchs_; -}; - XGBOOST_REGISTER_TREE_UPDATER(LocalHistMaker, "grow_local_histmaker") .describe("Tree constructor that uses approximate histogram construction.") .set_body([]() {