Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
c315087f
Unverified
Commit
c315087f
authored
Feb 19, 2020
by
Nikita Titov
Committed by
GitHub
Feb 19, 2020
Browse files
fixed cpplint issues (#2771)
parent
9f79e840
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
22 deletions
+20
-22
include/LightGBM/dataset.h
include/LightGBM/dataset.h
+3
-3
src/io/dataset.cpp
src/io/dataset.cpp
+11
-14
src/io/multi_val_dense_bin.hpp
src/io/multi_val_dense_bin.hpp
+2
-1
src/io/multi_val_sparse_bin.hpp
src/io/multi_val_sparse_bin.hpp
+2
-2
src/treelearner/serial_tree_learner.cpp
src/treelearner/serial_tree_learner.cpp
+2
-2
No files found.
include/LightGBM/dataset.h
View file @
c315087f
...
@@ -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
();
...
...
src/io/dataset.cpp
View file @
c315087f
...
@@ -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.
\n
You 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.
\n
You can set `force_row_wise=true` to remove the "
"You can set `force_row_wise=true` to remove the overhead.
\n
"
"overhead.
\n
And 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
);
...
...
src/io/multi_val_dense_bin.hpp
View file @
c315087f
...
@@ -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>
...
...
src/io/multi_val_sparse_bin.hpp
View file @
c315087f
/*!
/*!
* 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>
...
...
src/treelearner/serial_tree_learner.cpp
View file @
c315087f
...
@@ -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_
));
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment