Upgrade clang-tidy on CI. (#5469)
* Correct all clang-tidy errors. * Upgrade clang-tidy to 10 on CI. Co-authored-by: Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
@@ -41,7 +41,7 @@ struct ArrayInterfaceErrors {
|
||||
static char const* Version() {
|
||||
return "Only version 1 of `__cuda_array_interface__' is supported.";
|
||||
}
|
||||
static char const* ofType(std::string const& type) {
|
||||
static char const* OfType(std::string const& type) {
|
||||
static std::string str;
|
||||
str.clear();
|
||||
str += " should be of ";
|
||||
@@ -229,9 +229,6 @@ class ArrayInterfaceHandler {
|
||||
|
||||
// A view over __array_interface__
|
||||
class ArrayInterface {
|
||||
using mask_type = unsigned char;
|
||||
using index_type = int32_t;
|
||||
|
||||
public:
|
||||
ArrayInterface() = default;
|
||||
explicit ArrayInterface(std::map<std::string, Json> const& column) {
|
||||
|
||||
@@ -40,8 +40,8 @@ class CudfAdapterBatch : public detail::NoMetaInfo {
|
||||
common::Span<size_t> column_ptr, size_t num_elements)
|
||||
: columns_(columns),
|
||||
column_ptr_(column_ptr),
|
||||
num_elements(num_elements) {}
|
||||
size_t Size() const { return num_elements; }
|
||||
num_elements_(num_elements) {}
|
||||
size_t Size() const { return num_elements_; }
|
||||
__device__ COOTuple GetElement(size_t idx) const {
|
||||
size_t column_idx =
|
||||
dh::UpperBound(column_ptr_.data(), column_ptr_.size(), idx) - 1;
|
||||
@@ -50,7 +50,7 @@ class CudfAdapterBatch : public detail::NoMetaInfo {
|
||||
float value = column.valid.Data() == nullptr || column.valid.Check(row_idx)
|
||||
? column.GetElement(row_idx)
|
||||
: std::numeric_limits<float>::quiet_NaN();
|
||||
return COOTuple(row_idx, column_idx, value);
|
||||
return {row_idx, column_idx, value};
|
||||
}
|
||||
__device__ float GetValue(size_t ridx, bst_feature_t fidx) const {
|
||||
auto const& column = columns_[fidx];
|
||||
@@ -63,7 +63,7 @@ class CudfAdapterBatch : public detail::NoMetaInfo {
|
||||
private:
|
||||
common::Span<ArrayInterface> columns_;
|
||||
common::Span<size_t> column_ptr_;
|
||||
size_t num_elements;
|
||||
size_t num_elements_;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -146,10 +146,10 @@ class CudfAdapter : public detail::SingleBatchDataIter<CudfAdapterBatch> {
|
||||
}
|
||||
columns_ = columns;
|
||||
column_ptr_ = column_ptr;
|
||||
batch = CudfAdapterBatch(dh::ToSpan(columns_), dh::ToSpan(column_ptr_),
|
||||
batch_ = CudfAdapterBatch(dh::ToSpan(columns_), dh::ToSpan(column_ptr_),
|
||||
column_ptr.back());
|
||||
}
|
||||
const CudfAdapterBatch& Value() const override { return batch; }
|
||||
const CudfAdapterBatch& Value() const override { return batch_; }
|
||||
|
||||
size_t NumRows() const { return num_rows_; }
|
||||
size_t NumColumns() const { return columns_.size(); }
|
||||
@@ -159,7 +159,7 @@ class CudfAdapter : public detail::SingleBatchDataIter<CudfAdapterBatch> {
|
||||
bool IsRowMajor() { return false; }
|
||||
|
||||
private:
|
||||
CudfAdapterBatch batch;
|
||||
CudfAdapterBatch batch_;
|
||||
dh::device_vector<ArrayInterface> columns_;
|
||||
dh::device_vector<size_t> column_ptr_; // Exclusive scan of column sizes
|
||||
size_t num_rows_{0};
|
||||
@@ -169,8 +169,8 @@ class CudfAdapter : public detail::SingleBatchDataIter<CudfAdapterBatch> {
|
||||
class CupyAdapterBatch : public detail::NoMetaInfo {
|
||||
public:
|
||||
CupyAdapterBatch() = default;
|
||||
CupyAdapterBatch(ArrayInterface array_interface)
|
||||
: array_interface_(array_interface) {}
|
||||
explicit CupyAdapterBatch(ArrayInterface array_interface)
|
||||
: array_interface_(std::move(array_interface)) {}
|
||||
size_t Size() const {
|
||||
return array_interface_.num_rows * array_interface_.num_cols;
|
||||
}
|
||||
@@ -181,7 +181,7 @@ class CupyAdapterBatch : public detail::NoMetaInfo {
|
||||
array_interface_.valid.Check(row_idx)
|
||||
? array_interface_.GetElement(idx)
|
||||
: std::numeric_limits<float>::quiet_NaN();
|
||||
return COOTuple(row_idx, column_idx, value);
|
||||
return {row_idx, column_idx, value};
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -193,22 +193,22 @@ class CupyAdapter : public detail::SingleBatchDataIter<CupyAdapterBatch> {
|
||||
explicit CupyAdapter(std::string cuda_interface_str) {
|
||||
Json json_array_interface =
|
||||
Json::Load({cuda_interface_str.c_str(), cuda_interface_str.size()});
|
||||
array_interface = ArrayInterface(get<Object const>(json_array_interface));
|
||||
device_idx_ = dh::CudaGetPointerDevice(array_interface.data);
|
||||
array_interface_ = ArrayInterface(get<Object const>(json_array_interface));
|
||||
device_idx_ = dh::CudaGetPointerDevice(array_interface_.data);
|
||||
CHECK_NE(device_idx_, -1);
|
||||
batch = CupyAdapterBatch(array_interface);
|
||||
batch_ = CupyAdapterBatch(array_interface_);
|
||||
}
|
||||
const CupyAdapterBatch& Value() const override { return batch; }
|
||||
const CupyAdapterBatch& Value() const override { return batch_; }
|
||||
|
||||
size_t NumRows() const { return array_interface.num_rows; }
|
||||
size_t NumColumns() const { return array_interface.num_cols; }
|
||||
size_t NumRows() const { return array_interface_.num_rows; }
|
||||
size_t NumColumns() const { return array_interface_.num_cols; }
|
||||
size_t DeviceIdx() const { return device_idx_; }
|
||||
|
||||
bool IsRowMajor() { return true; }
|
||||
|
||||
private:
|
||||
ArrayInterface array_interface;
|
||||
CupyAdapterBatch batch;
|
||||
ArrayInterface array_interface_;
|
||||
CupyAdapterBatch batch_;
|
||||
int device_idx_;
|
||||
};
|
||||
|
||||
|
||||
@@ -46,12 +46,12 @@ template <typename AdapterBatchT>
|
||||
struct WriteCompressedEllpackFunctor {
|
||||
WriteCompressedEllpackFunctor(common::CompressedByteT* buffer,
|
||||
const common::CompressedBufferWriter& writer,
|
||||
const AdapterBatchT& batch,
|
||||
AdapterBatchT batch,
|
||||
EllpackDeviceAccessor accessor,
|
||||
const IsValidFunctor& is_valid)
|
||||
: d_buffer(buffer),
|
||||
writer(writer),
|
||||
batch(batch),
|
||||
batch(std::move(batch)),
|
||||
accessor(std::move(accessor)),
|
||||
is_valid(is_valid) {}
|
||||
|
||||
@@ -210,10 +210,10 @@ DeviceDMatrix::DeviceDMatrix(AdapterT* adapter, float missing, int nthread, int
|
||||
GetRowCounts(batch, row_counts_span, adapter->DeviceIdx(), missing);
|
||||
|
||||
dh::XGBCachingDeviceAllocator<char> alloc;
|
||||
info.num_nonzero_ = thrust::reduce(thrust::cuda::par(alloc),
|
||||
info_.num_nonzero_ = thrust::reduce(thrust::cuda::par(alloc),
|
||||
row_counts.begin(), row_counts.end());
|
||||
info.num_col_ = adapter->NumColumns();
|
||||
info.num_row_ = adapter->NumRows();
|
||||
info_.num_col_ = adapter->NumColumns();
|
||||
info_.num_row_ = adapter->NumRows();
|
||||
ellpack_page_.reset(new EllpackPage());
|
||||
*ellpack_page_->Impl() =
|
||||
EllpackPageImpl(adapter->DeviceIdx(), cuts, this->IsDense(), row_stride,
|
||||
@@ -228,7 +228,7 @@ DeviceDMatrix::DeviceDMatrix(AdapterT* adapter, float missing, int nthread, int
|
||||
WriteNullValues(ellpack_page_->Impl(), adapter->DeviceIdx(), row_counts_span);
|
||||
|
||||
// Synchronise worker columns
|
||||
rabit::Allreduce<rabit::op::Max>(&info.num_col_, 1);
|
||||
rabit::Allreduce<rabit::op::Max>(&info_.num_col_, 1);
|
||||
}
|
||||
template DeviceDMatrix::DeviceDMatrix(CudfAdapter* adapter, float missing,
|
||||
int nthread, int max_bin);
|
||||
|
||||
@@ -23,9 +23,9 @@ class DeviceDMatrix : public DMatrix {
|
||||
template <typename AdapterT>
|
||||
explicit DeviceDMatrix(AdapterT* adapter, float missing, int nthread, int max_bin);
|
||||
|
||||
MetaInfo& Info() override { return info; }
|
||||
MetaInfo& Info() override { return info_; }
|
||||
|
||||
const MetaInfo& Info() const override { return info; }
|
||||
const MetaInfo& Info() const override { return info_; }
|
||||
|
||||
bool SingleColBlock() const override { return true; }
|
||||
|
||||
@@ -51,7 +51,7 @@ class DeviceDMatrix : public DMatrix {
|
||||
return BatchSet<EllpackPage>(begin_iter);
|
||||
}
|
||||
|
||||
MetaInfo info;
|
||||
MetaInfo info_;
|
||||
// source data pointer.
|
||||
std::unique_ptr<EllpackPage> ellpack_page_;
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@ struct EllpackDeviceAccessor {
|
||||
* not found). */
|
||||
XGBOOST_DEVICE size_t NumSymbols() const { return gidx_fvalue_map.size() + 1; }
|
||||
|
||||
size_t NullValue() const { return gidx_fvalue_map.size(); }
|
||||
XGBOOST_DEVICE size_t NullValue() const { return gidx_fvalue_map.size(); }
|
||||
|
||||
XGBOOST_DEVICE size_t NumBins() const { return gidx_fvalue_map.size(); }
|
||||
|
||||
@@ -185,6 +185,9 @@ class EllpackPageImpl {
|
||||
base_rowid = row_id;
|
||||
}
|
||||
|
||||
common::HistogramCuts& Cuts() { return cuts_; }
|
||||
common::HistogramCuts const& Cuts() const { return cuts_; }
|
||||
|
||||
/*! \return Estimation of memory cost of this page. */
|
||||
static size_t MemCostBytes(size_t num_rows, size_t row_stride, const common::HistogramCuts&cuts) ;
|
||||
|
||||
@@ -220,8 +223,9 @@ public:
|
||||
size_t n_rows{};
|
||||
/*! \brief global index of histogram, which is stored in ELLPack format. */
|
||||
HostDeviceVector<common::CompressedByteT> gidx_buffer;
|
||||
|
||||
private:
|
||||
common::HistogramCuts cuts_;
|
||||
private:
|
||||
common::Monitor monitor_;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ class EllpackPageRawFormat : public SparsePageFormat<EllpackPage> {
|
||||
public:
|
||||
bool Read(EllpackPage* page, dmlc::SeekStream* fi) override {
|
||||
auto* impl = page->Impl();
|
||||
fi->Read(&impl->cuts_.cut_values_.HostVector());
|
||||
fi->Read(&impl->cuts_.cut_ptrs_.HostVector());
|
||||
fi->Read(&impl->cuts_.min_vals_.HostVector());
|
||||
fi->Read(&impl->Cuts().cut_values_.HostVector());
|
||||
fi->Read(&impl->Cuts().cut_ptrs_.HostVector());
|
||||
fi->Read(&impl->Cuts().min_vals_.HostVector());
|
||||
fi->Read(&impl->n_rows);
|
||||
fi->Read(&impl->is_dense);
|
||||
fi->Read(&impl->row_stride);
|
||||
@@ -38,9 +38,9 @@ class EllpackPageRawFormat : public SparsePageFormat<EllpackPage> {
|
||||
|
||||
void Write(const EllpackPage& page, dmlc::Stream* fo) override {
|
||||
auto* impl = page.Impl();
|
||||
fo->Write(impl->cuts_.cut_values_.ConstHostVector());
|
||||
fo->Write(impl->cuts_.cut_ptrs_.ConstHostVector());
|
||||
fo->Write(impl->cuts_.min_vals_.ConstHostVector());
|
||||
fo->Write(impl->Cuts().cut_values_.ConstHostVector());
|
||||
fo->Write(impl->Cuts().cut_ptrs_.ConstHostVector());
|
||||
fo->Write(impl->Cuts().min_vals_.ConstHostVector());
|
||||
fo->Write(impl->n_rows);
|
||||
fo->Write(impl->is_dense);
|
||||
fo->Write(impl->row_stride);
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
namespace xgboost {
|
||||
namespace data {
|
||||
MetaInfo& SimpleDMatrix::Info() { return info; }
|
||||
MetaInfo& SimpleDMatrix::Info() { return info_; }
|
||||
|
||||
const MetaInfo& SimpleDMatrix::Info() const { return info; }
|
||||
const MetaInfo& SimpleDMatrix::Info() const { return info_; }
|
||||
|
||||
BatchSet<SparsePage> SimpleDMatrix::GetRowBatches() {
|
||||
// since csr is the default data structure so `source_` is always available.
|
||||
@@ -26,7 +26,7 @@ BatchSet<SparsePage> SimpleDMatrix::GetRowBatches() {
|
||||
BatchSet<CSCPage> SimpleDMatrix::GetColumnBatches() {
|
||||
// column page doesn't exist, generate it
|
||||
if (!column_page_) {
|
||||
column_page_.reset(new CSCPage(sparse_page_.GetTranspose(info.num_col_)));
|
||||
column_page_.reset(new CSCPage(sparse_page_.GetTranspose(info_.num_col_)));
|
||||
}
|
||||
auto begin_iter =
|
||||
BatchIterator<CSCPage>(new SimpleBatchIteratorImpl<CSCPage>(column_page_.get()));
|
||||
@@ -37,7 +37,7 @@ BatchSet<SortedCSCPage> SimpleDMatrix::GetSortedColumnBatches() {
|
||||
// Sorted column page doesn't exist, generate it
|
||||
if (!sorted_column_page_) {
|
||||
sorted_column_page_.reset(
|
||||
new SortedCSCPage(sparse_page_.GetTranspose(info.num_col_)));
|
||||
new SortedCSCPage(sparse_page_.GetTranspose(info_.num_col_)));
|
||||
sorted_column_page_->SortRows();
|
||||
}
|
||||
auto begin_iter = BatchIterator<SortedCSCPage>(
|
||||
@@ -85,17 +85,17 @@ SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
|
||||
inferred_num_columns = std::max(batch_max_columns, inferred_num_columns);
|
||||
// Append meta information if available
|
||||
if (batch.Labels() != nullptr) {
|
||||
auto& labels = info.labels_.HostVector();
|
||||
auto& labels = info_.labels_.HostVector();
|
||||
labels.insert(labels.end(), batch.Labels(),
|
||||
batch.Labels() + batch.Size());
|
||||
}
|
||||
if (batch.Weights() != nullptr) {
|
||||
auto& weights = info.weights_.HostVector();
|
||||
auto& weights = info_.weights_.HostVector();
|
||||
weights.insert(weights.end(), batch.Weights(),
|
||||
batch.Weights() + batch.Size());
|
||||
}
|
||||
if (batch.BaseMargin() != nullptr) {
|
||||
auto& base_margin = info.base_margin_.HostVector();
|
||||
auto& base_margin = info_.base_margin_.HostVector();
|
||||
base_margin.insert(base_margin.end(), batch.BaseMargin(),
|
||||
batch.BaseMargin() + batch.Size());
|
||||
}
|
||||
@@ -105,7 +105,7 @@ SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
|
||||
for (size_t i = 0; i < batch.Size(); ++i) {
|
||||
const uint64_t cur_group_id = batch.Qid()[i];
|
||||
if (last_group_id == default_max || last_group_id != cur_group_id) {
|
||||
info.group_ptr_.push_back(group_size);
|
||||
info_.group_ptr_.push_back(group_size);
|
||||
}
|
||||
last_group_id = cur_group_id;
|
||||
++group_size;
|
||||
@@ -114,22 +114,22 @@ SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
|
||||
}
|
||||
|
||||
if (last_group_id != default_max) {
|
||||
if (group_size > info.group_ptr_.back()) {
|
||||
info.group_ptr_.push_back(group_size);
|
||||
if (group_size > info_.group_ptr_.back()) {
|
||||
info_.group_ptr_.push_back(group_size);
|
||||
}
|
||||
}
|
||||
|
||||
// Deal with empty rows/columns if necessary
|
||||
if (adapter->NumColumns() == kAdapterUnknownSize) {
|
||||
info.num_col_ = inferred_num_columns;
|
||||
info_.num_col_ = inferred_num_columns;
|
||||
} else {
|
||||
info.num_col_ = adapter->NumColumns();
|
||||
info_.num_col_ = adapter->NumColumns();
|
||||
}
|
||||
// Synchronise worker columns
|
||||
rabit::Allreduce<rabit::op::Max>(&info.num_col_, 1);
|
||||
rabit::Allreduce<rabit::op::Max>(&info_.num_col_, 1);
|
||||
|
||||
if (adapter->NumRows() == kAdapterUnknownSize) {
|
||||
info.num_row_ = offset_vec.size() - 1;
|
||||
info_.num_row_ = offset_vec.size() - 1;
|
||||
} else {
|
||||
if (offset_vec.empty()) {
|
||||
offset_vec.emplace_back(0);
|
||||
@@ -138,9 +138,9 @@ SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
|
||||
while (offset_vec.size() - 1 < adapter->NumRows()) {
|
||||
offset_vec.emplace_back(offset_vec.back());
|
||||
}
|
||||
info.num_row_ = adapter->NumRows();
|
||||
info_.num_row_ = adapter->NumRows();
|
||||
}
|
||||
info.num_nonzero_ = data_vec.size();
|
||||
info_.num_nonzero_ = data_vec.size();
|
||||
omp_set_num_threads(nthread_original);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ SimpleDMatrix::SimpleDMatrix(dmlc::Stream* in_stream) {
|
||||
CHECK(in_stream->Read(&tmagic, sizeof(tmagic)) == sizeof(tmagic))
|
||||
<< "invalid input file format";
|
||||
CHECK_EQ(tmagic, kMagic) << "invalid format, magic number mismatch";
|
||||
info.LoadBinary(in_stream);
|
||||
info_.LoadBinary(in_stream);
|
||||
in_stream->Read(&sparse_page_.offset.HostVector());
|
||||
in_stream->Read(&sparse_page_.data.HostVector());
|
||||
}
|
||||
@@ -158,7 +158,7 @@ void SimpleDMatrix::SaveToLocalFile(const std::string& fname) {
|
||||
std::unique_ptr<dmlc::Stream> fo(dmlc::Stream::Create(fname.c_str(), "w"));
|
||||
int tmagic = kMagic;
|
||||
fo->Write(&tmagic, sizeof(tmagic));
|
||||
info.SaveBinary(fo.get());
|
||||
info_.SaveBinary(fo.get());
|
||||
fo->Write(sparse_page_.offset.HostVector());
|
||||
fo->Write(sparse_page_.data.HostVector());
|
||||
}
|
||||
|
||||
@@ -113,8 +113,8 @@ SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
|
||||
sparse_page_.offset.Resize(adapter->NumRows() + 1);
|
||||
auto s_offset = sparse_page_.offset.DeviceSpan();
|
||||
CountRowOffsets(batch, s_offset, adapter->DeviceIdx(), missing);
|
||||
info.num_nonzero_ = sparse_page_.offset.HostVector().back();
|
||||
sparse_page_.data.Resize(info.num_nonzero_);
|
||||
info_.num_nonzero_ = sparse_page_.offset.HostVector().back();
|
||||
sparse_page_.data.Resize(info_.num_nonzero_);
|
||||
if (adapter->IsRowMajor()) {
|
||||
CopyDataRowMajor(adapter, sparse_page_.data.DeviceSpan(),
|
||||
adapter->DeviceIdx(), missing, s_offset);
|
||||
@@ -123,10 +123,10 @@ SimpleDMatrix::SimpleDMatrix(AdapterT* adapter, float missing, int nthread) {
|
||||
adapter->DeviceIdx(), missing, s_offset);
|
||||
}
|
||||
|
||||
info.num_col_ = adapter->NumColumns();
|
||||
info.num_row_ = adapter->NumRows();
|
||||
info_.num_col_ = adapter->NumColumns();
|
||||
info_.num_row_ = adapter->NumRows();
|
||||
// Synchronise worker columns
|
||||
rabit::Allreduce<rabit::op::Max>(&info.num_col_, 1);
|
||||
rabit::Allreduce<rabit::op::Max>(&info_.num_col_, 1);
|
||||
}
|
||||
|
||||
template SimpleDMatrix::SimpleDMatrix(CudfAdapter* adapter, float missing,
|
||||
|
||||
@@ -42,7 +42,7 @@ class SimpleDMatrix : public DMatrix {
|
||||
BatchSet<SortedCSCPage> GetSortedColumnBatches() override;
|
||||
BatchSet<EllpackPage> GetEllpackBatches(const BatchParam& param) override;
|
||||
|
||||
MetaInfo info;
|
||||
MetaInfo info_;
|
||||
SparsePage sparse_page_; // Primary storage type
|
||||
std::unique_ptr<CSCPage> column_page_;
|
||||
std::unique_ptr<SortedCSCPage> sorted_column_page_;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "../common/common.h"
|
||||
#include <xgboost/data.h>
|
||||
|
||||
namespace {
|
||||
namespace detail {
|
||||
|
||||
// Split a cache info string with delimiter ':'
|
||||
// If cache info string contains drive letter (e.g. C:), exclude it before splitting
|
||||
@@ -46,7 +46,7 @@ GetCacheShards(const std::string& cache_info) {
|
||||
return xgboost::common::Split(cache_info, ':');
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
} // namespace detail
|
||||
|
||||
namespace xgboost {
|
||||
namespace data {
|
||||
@@ -100,7 +100,7 @@ struct CacheInfo {
|
||||
|
||||
inline CacheInfo ParseCacheInfo(const std::string& cache_info, const std::string& page_type) {
|
||||
CacheInfo info;
|
||||
std::vector<std::string> cache_shards = GetCacheShards(cache_info);
|
||||
std::vector<std::string> cache_shards = ::detail::GetCacheShards(cache_info);
|
||||
CHECK_NE(cache_shards.size(), 0U);
|
||||
// read in the info files.
|
||||
info.name_info = cache_shards[0];
|
||||
|
||||
Reference in New Issue
Block a user