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
9c564ce8
Commit
9c564ce8
authored
Apr 16, 2018
by
Paul
Browse files
Update graph parsing
parent
a536b16b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
6 deletions
+25
-6
src/read_onnx.cpp
src/read_onnx.cpp
+25
-6
No files found.
src/read_onnx.cpp
View file @
9c564ce8
...
...
@@ -4,8 +4,32 @@
#include <onnx.pb.h>
#include <iostream>
#include <fstream>
#include <unordered_map>
std
::
unordered_map
<
std
::
string
,
onnx
::
AttributeProto
>
get_attributes
(
const
onnx
::
NodeProto
&
node
)
{
std
::
unordered_map
<
std
::
string
,
onnx
::
AttributeProto
>
result
;
for
(
auto
&&
attr
:
node
.
attribute
())
{
result
[
attr
.
name
()]
=
attr
;
}
return
result
;
}
void
parse_graph
(
onnx
::
GraphProto
graph
)
{
std
::
cout
<<
"Graph name: "
<<
graph
.
name
()
<<
std
::
endl
;
for
(
onnx
::
NodeProto
node
:
graph
.
node
())
{
std
::
cout
<<
"Layer: "
<<
node
.
op_type
()
<<
std
::
endl
;
std
::
cout
<<
" Name: "
<<
node
.
name
()
<<
std
::
endl
;
if
(
node
.
input_size
()
>
0
)
std
::
cout
<<
" Input: "
<<
node
.
input
(
0
)
<<
std
::
endl
;
if
(
node
.
output_size
()
>
0
)
std
::
cout
<<
" Output: "
<<
node
.
output
(
0
)
<<
std
::
endl
;
}
}
int
main
(
int
argc
,
char
const
*
argv
[])
{
if
(
argc
>
1
)
...
...
@@ -19,12 +43,7 @@ int main(int argc, char const *argv[])
std
::
cout
<<
"Producer version: "
<<
model
.
release_producer_version
()
<<
std
::
endl
;
if
(
model
.
has_graph
())
{
std
::
cout
<<
"Model has graph"
<<
std
::
endl
;
onnx
::
GraphProto
graph
=
model
.
graph
();
std
::
cout
<<
"Graph name: "
<<
graph
.
name
()
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
graph
.
node_size
();
i
++
)
{
onnx
::
NodeProto
node
=
graph
.
node
(
i
);
std
::
cout
<<
"Layer: "
<<
node
.
op_type
()
<<
std
::
endl
;
}
parse_graph
(
model
.
graph
());
}
}
else
{
std
::
cout
<<
"Failed reading: "
<<
file
<<
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