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
58000683
Commit
58000683
authored
Feb 27, 2017
by
Guolin Ke
Browse files
fix index out of range bug.
parent
5e3b7193
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
4 deletions
+6
-4
src/io/dense_nbits_bin.hpp
src/io/dense_nbits_bin.hpp
+6
-4
No files found.
src/io/dense_nbits_bin.hpp
View file @
58000683
...
@@ -206,7 +206,8 @@ public:
...
@@ -206,7 +206,8 @@ public:
void
LoadFromMemory
(
const
void
*
memory
,
const
std
::
vector
<
data_size_t
>&
local_used_indices
)
override
{
void
LoadFromMemory
(
const
void
*
memory
,
const
std
::
vector
<
data_size_t
>&
local_used_indices
)
override
{
const
uint8_t
*
mem_data
=
reinterpret_cast
<
const
uint8_t
*>
(
memory
);
const
uint8_t
*
mem_data
=
reinterpret_cast
<
const
uint8_t
*>
(
memory
);
if
(
!
local_used_indices
.
empty
())
{
if
(
!
local_used_indices
.
empty
())
{
for
(
int
i
=
0
;
i
<
num_data_
;
i
+=
2
)
{
const
data_size_t
rest
=
num_data_
&
1
;
for
(
int
i
=
0
;
i
<
num_data_
-
rest
;
i
+=
2
)
{
// get old bins
// get old bins
data_size_t
idx
=
local_used_indices
[
i
];
data_size_t
idx
=
local_used_indices
[
i
];
const
auto
bin1
=
static_cast
<
uint8_t
>
((
mem_data
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
);
const
auto
bin1
=
static_cast
<
uint8_t
>
((
mem_data
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
);
...
@@ -216,7 +217,7 @@ public:
...
@@ -216,7 +217,7 @@ public:
const
int
i1
=
i
>>
1
;
const
int
i1
=
i
>>
1
;
data_
[
i1
]
=
(
bin1
|
(
bin2
<<
4
));
data_
[
i1
]
=
(
bin1
|
(
bin2
<<
4
));
}
}
if
(
(
num_data_
&
1
)
==
1
)
{
if
(
rest
)
{
data_size_t
idx
=
local_used_indices
[
num_data_
-
1
];
data_size_t
idx
=
local_used_indices
[
num_data_
-
1
];
data_
[
num_data_
/
2
+
1
]
=
(
mem_data
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
;
data_
[
num_data_
/
2
+
1
]
=
(
mem_data
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
;
}
}
...
@@ -229,7 +230,8 @@ public:
...
@@ -229,7 +230,8 @@ public:
void
CopySubset
(
const
Bin
*
full_bin
,
const
data_size_t
*
used_indices
,
data_size_t
num_used_indices
)
override
{
void
CopySubset
(
const
Bin
*
full_bin
,
const
data_size_t
*
used_indices
,
data_size_t
num_used_indices
)
override
{
auto
other_bin
=
reinterpret_cast
<
const
Dense4bitsBin
*>
(
full_bin
);
auto
other_bin
=
reinterpret_cast
<
const
Dense4bitsBin
*>
(
full_bin
);
for
(
int
i
=
0
;
i
<
num_used_indices
;
i
+=
2
)
{
const
data_size_t
rest
=
num_used_indices
&
1
;
for
(
int
i
=
0
;
i
<
num_used_indices
-
rest
;
i
+=
2
)
{
data_size_t
idx
=
used_indices
[
i
];
data_size_t
idx
=
used_indices
[
i
];
const
auto
bin1
=
static_cast
<
uint8_t
>
((
other_bin
->
data_
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
);
const
auto
bin1
=
static_cast
<
uint8_t
>
((
other_bin
->
data_
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
);
idx
=
used_indices
[
i
+
1
];
idx
=
used_indices
[
i
+
1
];
...
@@ -237,7 +239,7 @@ public:
...
@@ -237,7 +239,7 @@ public:
const
int
i1
=
i
>>
1
;
const
int
i1
=
i
>>
1
;
data_
[
i1
]
=
(
bin1
|
(
bin2
<<
4
));
data_
[
i1
]
=
(
bin1
|
(
bin2
<<
4
));
}
}
if
(
(
num_used_indices
&
1
)
==
1
)
{
if
(
rest
)
{
data_size_t
idx
=
used_indices
[
num_used_indices
-
1
];
data_size_t
idx
=
used_indices
[
num_used_indices
-
1
];
data_
[
num_used_indices
/
2
+
1
]
=
(
other_bin
->
data_
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
;
data_
[
num_used_indices
/
2
+
1
]
=
(
other_bin
->
data_
[
idx
>>
1
]
>>
((
idx
&
1
)
<<
2
))
&
0xf
;
}
}
...
...
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