Clean up warnings (#6325)

This commit is contained in:
Igor Moura
2020-10-30 12:50:29 -03:00
committed by GitHub
parent f0fe18fc28
commit 5e1e972aea
16 changed files with 53 additions and 61 deletions

View File

@@ -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<float> lower,
[=] XGBOOST_DEVICE(size_t, common::Span<float> lower,
common::Span<float> upper,
common::Span<int> monotone) {
lower[leftid] = lower[nodeid];

View File

@@ -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<GraphvizParam> {
@@ -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, {

View File

@@ -163,7 +163,7 @@ class ColMaker: public TreeUpdater {
DMatrix* p_fmat,
RegTree* p_tree) {
std::vector<int> 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<GradientPair>& 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<bst_feature_t> &feat_set,
const std::vector<GradientPair> &gpair,
DMatrix*p_fmat) {
DMatrix*) {
// start enumeration
const auto num_features = static_cast<bst_omp_uint>(feat_set.size());
#if defined(_OPENMP)

View File

@@ -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<GradientPair> &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<HistSet> hset;
// initialize the hist set
inline void Configure(const TrainParam &param, 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<GradientPair> &gpair,
DMatrix *p_fmat,
DMatrix *,
const std::vector <bst_feature_t> &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<GradientPair> &gpair,
DMatrix *p_fmat,
const std::vector <bst_feature_t> &feature_set,
void FindSplit(const std::vector <bst_feature_t> &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<GradientPair> &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<int>(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<int>(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());