Refactor parts of fast histogram utilities (#3564)

* Refactor parts of fast histogram utilities

* Removed byte packing from column matrix
This commit is contained in:
Rory Mitchell
2018-08-09 17:59:57 +12:00
committed by GitHub
parent 3c72654e3b
commit bbb771f32e
8 changed files with 184 additions and 288 deletions

View File

@@ -75,6 +75,7 @@ struct HistCutMatrix {
std::vector<bst_float> min_val;
/*! \brief the cut field */
std::vector<bst_float> cut;
uint32_t GetBinIdx(const Entry &e);
/*! \brief Get histogram bound for fid */
inline HistCutUnit operator[](bst_uint fid) const {
return {dmlc::BeginPtr(cut) + row_ptr[fid],
@@ -122,18 +123,18 @@ struct GHistIndexMatrix {
/*! \brief hit count of each index */
std::vector<size_t> hit_count;
/*! \brief The corresponding cuts */
const HistCutMatrix* cut;
HistCutMatrix cut;
// Create a global histogram matrix, given cut
void Init(DMatrix* p_fmat);
void Init(DMatrix* p_fmat, int max_num_bins);
// get i-th row
inline GHistIndexRow operator[](size_t i) const {
return {&index[0] + row_ptr[i], row_ptr[i + 1] - row_ptr[i]};
}
inline void GetFeatureCounts(size_t* counts) const {
auto nfeature = cut->row_ptr.size() - 1;
auto nfeature = cut.row_ptr.size() - 1;
for (unsigned fid = 0; fid < nfeature; ++fid) {
auto ibegin = cut->row_ptr[fid];
auto iend = cut->row_ptr[fid + 1];
auto ibegin = cut.row_ptr[fid];
auto iend = cut.row_ptr[fid + 1];
for (auto i = ibegin; i < iend; ++i) {
counts[fid] += hit_count[i];
}