* Add hessian to batch param in preparation of new approx impl. * Extract a push method for gradient index matrix. * Use span instead of vector ref for hessian in sketching. * Create a binary format for gradient index.
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
/*!
|
|
* Copyright 2021 XGBoost contributors
|
|
*/
|
|
#ifndef XGBOOST_DATA_HISTOGRAM_CUT_FORMAT_H_
|
|
#define XGBOOST_DATA_HISTOGRAM_CUT_FORMAT_H_
|
|
|
|
#include "../common/hist_util.h"
|
|
|
|
namespace xgboost {
|
|
namespace data {
|
|
inline bool ReadHistogramCuts(common::HistogramCuts *cuts, dmlc::SeekStream *fi) {
|
|
if (!fi->Read(&cuts->cut_values_.HostVector())) {
|
|
return false;
|
|
}
|
|
if (!fi->Read(&cuts->cut_ptrs_.HostVector())) {
|
|
return false;
|
|
}
|
|
if (!fi->Read(&cuts->min_vals_.HostVector())) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
inline size_t WriteHistogramCuts(common::HistogramCuts const &cuts, dmlc::Stream *fo) {
|
|
size_t bytes = 0;
|
|
fo->Write(cuts.cut_values_.ConstHostVector());
|
|
bytes += cuts.cut_values_.ConstHostSpan().size_bytes() + sizeof(uint64_t);
|
|
fo->Write(cuts.cut_ptrs_.ConstHostVector());
|
|
bytes += cuts.cut_ptrs_.ConstHostSpan().size_bytes() + sizeof(uint64_t);
|
|
fo->Write(cuts.min_vals_.ConstHostVector());
|
|
bytes += cuts.min_vals_.ConstHostSpan().size_bytes() + sizeof(uint64_t);
|
|
return bytes;
|
|
}
|
|
} // namespace data
|
|
} // namespace xgboost
|
|
#endif // XGBOOST_DATA_HISTOGRAM_CUT_FORMAT_H_
|