diff --git a/include/xgboost/data.h b/include/xgboost/data.h index 9d954ae62..449c785b4 100644 --- a/include/xgboost/data.h +++ b/include/xgboost/data.h @@ -421,7 +421,7 @@ class BatchIterator { return *(*impl_); } - bool operator!=(const BatchIterator& rhs) const { + bool operator!=(const BatchIterator&) const { CHECK(impl_ != nullptr); return !impl_->AtEnd(); } diff --git a/include/xgboost/predictor.h b/include/xgboost/predictor.h index 915fe0a9e..9e448c2f1 100644 --- a/include/xgboost/predictor.h +++ b/include/xgboost/predictor.h @@ -117,7 +117,7 @@ class Predictor { * * \param cfg The configuration. */ - virtual void Configure(const std::vector>& cfg); + virtual void Configure(const std::vector>&); /** * \brief Generate batch predictions for a given feature matrix. May use diff --git a/src/c_api/c_api.cc b/src/c_api/c_api.cc index d91b179f0..e562acbd3 100644 --- a/src/c_api/c_api.cc +++ b/src/c_api/c_api.cc @@ -163,7 +163,7 @@ XGB_DLL int XGDMatrixCreateFromCSCEx(const size_t* col_ptr, const unsigned* indices, const bst_float* data, size_t nindptr, - size_t nelem, + size_t, size_t num_row, DMatrixHandle* out) { API_BEGIN(); diff --git a/src/common/hist_util.cc b/src/common/hist_util.cc index 01ed4bfc4..09a09897a 100644 --- a/src/common/hist_util.cc +++ b/src/common/hist_util.cc @@ -163,7 +163,7 @@ void GHistIndexMatrix::Init(DMatrix* p_fmat, int max_bins) { } else { common::Span index_data_span = {index.data(), n_index}; SetIndexData(index_data_span, batch_threads, batch, rbegin, nbins, - [](auto idx, auto i) { return idx; }); + [](auto idx, auto) { return idx; }); } #pragma omp parallel for num_threads(nthread) schedule(static) diff --git a/src/common/version.cc b/src/common/version.cc index e9d4fe9d1..6f1af9fa6 100644 --- a/src/common/version.cc +++ b/src/common/version.cc @@ -16,7 +16,7 @@ namespace xgboost { const Version::TripletT Version::kInvalid {-1, -1, -1}; -Version::TripletT Version::Load(Json const& in, bool check) { +Version::TripletT Version::Load(Json const& in) { if (get(in).find("version") == get(in).cend()) { return kInvalid; } diff --git a/src/common/version.h b/src/common/version.h index 96885f6a8..f143ed36a 100644 --- a/src/common/version.h +++ b/src/common/version.h @@ -18,7 +18,7 @@ struct Version { static const TripletT kInvalid; // Save/Load version info to Json document - static TripletT Load(Json const& in, bool check = false); + static TripletT Load(Json const& in); static void Save(Json* out); // Save/Load version info to dmlc::Stream diff --git a/src/data/sparse_page_dmatrix.h b/src/data/sparse_page_dmatrix.h index 393172658..00cbdbfbe 100644 --- a/src/data/sparse_page_dmatrix.h +++ b/src/data/sparse_page_dmatrix.h @@ -37,7 +37,7 @@ class SparsePageDMatrix : public DMatrix { const MetaInfo& Info() const override; bool SingleColBlock() const override { return false; } - DMatrix *Slice(common::Span ridxs) override { + DMatrix *Slice(common::Span) override { LOG(FATAL) << "Slicing DMatrix is not supported for external memory."; return nullptr; } diff --git a/src/gbm/gblinear_model.h b/src/gbm/gblinear_model.h index 6e3e83105..9f4888d82 100644 --- a/src/gbm/gblinear_model.h +++ b/src/gbm/gblinear_model.h @@ -49,7 +49,7 @@ class GBLinearModel : public Model { public: explicit GBLinearModel(LearnerModelParam const* learner_model_param) : learner_model_param {learner_model_param} {} - void Configure(Args const &cfg) { } + void Configure(Args const &) { } // weight for each of feature, bias is the last one std::vector weight; diff --git a/src/learner.cc b/src/learner.cc index 85ca3a503..34fe19cd1 100644 --- a/src/learner.cc +++ b/src/learner.cc @@ -341,7 +341,7 @@ class LearnerConfiguration : public Learner { void LoadConfig(Json const& in) override { CHECK(IsA(in)); - Version::Load(in, true); + Version::Load(in); auto const& learner_parameters = get(in["learner"]); FromJson(learner_parameters.at("learner_train_param"), &tparam_); @@ -623,7 +623,7 @@ class LearnerIO : public LearnerConfiguration { void LoadModel(Json const& in) override { CHECK(IsA(in)); - Version::Load(in, false); + Version::Load(in); auto const& learner = get(in["learner"]); mparam_.FromJson(learner.at("learner_model_param")); diff --git a/src/metric/metric.cc b/src/metric/metric.cc index 2e1392e30..e2ee04cf4 100644 --- a/src/metric/metric.cc +++ b/src/metric/metric.cc @@ -11,7 +11,7 @@ namespace xgboost { template -Metric* CreateMetricImpl(const std::string& name, GenericParameter const* tparam) { +Metric* CreateMetricImpl(const std::string& name) { std::string buf = name; std::string prefix = name; const char* param; @@ -44,7 +44,7 @@ Metric* CreateMetricImpl(const std::string& name, GenericParameter const* tparam Metric * Metric::Create(const std::string& name, GenericParameter const* tparam) { - auto metric = CreateMetricImpl(name, tparam); + auto metric = CreateMetricImpl(name); if (metric == nullptr) { LOG(FATAL) << "Unknown metric function " << name; } @@ -55,7 +55,7 @@ Metric::Create(const std::string& name, GenericParameter const* tparam) { Metric * GPUMetric::CreateGPUMetric(const std::string& name, GenericParameter const* tparam) { - auto metric = CreateMetricImpl(name, tparam); + auto metric = CreateMetricImpl(name); if (metric == nullptr) { LOG(WARNING) << "Cannot find a GPU metric builder for metric " << name << ". Resorting to the CPU builder"; diff --git a/src/metric/rank_metric.cc b/src/metric/rank_metric.cc index b55c764d2..cfbae468c 100644 --- a/src/metric/rank_metric.cc +++ b/src/metric/rank_metric.cc @@ -55,13 +55,13 @@ class PerInstanceWeightPolicy { public: inline static xgboost::bst_float GetWeightOfInstance(const xgboost::MetaInfo& info, - unsigned instance_id, unsigned group_id) { + unsigned instance_id, unsigned) { return info.GetWeight(instance_id); } inline static xgboost::bst_float GetWeightOfSortedRecord(const xgboost::MetaInfo& info, const PredIndPairContainer& rec, - unsigned record_id, unsigned group_id) { + unsigned record_id, unsigned) { return info.GetWeight(rec[record_id].second); } }; @@ -70,14 +70,14 @@ class PerGroupWeightPolicy { public: inline static xgboost::bst_float GetWeightOfInstance(const xgboost::MetaInfo& info, - unsigned instance_id, unsigned group_id) { + unsigned, unsigned group_id) { return info.GetWeight(group_id); } inline static xgboost::bst_float GetWeightOfSortedRecord(const xgboost::MetaInfo& info, - const PredIndPairContainer& rec, - unsigned record_id, unsigned group_id) { + const PredIndPairContainer&, + unsigned, unsigned group_id) { return info.GetWeight(group_id); } }; @@ -651,11 +651,11 @@ XGBOOST_REGISTER_METRIC(AMS, "ams") XGBOOST_REGISTER_METRIC(Auc, "auc") .describe("Area under curve for both classification and rank.") -.set_body([](const char* param) { return new EvalAuc(); }); +.set_body([](const char*) { return new EvalAuc(); }); XGBOOST_REGISTER_METRIC(AucPR, "aucpr") .describe("Area under PR curve for both classification and rank.") -.set_body([](const char* param) { return new EvalAucPR(); }); +.set_body([](const char*) { return new EvalAucPR(); }); XGBOOST_REGISTER_METRIC(Precision, "pre") .describe("precision@k for rank.") @@ -671,6 +671,6 @@ XGBOOST_REGISTER_METRIC(MAP, "map") XGBOOST_REGISTER_METRIC(Cox, "cox-nloglik") .describe("Negative log partial likelihood of Cox proportioanl hazards model.") -.set_body([](const char* param) { return new EvalCox(); }); +.set_body([](const char*) { return new EvalCox(); }); } // namespace metric } // namespace xgboost diff --git a/src/predictor/predictor.cc b/src/predictor/predictor.cc index 2a310ba10..9aa18b19c 100644 --- a/src/predictor/predictor.cc +++ b/src/predictor/predictor.cc @@ -47,7 +47,7 @@ decltype(PredictionContainer::container_) const& PredictionContainer::Container( } void Predictor::Configure( - const std::vector>& cfg) { + const std::vector>&) { } Predictor* Predictor::Create( std::string const& name, GenericParameter const* generic_param) { diff --git a/src/tree/split_evaluator.h b/src/tree/split_evaluator.h index 40550024f..fc7fe65fb 100644 --- a/src/tree/split_evaluator.h +++ b/src/tree/split_evaluator.h @@ -107,7 +107,7 @@ class TreeEvaluator { return w; } } - XGBOOST_DEVICE float CalcGainGivenWeight(bst_node_t nid, ParamT const &p, + XGBOOST_DEVICE float CalcGainGivenWeight(bst_node_t, ParamT const &p, tree::GradStats stats, float w) const { if (stats.GetHess() <= 0) { return .0f; @@ -149,7 +149,7 @@ class TreeEvaluator { return; } common::Transform<>::Init( - [=] XGBOOST_DEVICE(size_t idx, common::Span lower, + [=] XGBOOST_DEVICE(size_t, common::Span lower, common::Span upper, common::Span monotone) { lower[leftid] = lower[nodeid]; diff --git a/src/tree/tree_model.cc b/src/tree/tree_model.cc index e4253dbc4..35c052136 100644 --- a/src/tree/tree_model.cc +++ b/src/tree/tree_model.cc @@ -69,20 +69,24 @@ class TreeGenerator { return result; } - virtual std::string Indicator(RegTree const& tree, int32_t nid, uint32_t depth) const { + virtual std::string Indicator(RegTree const& /*tree*/, + int32_t /*nid*/, uint32_t /*depth*/) const { return ""; } - virtual std::string Integer(RegTree const& tree, int32_t nid, uint32_t depth) const { + virtual std::string Integer(RegTree const& /*tree*/, + int32_t /*nid*/, uint32_t /*depth*/) const { return ""; } - virtual std::string Quantitive(RegTree const& tree, int32_t nid, uint32_t depth) const { + virtual std::string Quantitive(RegTree const& /*tree*/, + int32_t /*nid*/, uint32_t /*depth*/) const { return ""; } - virtual std::string NodeStat(RegTree const& tree, int32_t nid) const { + virtual std::string NodeStat(RegTree const& /*tree*/, int32_t /*nid*/) const { return ""; } - virtual std::string PlainNode(RegTree const& tree, int32_t nid, uint32_t depth) const = 0; + virtual std::string PlainNode(RegTree const& /*tree*/, + int32_t /*nid*/, uint32_t /*depth*/) const = 0; virtual std::string SplitNode(RegTree const& tree, int32_t nid, uint32_t depth) { auto const split_index = tree[nid].SplitIndex(); @@ -179,7 +183,7 @@ class TextGenerator : public TreeGenerator { using SuperT = TreeGenerator; public: - TextGenerator(FeatureMap const& fmap, std::string const& attrs, bool with_stats) : + TextGenerator(FeatureMap const& fmap, bool with_stats) : TreeGenerator(fmap, with_stats) {} std::string LeafNode(RegTree const& tree, int32_t nid, uint32_t depth) const override { @@ -196,7 +200,7 @@ class TextGenerator : public TreeGenerator { return result; } - std::string Indicator(RegTree const& tree, int32_t nid, uint32_t depth) const override { + std::string Indicator(RegTree const& tree, int32_t nid, uint32_t) const override { static std::string const kIndicatorTemplate = "{nid}:[{fname}] yes={yes},no={no}"; int32_t nyes = tree[nid].DefaultLeft() ? tree[nid].RightChild() : tree[nid].LeftChild(); @@ -288,14 +292,14 @@ class TextGenerator : public TreeGenerator { XGBOOST_REGISTER_TREE_IO(TextGenerator, "text") .describe("Dump text representation of tree") .set_body([](FeatureMap const& fmap, std::string const& attrs, bool with_stats) { - return new TextGenerator(fmap, attrs, with_stats); + return new TextGenerator(fmap, with_stats); }); class JsonGenerator : public TreeGenerator { using SuperT = TreeGenerator; public: - JsonGenerator(FeatureMap const& fmap, std::string attrs, bool with_stats) : + JsonGenerator(FeatureMap const& fmap, bool with_stats) : TreeGenerator(fmap, with_stats) {} std::string Indent(uint32_t depth) const { @@ -306,7 +310,7 @@ class JsonGenerator : public TreeGenerator { return result; } - std::string LeafNode(RegTree const& tree, int32_t nid, uint32_t depth) const override { + std::string LeafNode(RegTree const& tree, int32_t nid, uint32_t) const override { static std::string const kLeafTemplate = R"L({ "nodeid": {nid}, "leaf": {leaf} {stat}})L"; static std::string const kStatTemplate = @@ -426,7 +430,7 @@ class JsonGenerator : public TreeGenerator { XGBOOST_REGISTER_TREE_IO(JsonGenerator, "json") .describe("Dump json representation of tree") .set_body([](FeatureMap const& fmap, std::string const& attrs, bool with_stats) { - return new JsonGenerator(fmap, attrs, with_stats); + return new JsonGenerator(fmap, with_stats); }); struct GraphvizParam : public XGBoostParameter { @@ -531,7 +535,7 @@ class GraphvizGenerator : public TreeGenerator { protected: // Only indicator is different, so we combine all different node types into this // function. - std::string PlainNode(RegTree const& tree, int32_t nid, uint32_t depth) const override { + std::string PlainNode(RegTree const& tree, int32_t nid, uint32_t) const override { auto split = tree[nid].SplitIndex(); auto cond = tree[nid].SplitCond(); static std::string const kNodeTemplate = @@ -565,7 +569,7 @@ class GraphvizGenerator : public TreeGenerator { return result; }; - std::string LeafNode(RegTree const& tree, int32_t nid, uint32_t depth) const override { + std::string LeafNode(RegTree const& tree, int32_t nid, uint32_t) const override { static std::string const kLeafTemplate = " {nid} [ label=\"leaf={leaf-value}\" {params}]\n"; auto result = SuperT::Match(kLeafTemplate, { diff --git a/src/tree/updater_colmaker.cc b/src/tree/updater_colmaker.cc index 2cd86a7aa..70a1f4dab 100644 --- a/src/tree/updater_colmaker.cc +++ b/src/tree/updater_colmaker.cc @@ -163,7 +163,7 @@ class ColMaker: public TreeUpdater { DMatrix* p_fmat, RegTree* p_tree) { std::vector newnodes; - this->InitData(gpair, *p_fmat, *p_tree); + this->InitData(gpair, *p_fmat); this->InitNewNode(qexpand_, gpair, *p_fmat, *p_tree); for (int depth = 0; depth < param_.max_depth; ++depth) { this->FindSplit(depth, qexpand_, gpair, p_fmat, p_tree); @@ -200,8 +200,7 @@ class ColMaker: public TreeUpdater { protected: // initialize temp data structure inline void InitData(const std::vector& gpair, - const DMatrix& fmat, - const RegTree& tree) { + const DMatrix& fmat) { { // setup position position_.resize(gpair.size()); @@ -439,7 +438,7 @@ class ColMaker: public TreeUpdater { virtual void UpdateSolution(const SparsePage &batch, const std::vector &feat_set, const std::vector &gpair, - DMatrix*p_fmat) { + DMatrix*) { // start enumeration const auto num_features = static_cast(feat_set.size()); #if defined(_OPENMP) diff --git a/src/tree/updater_histmaker.cc b/src/tree/updater_histmaker.cc index 6deb42113..7edceee72 100644 --- a/src/tree/updater_histmaker.cc +++ b/src/tree/updater_histmaker.cc @@ -56,13 +56,6 @@ class HistMaker: public BaseMaker { HistUnit(const float *cut, GradStats *data, uint32_t size) : cut{cut}, data{data}, size{size} {} /*! \brief add a histogram to data */ - void Add(float fv, const std::vector &gpair, - const MetaInfo &info, const size_t ridx) { - unsigned bin = std::upper_bound(cut, cut + size, fv) - cut; - CHECK_NE(size, 0U) << "try insert into size=0"; - CHECK_LT(bin, size); - data[bin].Add(gpair[ridx]); - } }; /*! \brief a set of histograms from different index */ struct HistSet { @@ -86,7 +79,7 @@ class HistMaker: public BaseMaker { // per thread histset std::vector hset; // initialize the hist set - inline void Configure(const TrainParam ¶m, int nthread) { + inline void Configure(int nthread) { hset.resize(nthread); // cleanup statistics for (int tid = 0; tid < nthread; ++tid) { @@ -127,7 +120,7 @@ class HistMaker: public BaseMaker { // create histogram this->CreateHist(gpair, p_fmat, selected_features_, *p_tree); // find split based on histogram statistics - this->FindSplit(depth, gpair, p_fmat, selected_features_, p_tree); + this->FindSplit(selected_features_, p_tree); // reset position after split this->ResetPositionAfterSplit(p_fmat, *p_tree); this->UpdateQueueExpand(*p_tree); @@ -159,9 +152,9 @@ class HistMaker: public BaseMaker { const RegTree &tree) { } virtual void CreateHist(const std::vector &gpair, - DMatrix *p_fmat, + DMatrix *, const std::vector &fset, - const RegTree &tree) = 0; + const RegTree &) = 0; private: void EnumerateSplit(const HistUnit &hist, @@ -202,10 +195,7 @@ class HistMaker: public BaseMaker { } } - void FindSplit(int depth, - const std::vector &gpair, - DMatrix *p_fmat, - const std::vector &feature_set, + void FindSplit(const std::vector &feature_set, RegTree *p_tree) { const size_t num_feature = feature_set.size(); // get the best split condition for each node @@ -288,7 +278,6 @@ class CQHistMaker: public HistMaker { */ inline void Add(bst_float fv, const std::vector &gpair, - const MetaInfo &info, const bst_uint ridx) { while (istart < hist.size && !(fv < hist.cut[istart])) ++istart; CHECK_NE(istart, hist.size); @@ -342,7 +331,7 @@ class CQHistMaker: public HistMaker { feat2workindex_[fset[i]] = static_cast(i); } // start to work - this->wspace_.Configure(this->param_, 1); + this->wspace_.Configure(1); // if it is C++11, use lazy evaluation for Allreduce, // to gain speedup in recovery auto lazy_get_hist = [&]() { @@ -376,7 +365,7 @@ class CQHistMaker: public HistMaker { this->wspace_.hset[0].data.size(), lazy_get_hist); } - void ResetPositionAfterSplit(DMatrix *p_fmat, + void ResetPositionAfterSplit(DMatrix *, const RegTree &tree) override { this->GetSplitSet(this->qexpand_, tree, &fsplit_set_); } @@ -533,7 +522,7 @@ class CQHistMaker: public HistMaker { const bst_uint ridx = c.index; const int nid = this->position_[ridx]; if (nid >= 0) { - hbuilder[nid].Add(c.fvalue, gpair, info, ridx); + hbuilder[nid].Add(c.fvalue, gpair, ridx); } } } @@ -689,7 +678,7 @@ class GlobalProposalHistMaker: public CQHistMaker { this->feat2workindex_[fset[i]] = static_cast(i); } // start to work - this->wspace_.Configure(this->param_, 1); + this->wspace_.Configure(1); // to gain speedup in recovery { this->thread_hist_.resize(omp_get_max_threads());