Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CPP lint. #8807

Merged
merged 2 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions include/xgboost/metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@
#define XGBOOST_METRIC_H_

#include <dmlc/registry.h>
#include <xgboost/model.h>
#include <xgboost/data.h>
#include <xgboost/base.h>
#include <xgboost/data.h>
#include <xgboost/host_device_vector.h>
#include <xgboost/model.h>

#include <vector>
#include <string>
#include <functional>
#include <memory> // shared_ptr
#include <string>
#include <utility>
#include <vector>

namespace xgboost {
struct Context;
Expand Down
4 changes: 2 additions & 2 deletions src/data/sparse_page_dmatrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/metric/auc.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <algorithm>
#include <cassert>
#include <cub/cub.cuh>
#include <cub/cub.cuh> // NOLINT
#include <limits>
#include <memory>
#include <tuple>
Expand Down
1 change: 1 addition & 0 deletions src/metric/metric_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define XGBOOST_METRIC_METRIC_COMMON_H_

#include <limits>
#include <memory> // shared_ptr
#include <string>

#include "../common/common.h"
Expand Down
4 changes: 2 additions & 2 deletions src/objective/adaptive.cu
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
#include <thrust/sort.h>

#include <cstdint> // std::int32_t
#include <cub/cub.cuh>
#include <cstdint> // std::int32_t
#include <cub/cub.cuh> // NOLINT

#include "../common/cuda_context.cuh" // CUDAContext
#include "../common/device_helpers.cuh"
Expand Down
7 changes: 4 additions & 3 deletions src/predictor/cpu_treeshap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
*/
#include "cpu_treeshap.h"

#include <cinttypes> // std::uint32_t
#include <algorithm> // copy
#include <cinttypes> // 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

Expand Down
5 changes: 5 additions & 0 deletions src/predictor/cpu_treeshap.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#ifndef XGBOOST_PREDICTOR_CPU_TREESHAP_H_
#define XGBOOST_PREDICTOR_CPU_TREESHAP_H_
/**
* Copyright by XGBoost Contributors 2017-2022
*/
#include <vector> // vector

#include "xgboost/tree_model.h" // RegTree

namespace xgboost {
Expand All @@ -15,3 +19,4 @@ void CalculateContributions(RegTree const &tree, const RegTree::FVec &feat,
std::vector<float> *mean_values, bst_float *out_contribs, int condition,
unsigned condition_feature);
} // namespace xgboost
#endif // XGBOOST_PREDICTOR_CPU_TREESHAP_H_
4 changes: 2 additions & 2 deletions src/tree/gpu_hist/evaluate_splits.cu
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ void GPUHistEvaluator::LaunchEvaluateSplits(

// One block for each feature
uint32_t constexpr kBlockThreads = 32;
dh::LaunchKernel{static_cast<uint32_t>(combined_num_features), kBlockThreads,
0}(
dh::LaunchKernel {static_cast<uint32_t>(combined_num_features), kBlockThreads,
0}(
EvaluateSplitsKernel<kBlockThreads>, max_active_features, d_inputs,
shared_inputs,
this->SortedIdx(d_inputs.size(), shared_inputs.feature_values.size()),
Expand Down
2 changes: 1 addition & 1 deletion src/tree/gpu_hist/histogram.cu
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint32_t>(kBlockThreads), smem_size,
dh::LaunchKernel {dim3(grid_size, num_groups), static_cast<uint32_t>(kBlockThreads), smem_size,
ctx->Stream()} (kernel, matrix, feature_groups, d_ridx, histogram.data(),
gpair.data(), rounding);
};
Expand Down