src/tree/updater_quantile_hist.cc
// merge some block of partial histograms
merge some block of partial histograms
merge some block of partial histograms
void QuantileHistMaker::Builder::ReduceHistograms(
    common::GradStatHist::GradType* hist_data,
    common::GradStatHist::GradType* sibling_hist_data,
    common::GradStatHist::GradType* parent_hist_data,
    const size_t ibegin,
    const size_t iend,
    const size_t inode,
    const std::vector<std::vector<uint8_t>>& hist_is_init,
    const std::vector<std::vector<common::GradStatHist::GradType*>>& hist_buffers) {
  bool is_init = false;
  for (size_t ihist = 0; ihist < hist_is_init[inode].size(); ++ihist) {
    common::GradStatHist::GradType* partial_data = hist_buffers[inode][ihist];
    if (hist_is_init[inode][ihist] && is_init) {
      for (size_t i = ibegin; i < iend; ++i) {
        hist_data[i] += partial_data[i];
      }
    } else if (hist_is_init[inode][ihist]) {
      for (size_t i = ibegin; i < iend; ++i) {
        hist_data[i] = partial_data[i];
      }
      is_init = true;
    }
  }
  if (sibling_hist_data) {
    for (size_t i = ibegin; i < iend; ++i) {
      sibling_hist_data[i] = parent_hist_data[i] - hist_data[i];
    }
  }
}
void QuantileHistMaker :: Builder :: ReduceHistograms ( common :: GradStatHist :: GradType * hist_data , common :: GradStatHist :: GradType * sibling_hist_data , common :: GradStatHist :: GradType * parent_hist_data , const size_t ibegin , const size_t iend , const size_t inode , const std :: vector < std :: vector < uint8_t > > & hist_is_init , const std :: vector < std :: vector < common :: GradStatHist :: GradType * > > & hist_buffers ) { bool is_init = false ; for ( size_t ihist = 0 ; ihist < hist_is_init [ inode ] . size ( ) ; ++ ihist ) { common :: GradStatHist :: GradType * partial_data = hist_buffers [ inode ] [ ihist ] ; if ( hist_is_init [ inode ] [ ihist ] && is_init ) { for ( size_t i = ibegin ; i < iend ; ++ i ) { hist_data [ i ] += partial_data [ i ] ; } } else if ( hist_is_init [ inode ] [ ihist ] ) { for ( size_t i = ibegin ; i < iend ; ++ i ) { hist_data [ i ] = partial_data [ i ] ; } is_init = true ; } } if ( sibling_hist_data ) { for ( size_t i = ibegin ; i < iend ; ++ i ) { sibling_hist_data [ i ] = parent_hist_data [ i ] - hist_data [ i ] ; } } }
merge some block of partial histograms
merge some block of partial histograms