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
850f0391
Commit
850f0391
authored
Aug 11, 2017
by
Guolin Ke
Browse files
remove some duplicate codes
parent
203df1b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
44 deletions
+24
-44
src/io/dataset.cpp
src/io/dataset.cpp
+24
-44
No files found.
src/io/dataset.cpp
View file @
850f0391
...
@@ -589,6 +589,22 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
...
@@ -589,6 +589,22 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
if
(
leaf_idx
<
0
||
num_data
<=
0
||
hist_data
==
nullptr
)
{
if
(
leaf_idx
<
0
||
num_data
<=
0
||
hist_data
==
nullptr
)
{
return
;
return
;
}
}
std
::
vector
<
int
>
used_group
;
used_group
.
reserve
(
num_groups_
);
for
(
int
group
=
0
;
group
<
num_groups_
;
++
group
)
{
bool
is_groud_used
=
false
;
const
int
f_cnt
=
group_feature_cnt_
[
group
];
for
(
int
j
=
0
;
j
<
f_cnt
;
++
j
)
{
const
int
fidx
=
group_feature_start_
[
group
]
+
j
;
if
(
is_feature_used
[
fidx
])
{
is_groud_used
=
true
;
break
;
}
}
used_group
.
push_back
(
group
);
}
int
num_used_group
=
static_cast
<
int
>
(
used_group
.
size
());
auto
ptr_ordered_grad
=
gradients
;
auto
ptr_ordered_grad
=
gradients
;
auto
ptr_ordered_hess
=
hessians
;
auto
ptr_ordered_hess
=
hessians
;
if
(
data_indices
!=
nullptr
&&
num_data
<
num_data_
)
{
if
(
data_indices
!=
nullptr
&&
num_data
<
num_data_
)
{
...
@@ -609,18 +625,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
...
@@ -609,18 +625,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
if
(
!
is_constant_hessian
)
{
if
(
!
is_constant_hessian
)
{
OMP_INIT_EX
();
OMP_INIT_EX
();
#pragma omp parallel for schedule(static)
#pragma omp parallel for schedule(static)
for
(
int
g
roup
=
0
;
g
roup
<
num_group
s_
;
++
g
roup
)
{
for
(
int
g
i
=
0
;
g
i
<
num_
used_
group
;
++
g
i
)
{
OMP_LOOP_EX_BEGIN
();
OMP_LOOP_EX_BEGIN
();
bool
is_groud_used
=
false
;
int
group
=
used_group
[
gi
];
const
int
f_cnt
=
group_feature_cnt_
[
group
];
for
(
int
j
=
0
;
j
<
f_cnt
;
++
j
)
{
const
int
fidx
=
group_feature_start_
[
group
]
+
j
;
if
(
is_feature_used
[
fidx
])
{
is_groud_used
=
true
;
break
;
}
}
if
(
!
is_groud_used
)
{
continue
;
}
// feature is not used
// feature is not used
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
...
@@ -647,18 +654,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
...
@@ -647,18 +654,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
}
else
{
}
else
{
OMP_INIT_EX
();
OMP_INIT_EX
();
#pragma omp parallel for schedule(static)
#pragma omp parallel for schedule(static)
for
(
int
g
roup
=
0
;
g
roup
<
num_group
s_
;
++
g
roup
)
{
for
(
int
g
i
=
0
;
g
i
<
num_
used_
group
;
++
g
i
)
{
OMP_LOOP_EX_BEGIN
();
OMP_LOOP_EX_BEGIN
();
bool
is_groud_used
=
false
;
int
group
=
used_group
[
gi
];
const
int
f_cnt
=
group_feature_cnt_
[
group
];
for
(
int
j
=
0
;
j
<
f_cnt
;
++
j
)
{
const
int
fidx
=
group_feature_start_
[
group
]
+
j
;
if
(
is_feature_used
[
fidx
])
{
is_groud_used
=
true
;
break
;
}
}
if
(
!
is_groud_used
)
{
continue
;
}
// feature is not used
// feature is not used
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
...
@@ -689,18 +687,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
...
@@ -689,18 +687,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
if
(
!
is_constant_hessian
)
{
if
(
!
is_constant_hessian
)
{
OMP_INIT_EX
();
OMP_INIT_EX
();
#pragma omp parallel for schedule(static)
#pragma omp parallel for schedule(static)
for
(
int
g
roup
=
0
;
g
roup
<
num_group
s_
;
++
g
roup
)
{
for
(
int
g
i
=
0
;
g
i
<
num_
used_
group
;
++
g
i
)
{
OMP_LOOP_EX_BEGIN
();
OMP_LOOP_EX_BEGIN
();
bool
is_groud_used
=
false
;
int
group
=
used_group
[
gi
];
const
int
f_cnt
=
group_feature_cnt_
[
group
];
for
(
int
j
=
0
;
j
<
f_cnt
;
++
j
)
{
const
int
fidx
=
group_feature_start_
[
group
]
+
j
;
if
(
is_feature_used
[
fidx
])
{
is_groud_used
=
true
;
break
;
}
}
if
(
!
is_groud_used
)
{
continue
;
}
// feature is not used
// feature is not used
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
...
@@ -726,18 +715,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
...
@@ -726,18 +715,9 @@ void Dataset::ConstructHistograms(const std::vector<int8_t>& is_feature_used,
}
else
{
}
else
{
OMP_INIT_EX
();
OMP_INIT_EX
();
#pragma omp parallel for schedule(static)
#pragma omp parallel for schedule(static)
for
(
int
g
roup
=
0
;
g
roup
<
num_group
s_
;
++
g
roup
)
{
for
(
int
g
i
=
0
;
g
i
<
num_
used_
group
;
++
g
i
)
{
OMP_LOOP_EX_BEGIN
();
OMP_LOOP_EX_BEGIN
();
bool
is_groud_used
=
false
;
int
group
=
used_group
[
gi
];
const
int
f_cnt
=
group_feature_cnt_
[
group
];
for
(
int
j
=
0
;
j
<
f_cnt
;
++
j
)
{
const
int
fidx
=
group_feature_start_
[
group
]
+
j
;
if
(
is_feature_used
[
fidx
])
{
is_groud_used
=
true
;
break
;
}
}
if
(
!
is_groud_used
)
{
continue
;
}
// feature is not used
// feature is not used
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
auto
data_ptr
=
hist_data
+
group_bin_boundaries_
[
group
];
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
const
int
num_bin
=
feature_groups_
[
group
]
->
num_total_bin_
;
...
...
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