Unverified Commit c315087f authored by Nikita Titov's avatar Nikita Titov Committed by GitHub
Browse files

fixed cpplint issues (#2771)

parent 9f79e840
...@@ -297,7 +297,7 @@ struct TrainingTempState { ...@@ -297,7 +297,7 @@ struct TrainingTempState {
#pragma omp parallel #pragma omp parallel
#pragma omp master #pragma omp master
{ num_threads = omp_get_num_threads(); } { num_threads = omp_get_num_threads(); }
num_bin_aligned = num_bin_aligned =
(bin->num_bin() + kAlignedSize - 1) / kAlignedSize * kAlignedSize; (bin->num_bin() + kAlignedSize - 1) / kAlignedSize * kAlignedSize;
size_t new_size = static_cast<size_t>(num_bin_aligned) * 2 * num_threads; size_t new_size = static_cast<size_t>(num_bin_aligned) * 2 * num_threads;
if (new_size > hist_buf.size()) { if (new_size > hist_buf.size()) {
...@@ -447,8 +447,8 @@ class Dataset { ...@@ -447,8 +447,8 @@ class Dataset {
MultiValBin* GetMultiBinFromAllFeatures() const; MultiValBin* GetMultiBinFromAllFeatures() const;
TrainingTempState* TestMultiThreadingMethod( TrainingTempState* TestMultiThreadingMethod(
score_t* gradients, score_t* hessians, score_t* gradients, score_t* hessians,
const std::vector<int8_t>& is_feature_used, bool is_constant_hessian, const std::vector<int8_t>& is_feature_used, bool is_constant_hessian,
bool force_colwise, bool force_rowwise, bool* is_hist_col_wise) const; bool force_colwise, bool force_rowwise, bool* is_hist_col_wise) const;
LIGHTGBM_EXPORT void FinishLoad(); LIGHTGBM_EXPORT void FinishLoad();
......
...@@ -639,9 +639,8 @@ TrainingTempState* Dataset::TestMultiThreadingMethod( ...@@ -639,9 +639,8 @@ TrainingTempState* Dataset::TestMultiThreadingMethod(
auto overhead_cost = row_wise_init_time + row_wise_time + col_wise_time; auto overhead_cost = row_wise_init_time + row_wise_time + col_wise_time;
Log::Warning( Log::Warning(
"Auto-choosing col-wise multi-threading, the overhead of testing was " "Auto-choosing col-wise multi-threading, the overhead of testing was "
"%f " "%f seconds.\n"
"seconds.\nYou can set `force_col_wise=true` to remove the " "You can set `force_col_wise=true` to remove the overhead.",
"overhead.",
overhead_cost * 1e-3); overhead_cost * 1e-3);
return colwise_state.release(); return colwise_state.release();
} else { } else {
...@@ -649,10 +648,9 @@ TrainingTempState* Dataset::TestMultiThreadingMethod( ...@@ -649,10 +648,9 @@ TrainingTempState* Dataset::TestMultiThreadingMethod(
auto overhead_cost = col_wise_init_time + row_wise_time + col_wise_time; auto overhead_cost = col_wise_init_time + row_wise_time + col_wise_time;
Log::Warning( Log::Warning(
"Auto-choosing row-wise multi-threading, the overhead of testing was " "Auto-choosing row-wise multi-threading, the overhead of testing was "
"%f " "%f seconds.\n"
"seconds.\nYou can set `force_row_wise=true` to remove the " "You can set `force_row_wise=true` to remove the overhead.\n"
"overhead.\nAnd if memory is not enough, you can set " "And if memory is not enough, you can set `force_col_wise=true`.",
"`force_col_wise=true`.",
overhead_cost * 1e-3); overhead_cost * 1e-3);
if (rowwise_state->multi_val_bin->IsSparse()) { if (rowwise_state->multi_val_bin->IsSparse()) {
Log::Debug("Using Sparse Multi-Val Bin"); Log::Debug("Using Sparse Multi-Val Bin");
...@@ -1008,7 +1006,6 @@ void Dataset::DumpTextFile(const char* text_filename) { ...@@ -1008,7 +1006,6 @@ void Dataset::DumpTextFile(const char* text_filename) {
fclose(file); fclose(file);
} }
void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used, void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used,
bool is_colwise, TrainingTempState* temp_state) const { bool is_colwise, TrainingTempState* temp_state) const {
Common::FunctionTimer fun_time("Dataset::InitTrain", global_timer); Common::FunctionTimer fun_time("Dataset::InitTrain", global_timer);
...@@ -1024,7 +1021,7 @@ void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used, ...@@ -1024,7 +1021,7 @@ void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used,
std::vector<int> used_feature_index; std::vector<int> used_feature_index;
for (int i = 0; i < num_groups_; ++i) { for (int i = 0; i < num_groups_; ++i) {
int f_start = group_feature_start_[i]; int f_start = group_feature_start_[i];
if (feature_groups_[i]->is_multi_val_ ) { if (feature_groups_[i]->is_multi_val_) {
for (int j = 0; j < feature_groups_[i]->num_feature_; ++j) { for (int j = 0; j < feature_groups_[i]->num_feature_; ++j) {
const auto dense_rate = const auto dense_rate =
1.0 - feature_groups_[i]->bin_mappers_[j]->sparse_rate(); 1.0 - feature_groups_[i]->bin_mappers_[j]->sparse_rate();
...@@ -1086,11 +1083,11 @@ void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used, ...@@ -1086,11 +1083,11 @@ void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used,
lower_bound.push_back(num_total_bin - cur_num_bin); lower_bound.push_back(num_total_bin - cur_num_bin);
upper_bound.push_back(num_total_bin); upper_bound.push_back(num_total_bin);
temp_state->hist_move_src.push_back( temp_state->hist_move_src.push_back(
(new_num_total_bin - cur_num_bin) * 2); (new_num_total_bin - cur_num_bin) * 2);
temp_state->hist_move_dest.push_back((num_total_bin - cur_num_bin) * temp_state->hist_move_dest.push_back(
2); (num_total_bin - cur_num_bin) * 2);
temp_state->hist_move_size.push_back(cur_num_bin * 2); temp_state->hist_move_size.push_back(cur_num_bin * 2);
delta.push_back(num_total_bin - new_num_total_bin); delta.push_back(num_total_bin - new_num_total_bin);
} }
...@@ -1111,8 +1108,8 @@ void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used, ...@@ -1111,8 +1108,8 @@ void Dataset::InitTrain(const std::vector<int8_t>& is_feature_used,
lower_bound.push_back(num_total_bin - cur_num_bin); lower_bound.push_back(num_total_bin - cur_num_bin);
upper_bound.push_back(num_total_bin); upper_bound.push_back(num_total_bin);
temp_state->hist_move_src.push_back((new_num_total_bin - cur_num_bin) * temp_state->hist_move_src.push_back(
2); (new_num_total_bin - cur_num_bin) * 2);
temp_state->hist_move_dest.push_back((num_total_bin - cur_num_bin) * 2); temp_state->hist_move_dest.push_back((num_total_bin - cur_num_bin) * 2);
temp_state->hist_move_size.push_back(cur_num_bin * 2); temp_state->hist_move_size.push_back(cur_num_bin * 2);
delta.push_back(num_total_bin - new_num_total_bin); delta.push_back(num_total_bin - new_num_total_bin);
......
...@@ -5,9 +5,10 @@ ...@@ -5,9 +5,10 @@
#ifndef LIGHTGBM_IO_MULTI_VAL_DENSE_BIN_HPP_ #ifndef LIGHTGBM_IO_MULTI_VAL_DENSE_BIN_HPP_
#define LIGHTGBM_IO_MULTI_VAL_DENSE_BIN_HPP_ #define LIGHTGBM_IO_MULTI_VAL_DENSE_BIN_HPP_
#include <LightGBM/utils/openmp_wrapper.h>
#include <LightGBM/bin.h> #include <LightGBM/bin.h>
#include <LightGBM/utils/openmp_wrapper.h>
#include <algorithm>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <vector> #include <vector>
......
/*! /*!
* Copyright (c) 2020 Microsoft Corporation. All rights reserved. * Copyright (c) 2020 Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE file in the project root for * Licensed under the MIT License. See LICENSE file in the project root for license information.
* license information.
*/ */
#ifndef LIGHTGBM_IO_MULTI_VAL_SPARSE_BIN_HPP_ #ifndef LIGHTGBM_IO_MULTI_VAL_SPARSE_BIN_HPP_
#define LIGHTGBM_IO_MULTI_VAL_SPARSE_BIN_HPP_ #define LIGHTGBM_IO_MULTI_VAL_SPARSE_BIN_HPP_
...@@ -9,6 +8,7 @@ ...@@ -9,6 +8,7 @@
#include <LightGBM/bin.h> #include <LightGBM/bin.h>
#include <LightGBM/utils/openmp_wrapper.h> #include <LightGBM/utils/openmp_wrapper.h>
#include <algorithm>
#include <cstdint> #include <cstdint>
#include <cstring> #include <cstring>
#include <vector> #include <vector>
......
...@@ -81,12 +81,12 @@ void SerialTreeLearner::GetMultiValBin(const Dataset* dataset, bool is_first_tim ...@@ -81,12 +81,12 @@ void SerialTreeLearner::GetMultiValBin(const Dataset* dataset, bool is_first_tim
if (is_first_time) { if (is_first_time) {
auto used_feature = GetUsedFeatures(true); auto used_feature = GetUsedFeatures(true);
temp_state_.reset(dataset->TestMultiThreadingMethod( temp_state_.reset(dataset->TestMultiThreadingMethod(
ordered_gradients_.data(), ordered_hessians_.data(), used_feature, ordered_gradients_.data(), ordered_hessians_.data(), used_feature,
is_constant_hessian_, config_->force_col_wise, config_->force_row_wise, &is_hist_colwise_)); is_constant_hessian_, config_->force_col_wise, config_->force_row_wise, &is_hist_colwise_));
} else { } else {
// cannot change is_hist_col_wise during training // cannot change is_hist_col_wise during training
temp_state_.reset(dataset->TestMultiThreadingMethod( temp_state_.reset(dataset->TestMultiThreadingMethod(
ordered_gradients_.data(), ordered_hessians_.data(), is_feature_used_, ordered_gradients_.data(), ordered_hessians_.data(), is_feature_used_,
is_constant_hessian_, is_hist_colwise_, !is_hist_colwise_, &is_hist_colwise_)); is_constant_hessian_, is_hist_colwise_, !is_hist_colwise_, &is_hist_colwise_));
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment