Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
03b861f1
Commit
03b861f1
authored
Apr 11, 2019
by
Khalique
Browse files
initial testing of generating graph file
parent
af00eea8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
3 deletions
+47
-3
src/include/migraphx/program.hpp
src/include/migraphx/program.hpp
+1
-0
src/onnx/read_onnx.cpp
src/onnx/read_onnx.cpp
+2
-1
src/program.cpp
src/program.cpp
+44
-2
No files found.
src/include/migraphx/program.hpp
View file @
03b861f1
...
@@ -108,6 +108,7 @@ struct program
...
@@ -108,6 +108,7 @@ struct program
void
debug_print
()
const
;
void
debug_print
()
const
;
void
debug_print
(
instruction_ref
ins
)
const
;
void
debug_print
(
instruction_ref
ins
)
const
;
void
debug_print
(
const
std
::
vector
<
instruction_ref
>&
inss
)
const
;
void
debug_print
(
const
std
::
vector
<
instruction_ref
>&
inss
)
const
;
void
print_graph
(
std
::
ostream
&
os
)
const
;
void
dry_run
(
parameter_map
params
)
const
;
void
dry_run
(
parameter_map
params
)
const
;
...
...
src/onnx/read_onnx.cpp
View file @
03b861f1
...
@@ -7,6 +7,7 @@ int main(int argc, char const* argv[])
...
@@ -7,6 +7,7 @@ int main(int argc, char const* argv[])
{
{
std
::
string
file
=
argv
[
1
];
std
::
string
file
=
argv
[
1
];
auto
prog
=
migraphx
::
parse_onnx
(
file
);
auto
prog
=
migraphx
::
parse_onnx
(
file
);
std
::
cout
<<
prog
<<
std
::
endl
;
//std::cout << prog << std::endl;
prog
.
print_graph
(
std
::
cout
);
}
}
}
}
src/program.cpp
View file @
03b861f1
...
@@ -54,8 +54,42 @@ static void print_instruction(std::ostream& os,
...
@@ -54,8 +54,42 @@ static void print_instruction(std::ostream& os,
os
<<
" -> "
<<
ins
->
get_shape
();
os
<<
" -> "
<<
ins
->
get_shape
();
}
}
static
std
::
string
enclose_name
(
const
std
::
string
&
name
)
{
return
'"'
+
name
+
'"'
;
}
static
void
print_graph_node
(
std
::
ostream
&
os
,
instruction_ref
ins
,
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
)
{
os
<<
"
\t
"
;
if
(
!
ins
->
inputs
().
empty
())
{
char
delim
=
'{'
;
for
(
auto
&&
arg
:
ins
->
inputs
())
{
os
<<
delim
<<
enclose_name
(
names
.
at
(
arg
));
delim
=
' '
;
}
os
<<
'}'
;
os
<<
" -> "
;
}
os
<<
enclose_name
(
names
.
at
(
ins
))
<<
";"
;
// if(ins->name() == "@literal")
// {
// if(ins->get_literal().get_shape().elements() > 10)
// os << "{ ... }";
// else
// os << "{" << ins->get_literal() << "}";
// }
}
template
<
class
F
>
template
<
class
F
>
static
void
print_program
(
std
::
ostream
&
os
,
const
program
&
p
,
F
annonate
)
static
void
print_program
(
std
::
ostream
&
os
,
const
program
&
p
,
F
annonate
,
std
::
function
<
void
(
std
::
ostream
&
,
instruction_ref
,
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
)
>
print_func
=
print_instruction
)
{
{
std
::
unordered_map
<
instruction_ref
,
std
::
string
>
names
;
std
::
unordered_map
<
instruction_ref
,
std
::
string
>
names
;
int
count
=
0
;
int
count
=
0
;
...
@@ -76,7 +110,7 @@ static void print_program(std::ostream& os, const program& p, F annonate)
...
@@ -76,7 +110,7 @@ static void print_program(std::ostream& os, const program& p, F annonate)
(
void
)
arg
;
(
void
)
arg
;
}
}
print_
instruction
(
os
,
ins
,
names
);
print_
func
(
os
,
ins
,
names
);
annonate
(
ins
,
names
);
annonate
(
ins
,
names
);
...
@@ -531,6 +565,14 @@ void program::debug_print(const std::vector<instruction_ref>& inss) const
...
@@ -531,6 +565,14 @@ void program::debug_print(const std::vector<instruction_ref>& inss) const
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
std
::
endl
;
}
}
void
program
::
print_graph
(
std
::
ostream
&
os
)
const
{
os
<<
"digraph {"
<<
std
::
endl
;
os
<<
"
\t
rankdir=LR;"
<<
std
::
endl
;
print_program
(
os
,
*
this
,
[](
auto
&&
...)
{},
print_graph_node
);
os
<<
"}"
<<
std
::
endl
;
}
void
program
::
dry_run
(
std
::
unordered_map
<
std
::
string
,
argument
>
params
)
const
void
program
::
dry_run
(
std
::
unordered_map
<
std
::
string
,
argument
>
params
)
const
{
{
auto
&
ctx
=
this
->
impl
->
ctx
;
auto
&
ctx
=
this
->
impl
->
ctx
;
...
...
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