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
19d2b713
Commit
19d2b713
authored
Aug 24, 2018
by
wsttiger
Browse files
Forgot to add these files to the previous commit
parent
a36c7a1f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
7 additions
and
33 deletions
+7
-33
src/include/migraph/operators.hpp
src/include/migraph/operators.hpp
+0
-10
src/onnx/cifar10.cpp
src/onnx/cifar10.cpp
+4
-12
src/onnx/mnist.cpp
src/onnx/mnist.cpp
+2
-10
test/cpu_ops_test.cpp
test/cpu_ops_test.cpp
+1
-1
No files found.
src/include/migraph/operators.hpp
View file @
19d2b713
...
...
@@ -163,16 +163,6 @@ struct pooling
std
::
ptrdiff_t
(
std
::
floor
((
input
.
lens
()[
3
]
+
2
*
padding
[
1
]
-
lengths
[
1
])
/
static_cast
<
float
>
(
stride
[
1
])))
+
1
)),
// std::size_t(std::max<std::ptrdiff_t>(
// 1,
// std::ptrdiff_t((input.lens()[2] + 2 * padding[0] - lengths[0]) /
// static_cast<float>(stride[0])) +
// 1)),
// std::size_t(std::max<std::ptrdiff_t>(
// 1,
// std::ptrdiff_t((input.lens()[3] + 2 * padding[1] - lengths[1]) /
// static_cast<float>(stride[1])) +
// 1)),
}};
}
...
...
src/onnx/cifar10.cpp
View file @
19d2b713
...
...
@@ -11,6 +11,8 @@
#include <migraph/gpu/hip.hpp>
#include <migraph/generate.hpp>
#include "softmax.h"
auto
read_cifar10_images
(
const
std
::
string
&
full_path
)
{
std
::
ifstream
file
(
full_path
,
std
::
ios
::
binary
);
...
...
@@ -42,16 +44,6 @@ auto read_cifar10_images(const std::string& full_path)
}
}
std
::
vector
<
float
>
softmax
(
std
::
vector
<
float
>
p
)
{
size_t
n
=
p
.
size
();
std
::
vector
<
float
>
result
(
n
);
std
::
transform
(
p
.
begin
(),
p
.
end
(),
result
.
begin
(),
[](
auto
x
)
{
return
std
::
exp
(
x
);
});
float
s
=
std
::
accumulate
(
result
.
begin
(),
result
.
end
(),
0.0
f
,
std
::
plus
<
float
>
());
std
::
transform
(
result
.
begin
(),
result
.
end
(),
result
.
begin
(),
[
=
](
auto
x
)
{
return
x
/
s
;
});
return
result
;
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
argc
<
4
)
...
...
@@ -85,7 +77,7 @@ int main(int argc, char const* argv[])
auto
result
=
migraph
::
gpu
::
from_gpu
(
prog
.
eval
(
m
));
std
::
vector
<
float
>
logits
;
result
.
visit
([
&
](
auto
output
)
{
logits
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
probs
=
softmax
(
logits
);
std
::
vector
<
float
>
probs
=
softmax
<
float
>
(
logits
);
for
(
auto
x
:
probs
)
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
<<
std
::
endl
;
...
...
@@ -106,7 +98,7 @@ int main(int argc, char const* argv[])
auto
result
=
prog
.
eval
({{
"0"
,
input3
}});
std
::
vector
<
float
>
logits
;
result
.
visit
([
&
](
auto
output
)
{
logits
.
assign
(
output
.
begin
(),
output
.
end
());
});
std
::
vector
<
float
>
probs
=
softmax
(
logits
);
std
::
vector
<
float
>
probs
=
softmax
<
float
>
(
logits
);
for
(
auto
x
:
probs
)
std
::
cout
<<
x
<<
" "
;
std
::
cout
<<
std
::
endl
;
...
...
src/onnx/mnist.cpp
View file @
19d2b713
...
...
@@ -10,6 +10,8 @@
#include <migraph/gpu/hip.hpp>
#include <migraph/generate.hpp>
#include "softmax.h"
auto
reverse_int
(
unsigned
int
i
)
{
unsigned
char
c1
,
c2
,
c3
,
c4
;
...
...
@@ -98,16 +100,6 @@ std::vector<int32_t> read_mnist_labels(const std::string& full_path, int& number
}
}
std
::
vector
<
float
>
softmax
(
std
::
vector
<
float
>
p
)
{
size_t
n
=
p
.
size
();
std
::
vector
<
float
>
result
(
n
);
std
::
transform
(
p
.
begin
(),
p
.
end
(),
result
.
begin
(),
[](
auto
x
)
{
return
std
::
exp
(
x
);
});
float
s
=
std
::
accumulate
(
result
.
begin
(),
result
.
end
(),
0.0
f
,
std
::
plus
<
float
>
());
std
::
transform
(
result
.
begin
(),
result
.
end
(),
result
.
begin
(),
[
=
](
auto
x
)
{
return
x
/
s
;
});
return
result
;
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
argc
>
3
)
...
...
test/cpu_ops_test.cpp
View file @
19d2b713
...
...
@@ -659,7 +659,7 @@ int main()
gemm_test
<
double
>
();
reshape_test
();
transpose_test
();
//
contiguous_test();
contiguous_test
();
softmax_test
();
// maxpool_test();
conv2d_test
();
...
...
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