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
gaoqiong
MIGraphX
Commits
056c6fe2
Commit
056c6fe2
authored
Jul 11, 2018
by
Scott Thornton
Browse files
Made reverse_int a function instead of lambda; changed check for argc
parent
af1d7a1f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
21 deletions
+12
-21
src/onnx/mnist.cpp
src/onnx/mnist.cpp
+12
-21
No files found.
src/onnx/mnist.cpp
View file @
056c6fe2
...
...
@@ -9,18 +9,19 @@
#include <migraph/cpu/cpu_target.hpp>
#include <migraph/generate.hpp>
std
::
vector
<
float
>
read_mnist_images
(
std
::
string
full_path
,
int
&
number_of_images
,
int
&
i
mage_size
)
auto
reverse_int
(
unsigned
int
i
)
{
auto
reverse_int
=
[](
unsigned
int
i
)
{
unsigned
char
c1
,
c2
,
c3
,
c4
;
c1
=
i
&
255u
;
c2
=
(
i
>>
8u
)
&
255u
;
c3
=
(
i
>>
16u
)
&
255u
;
c4
=
(
i
>>
24u
)
&
255u
;
return
(
static_cast
<
unsigned
int
>
(
c1
)
<<
24u
)
+
(
static_cast
<
unsigned
int
>
(
c2
)
<<
16u
)
+
(
static_cast
<
unsigned
int
>
(
c3
)
<<
8u
)
+
c4
;
};
unsigned
char
c1
,
c2
,
c3
,
c4
;
c1
=
i
&
255u
;
c2
=
(
i
>>
8u
)
&
255u
;
c3
=
(
i
>>
16u
)
&
255u
;
c4
=
(
i
>>
24u
)
&
255u
;
return
(
static_cast
<
unsigned
int
>
(
c1
)
<<
24u
)
+
(
static_cast
<
unsigned
int
>
(
c2
)
<<
16u
)
+
(
static_cast
<
unsigned
int
>
(
c3
)
<<
8u
)
+
c4
;
};
std
::
vector
<
float
>
read_mnist_images
(
std
::
string
full_path
,
int
&
number_of_images
,
int
&
image_size
)
{
using
uchar
=
unsigned
char
;
std
::
ifstream
file
(
full_path
,
std
::
ios
::
binary
);
...
...
@@ -64,16 +65,6 @@ std::vector<float> read_mnist_images(std::string full_path, int& number_of_image
std
::
vector
<
int32_t
>
read_mnist_labels
(
std
::
string
full_path
,
int
&
number_of_labels
)
{
auto
reverse_int
=
[](
unsigned
int
i
)
{
unsigned
char
c1
,
c2
,
c3
,
c4
;
c1
=
i
&
255u
;
c2
=
(
i
>>
8u
)
&
255u
;
c3
=
(
i
>>
16u
)
&
255u
;
c4
=
(
i
>>
24u
)
&
255u
;
return
(
static_cast
<
unsigned
int
>
(
c1
)
<<
24u
)
+
(
static_cast
<
unsigned
int
>
(
c2
)
<<
16u
)
+
(
static_cast
<
unsigned
int
>
(
c3
)
<<
8u
)
+
c4
;
};
using
uchar
=
unsigned
char
;
std
::
ifstream
file
(
full_path
,
std
::
ios
::
binary
);
...
...
@@ -116,7 +107,7 @@ std::vector<float> softmax(std::vector<float> p) {
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
argc
>
1
)
if
(
argc
>
3
)
{
std
::
string
datafile
=
argv
[
2
];
std
::
string
labelfile
=
argv
[
3
];
...
...
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