From 594371e35ba14cad5592a5c75c655219f5825c9b Mon Sep 17 00:00:00 2001 From: Jiaming Yuan Date: Wed, 15 Feb 2023 20:16:35 +0800 Subject: [PATCH] Fix CPP lint. (#8807) --- .github/workflows/main.yml | 13 ++++++++++++- include/xgboost/metric.h | 9 +++++---- src/data/sparse_page_dmatrix.cc | 4 ++-- src/metric/auc.cu | 2 +- src/metric/metric_common.h | 1 + src/objective/adaptive.cu | 4 ++-- src/predictor/cpu_treeshap.cc | 7 ++++--- src/predictor/cpu_treeshap.h | 5 +++++ src/tree/gpu_hist/evaluate_splits.cu | 4 ++-- src/tree/gpu_hist/histogram.cu | 2 +- 10 files changed, 35 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 822ae14d8..ac50b744b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -144,7 +144,18 @@ jobs: python -m pip install wheel setuptools cpplint pylint - name: Run lint run: | - python dmlc-core/scripts/lint.py xgboost cpp R-package/src + python3 dmlc-core/scripts/lint.py xgboost cpp R-package/src + + python3 dmlc-core/scripts/lint.py --exclude_path \ + python-package/xgboost/dmlc-core \ + python-package/xgboost/include \ + python-package/xgboost/lib \ + python-package/xgboost/rabit \ + python-package/xgboost/src \ + --pylint-rc python-package/.pylintrc \ + xgboost \ + cpp \ + include src python-package sphinx: runs-on: ubuntu-latest diff --git a/include/xgboost/metric.h b/include/xgboost/metric.h index 2be6d5591..2f67e47dd 100644 --- a/include/xgboost/metric.h +++ b/include/xgboost/metric.h @@ -8,15 +8,16 @@ #define XGBOOST_METRIC_H_ #include -#include -#include #include +#include #include +#include -#include -#include #include +#include // shared_ptr +#include #include +#include namespace xgboost { struct Context; diff --git a/src/data/sparse_page_dmatrix.cc b/src/data/sparse_page_dmatrix.cc index 7881c62d2..698e1e5b2 100644 --- a/src/data/sparse_page_dmatrix.cc +++ b/src/data/sparse_page_dmatrix.cc @@ -19,7 +19,7 @@ const MetaInfo &SparsePageDMatrix::Info() const { return info_; } namespace detail { // Use device dispatch -std::size_t NSamplesDevice(DMatrixProxy *) +std::size_t NSamplesDevice(DMatrixProxy *) // NOLINT #if defined(XGBOOST_USE_CUDA) ; // NOLINT #else @@ -28,7 +28,7 @@ std::size_t NSamplesDevice(DMatrixProxy *) return 0; } #endif -std::size_t NFeaturesDevice(DMatrixProxy *) +std::size_t NFeaturesDevice(DMatrixProxy *) // NOLINT #if defined(XGBOOST_USE_CUDA) ; // NOLINT #else diff --git a/src/metric/auc.cu b/src/metric/auc.cu index ae5ba676e..fdbf0501a 100644 --- a/src/metric/auc.cu +++ b/src/metric/auc.cu @@ -5,7 +5,7 @@ #include #include -#include +#include // NOLINT #include #include #include diff --git a/src/metric/metric_common.h b/src/metric/metric_common.h index 064608ebf..5fbd6f256 100644 --- a/src/metric/metric_common.h +++ b/src/metric/metric_common.h @@ -6,6 +6,7 @@ #define XGBOOST_METRIC_METRIC_COMMON_H_ #include +#include // shared_ptr #include #include "../common/common.h" diff --git a/src/objective/adaptive.cu b/src/objective/adaptive.cu index 774149960..5e2f490b7 100644 --- a/src/objective/adaptive.cu +++ b/src/objective/adaptive.cu @@ -3,8 +3,8 @@ */ #include -#include // std::int32_t -#include +#include // std::int32_t +#include // NOLINT #include "../common/cuda_context.cuh" // CUDAContext #include "../common/device_helpers.cuh" diff --git a/src/predictor/cpu_treeshap.cc b/src/predictor/cpu_treeshap.cc index 87da2612c..64b195d78 100644 --- a/src/predictor/cpu_treeshap.cc +++ b/src/predictor/cpu_treeshap.cc @@ -3,10 +3,11 @@ */ #include "cpu_treeshap.h" -#include // std::uint32_t +#include // copy +#include // std::uint32_t -#include "predict_fn.h" // GetNextNode -#include "xgboost/base.h" // bst_node_t +#include "predict_fn.h" // GetNextNode +#include "xgboost/base.h" // bst_node_t #include "xgboost/logging.h" #include "xgboost/tree_model.h" // RegTree diff --git a/src/predictor/cpu_treeshap.h b/src/predictor/cpu_treeshap.h index 702b3d571..3cdbcc4a9 100644 --- a/src/predictor/cpu_treeshap.h +++ b/src/predictor/cpu_treeshap.h @@ -1,6 +1,10 @@ +#ifndef XGBOOST_PREDICTOR_CPU_TREESHAP_H_ +#define XGBOOST_PREDICTOR_CPU_TREESHAP_H_ /** * Copyright by XGBoost Contributors 2017-2022 */ +#include // vector + #include "xgboost/tree_model.h" // RegTree namespace xgboost { @@ -15,3 +19,4 @@ void CalculateContributions(RegTree const &tree, const RegTree::FVec &feat, std::vector *mean_values, bst_float *out_contribs, int condition, unsigned condition_feature); } // namespace xgboost +#endif // XGBOOST_PREDICTOR_CPU_TREESHAP_H_ diff --git a/src/tree/gpu_hist/evaluate_splits.cu b/src/tree/gpu_hist/evaluate_splits.cu index 781fff92a..540b9c4fe 100644 --- a/src/tree/gpu_hist/evaluate_splits.cu +++ b/src/tree/gpu_hist/evaluate_splits.cu @@ -359,8 +359,8 @@ void GPUHistEvaluator::LaunchEvaluateSplits( // One block for each feature uint32_t constexpr kBlockThreads = 32; - dh::LaunchKernel{static_cast(combined_num_features), kBlockThreads, - 0}( + dh::LaunchKernel {static_cast(combined_num_features), kBlockThreads, + 0}( EvaluateSplitsKernel, max_active_features, d_inputs, shared_inputs, this->SortedIdx(d_inputs.size(), shared_inputs.feature_values.size()), diff --git a/src/tree/gpu_hist/histogram.cu b/src/tree/gpu_hist/histogram.cu index 1344ecf4f..eda9baba9 100644 --- a/src/tree/gpu_hist/histogram.cu +++ b/src/tree/gpu_hist/histogram.cu @@ -299,7 +299,7 @@ void BuildGradientHistogram(CUDAContext const* ctx, EllpackDeviceAccessor const& min(grid_size, unsigned(common::DivRoundUp(items_per_group, kMinItemsPerBlock))); - dh::LaunchKernel{dim3(grid_size, num_groups), static_cast(kBlockThreads), smem_size, + dh::LaunchKernel {dim3(grid_size, num_groups), static_cast(kBlockThreads), smem_size, ctx->Stream()} (kernel, matrix, feature_groups, d_ridx, histogram.data(), gpair.data(), rounding); };