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
e1bd9673
Commit
e1bd9673
authored
Jun 26, 2018
by
Paul
Browse files
Add verify onnx driver
parent
3a1980fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
9 deletions
+57
-9
src/onnx/CMakeLists.txt
src/onnx/CMakeLists.txt
+5
-1
src/onnx/read_onnx.cpp
src/onnx/read_onnx.cpp
+0
-8
src/onnx/verify_onnx.cpp
src/onnx/verify_onnx.cpp
+52
-0
No files found.
src/onnx/CMakeLists.txt
View file @
e1bd9673
...
...
@@ -12,4 +12,8 @@ target_link_libraries(rtg_onnx onnx-proto rtg)
add_executable
(
read_onnx read_onnx.cpp
)
rocm_clang_tidy_check
(
read_onnx
)
target_link_libraries
(
read_onnx rtg_onnx rtg_cpu
)
target_link_libraries
(
read_onnx rtg_onnx
)
add_executable
(
verify_onnx verify_onnx.cpp
)
rocm_clang_tidy_check
(
verify_onnx
)
target_link_libraries
(
verify_onnx rtg_onnx rtg_cpu rtg_miopen
)
src/onnx/read_onnx.cpp
View file @
e1bd9673
#include <rtg/onnx.hpp>
#include <rtg/cpu/cpu_target.hpp>
#include <rtg/generate.hpp>
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
argc
>
1
)
{
std
::
string
file
=
argv
[
1
];
auto
prog
=
rtg
::
parse_onnx
(
file
);
prog
.
compile
(
rtg
::
cpu
::
cpu_target
{});
auto
s
=
prog
.
get_parameter_shape
(
"Input3"
);
auto
input3
=
generate_argument
(
s
);
auto
out
=
prog
.
eval
({{
"Input3"
,
input3
}});
(
void
)
out
;
std
::
cout
<<
prog
<<
std
::
endl
;
}
}
src/onnx/verify_onnx.cpp
0 → 100644
View file @
e1bd9673
#include <rtg/onnx.hpp>
#include <rtg/cpu/cpu_target.hpp>
#include <rtg/miopen/miopen_target.hpp>
#include <rtg/miopen/hip.hpp>
#include <rtg/generate.hpp>
#include <miopen/miopen.h>
#include <rtg/miopen/miopen.hpp>
rtg
::
argument
run_cpu
(
std
::
string
file
)
{
auto
p
=
rtg
::
parse_onnx
(
file
);
p
.
compile
(
rtg
::
cpu
::
cpu_target
{});
auto
s
=
p
.
get_parameter_shape
(
"Input3"
);
auto
input3
=
rtg
::
generate_argument
(
s
);
auto
out
=
p
.
eval
({{
"Input3"
,
input3
}});
std
::
cout
<<
p
<<
std
::
endl
;
return
out
;
}
rtg
::
argument
run_gpu
(
std
::
string
file
)
{
auto
p
=
rtg
::
parse_onnx
(
file
);
p
.
compile
(
rtg
::
cpu
::
cpu_target
{});
auto
s
=
p
.
get_parameter_shape
(
"Input3"
);
auto
input3
=
rtg
::
miopen
::
to_gpu
(
rtg
::
generate_argument
(
s
));
auto
output
=
rtg
::
miopen
::
to_gpu
(
rtg
::
generate_argument
(
p
.
get_parameter_shape
(
"output"
)));
auto
handle
=
rtg
::
miopen
::
make_obj
<
rtg
::
miopen
::
miopen_handle
>
(
&
miopenCreate
);
auto
out
=
p
.
eval
(
{{
"Input3"
,
input3
},
{
"handle"
,
{
rtg
::
shape
::
any_type
,
handle
.
get
()}},
{
"output"
,
output
}});
std
::
cout
<<
p
<<
std
::
endl
;
return
rtg
::
miopen
::
from_gpu
(
out
);
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
argc
>
1
)
{
std
::
string
file
=
argv
[
1
];
auto
x
=
run_cpu
(
file
);
auto
y
=
run_gpu
(
file
);
if
(
x
!=
y
)
{
std
::
cout
<<
"Not equal"
<<
std
::
endl
;
std
::
cout
<<
x
<<
std
::
endl
;
std
::
cout
<<
y
<<
std
::
endl
;
}
}
}
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