Skip to content

Commit

Permalink
fix lint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Nan Zhu committed Feb 5, 2019
1 parent 9ec04cd commit 38c8da2
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 81 deletions.
2 changes: 1 addition & 1 deletion include/xgboost/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
#define XGBOOST_BUILTIN_PREFETCH_PRESENT
#endif

#endif // XGBOOST_BUILD_CONFIG_H_
#endif // XGBOOST_BUILD_CONFIG_H_
160 changes: 80 additions & 80 deletions src/tree/updater_quantile_hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,34 @@ class QuantileHistMaker: public TreeUpdater {
bool UpdatePredictionCache(const DMatrix* data,
HostDeviceVector<bst_float>* p_out_preds);

protected:
// initialize temp data structure
void InitData(const GHistIndexMatrix& gmat,
protected:
// initialize temp data structure
void InitData(const GHistIndexMatrix& gmat,
const std::vector<GradientPair>& gpair,
const DMatrix& fmat,
const RegTree& tree);

void EvaluateSplit(int nid,
void EvaluateSplit(int nid,
const GHistIndexMatrix& gmat,
const HistCollection& hist,
const DMatrix& fmat,
const RegTree& tree);

void ApplySplit(int nid,
const GHistIndexMatrix& gmat,
const ColumnMatrix& column_matrix,
const HistCollection& hist,
const DMatrix& fmat,
RegTree* p_tree);

void ApplySplitDenseData(const RowSetCollection::Elem rowset,
const GHistIndexMatrix& gmat,
std::vector<RowSetCollection::Split>* p_row_split_tloc,
const Column& column,
bst_int split_cond,
bool default_left);

void ApplySplitSparseData(const RowSetCollection::Elem rowset,
void ApplySplit(int nid,
const GHistIndexMatrix& gmat,
const ColumnMatrix& column_matrix,
const HistCollection& hist,
const DMatrix& fmat,
RegTree* p_tree);

void ApplySplitDenseData(const RowSetCollection::Elem rowset,
const GHistIndexMatrix& gmat,
std::vector<RowSetCollection::Split>* p_row_split_tloc,
const Column& column,
bst_int split_cond,
bool default_left);

void ApplySplitSparseData(const RowSetCollection::Elem rowset,
const GHistIndexMatrix& gmat,
std::vector<RowSetCollection::Split>* p_row_split_tloc,
const Column& column,
Expand All @@ -154,14 +154,14 @@ class QuantileHistMaker: public TreeUpdater {
bst_int split_cond,
bool default_left);

void InitNewNode(int nid,
void InitNewNode(int nid,
const GHistIndexMatrix& gmat,
const std::vector<GradientPair>& gpair,
const DMatrix& fmat,
const RegTree& tree);

// enumerate the split values of specific feature
void EnumerateSplit(int d_step,
// enumerate the split values of specific feature
void EnumerateSplit(int d_step,
const GHistIndexMatrix& gmat,
const GHistRow& hist,
const NodeEntry& snode,
Expand All @@ -170,109 +170,109 @@ class QuantileHistMaker: public TreeUpdater {
bst_uint fid,
bst_uint nodeID);

void ExpandWithDepthWidth(const GHistIndexMatrix &gmat,
void ExpandWithDepthWidth(const GHistIndexMatrix &gmat,
const GHistIndexBlockMatrix &gmatb,
const ColumnMatrix &column_matrix,
DMatrix *p_fmat,
RegTree *p_tree,
const std::vector<GradientPair> &gpair_h);

void ExpandWithLossGuide(const GHistIndexMatrix& gmat,
void ExpandWithLossGuide(const GHistIndexMatrix& gmat,
const GHistIndexBlockMatrix& gmatb,
const ColumnMatrix& column_matrix,
DMatrix* p_fmat,
RegTree* p_tree,
const std::vector<GradientPair>& gpair_h);

/* tree growing policies */
struct ExpandEntry {
struct ExpandEntry {
int nid;
int depth;
bst_float loss_chg;
unsigned timestamp;
ExpandEntry(int nid, int depth, bst_float loss_chg, unsigned tstmp)
: nid(nid), depth(depth), loss_chg(loss_chg), timestamp(tstmp) {}
};
inline static bool DepthWise(ExpandEntry lhs, ExpandEntry rhs) {
};
inline static bool DepthWise(ExpandEntry lhs, ExpandEntry rhs) {
if (lhs.depth == rhs.depth) {
return lhs.timestamp > rhs.timestamp; // favor small timestamp
} else {
return lhs.depth > rhs.depth; // favor small depth
}
}
inline static bool LossGuide(ExpandEntry lhs, ExpandEntry rhs) {
}
inline static bool LossGuide(ExpandEntry lhs, ExpandEntry rhs) {
if (lhs.loss_chg == rhs.loss_chg) {
return lhs.timestamp > rhs.timestamp; // favor small timestamp
} else {
return lhs.loss_chg < rhs.loss_chg; // favor large loss_chg
}
}

// --data fields--
const TrainParam& param_;
// number of omp thread used during training
int nthread_;
common::ColumnSampler column_sampler_;
// the internal row sets
RowSetCollection row_set_collection_;
// the temp space for split
std::vector<RowSetCollection::Split> row_split_tloc_;
std::vector<SplitEntry> best_split_tloc_;
/*! \brief TreeNode Data: statistics for each constructed node */
std::vector<NodeEntry> snode_;
/*! \brief culmulative histogram of gradients. */
HistCollection hist_;
/*! \brief feature with least # of bins. to be used for dense specialization
}

// --data fields--
const TrainParam& param_;
// number of omp thread used during training
int nthread_;
common::ColumnSampler column_sampler_;
// the internal row sets
RowSetCollection row_set_collection_;
// the temp space for split
std::vector<RowSetCollection::Split> row_split_tloc_;
std::vector<SplitEntry> best_split_tloc_;
/*! \brief TreeNode Data: statistics for each constructed node */
std::vector<NodeEntry> snode_;
/*! \brief culmulative histogram of gradients. */
HistCollection hist_;
/*! \brief feature with least # of bins. to be used for dense specialization
of InitNewNode() */
uint32_t fid_least_bins_;
/*! \brief local prediction cache; maps node id to leaf value */
std::vector<float> leaf_value_cache_;
uint32_t fid_least_bins_;
/*! \brief local prediction cache; maps node id to leaf value */
std::vector<float> leaf_value_cache_;

GHistBuilder hist_builder_;
std::unique_ptr<TreeUpdater> pruner_;
std::unique_ptr<SplitEvaluator> spliteval_;
GHistBuilder hist_builder_;
std::unique_ptr<TreeUpdater> pruner_;
std::unique_ptr<SplitEvaluator> spliteval_;

// back pointers to tree and data matrix
const RegTree* p_last_tree_;
const DMatrix* p_last_fmat_;
// back pointers to tree and data matrix
const RegTree* p_last_tree_;
const DMatrix* p_last_fmat_;

using ExpandQueue =
using ExpandQueue =
std::priority_queue<ExpandEntry, std::vector<ExpandEntry>,
std::function<bool(ExpandEntry, ExpandEntry)>>;

std::unique_ptr<ExpandQueue> qexpand_loss_guided;
std::vector<ExpandEntry> qexpand_depth_wise;
// key is the node id which should be calculated by SubstractTrick, value is the node is which
// provides the evidence for substracts
std::unordered_map<int, int> nodes_to_derive;
std::unordered_map<int, int> left_to_right_siblings;
std::unordered_map<int, int> right_to_left_siblings;
std::unique_ptr<ExpandQueue> qexpand_loss_guided;
std::vector<ExpandEntry> qexpand_depth_wise;
// key is the node id which should be calculated by SubstractTrick, value is the node is which
// provides the evidence for substracts
std::unordered_map<int, int> nodes_to_derive;
std::unordered_map<int, int> left_to_right_siblings;
std::unordered_map<int, int> right_to_left_siblings;

inline bool IsLeft(int nid) {
inline bool IsLeft(int nid) {
return left_to_right_siblings.find(nid) != left_to_right_siblings.end();
}
}

inline bool IsRight(int nid) {
inline bool IsRight(int nid) {
return right_to_left_siblings.find(nid) != right_to_left_siblings.end();
}
}

inline bool IsRoot(int nid) {
inline bool IsRoot(int nid) {
return (right_to_left_siblings.find(nid) == right_to_left_siblings.end() &&
left_to_right_siblings.find(nid) == left_to_right_siblings.end());
}
left_to_right_siblings.find(nid) == left_to_right_siblings.end());
}

enum DataLayout { kDenseDataZeroBased, kDenseDataOneBased, kSparseData };
DataLayout data_layout_;
enum DataLayout { kDenseDataZeroBased, kDenseDataOneBased, kSparseData };
DataLayout data_layout_;

// performance counters
double tstart;
double time_init_data = 0;
double time_init_new_node = 0;
double time_build_hist = 0;
double time_evaluate_split = 0;
double time_apply_split = 0;
// performance counters
double tstart;
double time_init_data = 0;
double time_init_new_node = 0;
double time_build_hist = 0;
double time_evaluate_split = 0;
double time_apply_split = 0;

rabit::Reducer<GHistEntry, GHistEntry::Reduce> histred_;
rabit::Reducer<GHistEntry, GHistEntry::Reduce> histred_;
};

std::unique_ptr<Builder> builder_;
Expand Down

0 comments on commit 38c8da2

Please sign in to comment.