Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
f076fea9
Commit
f076fea9
authored
Mar 20, 2018
by
Nick Korovaiko
Committed by
Robert Kimball
Mar 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `--visualize` to nbench (#679)
* add visualize option to nbench * check for dot, amend help msg
parent
2e1823fe
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
7 deletions
+39
-7
visualize_tree.cpp
src/ngraph/pass/visualize_tree.cpp
+17
-7
visualize_tree.hpp
src/ngraph/pass/visualize_tree.hpp
+2
-0
nbench.cpp
src/tools/nbench/nbench.cpp
+20
-0
No files found.
src/ngraph/pass/visualize_tree.cpp
View file @
f076fea9
...
...
@@ -114,6 +114,22 @@ std::string pass::VisualizeTree::get_attributes(shared_ptr<Node> node)
return
ss
.
str
();
}
std
::
string
pass
::
VisualizeTree
::
get_file_ext
()
{
const
char
*
format
=
std
::
getenv
(
"NGRAPH_VISUALIZE_TREE_OUTPUT_FORMAT"
);
if
(
!
format
)
{
format
=
"png"
;
}
if
(
format
[
0
]
==
'.'
)
{
format
+=
1
;
}
return
std
::
string
(
format
);
}
void
pass
::
VisualizeTree
::
render
()
const
{
#ifdef GRAPHVIZ_FOUND
...
...
@@ -128,13 +144,7 @@ void pass::VisualizeTree::render() const
stringstream
ss
;
const
char
*
format
=
std
::
getenv
(
"NGRAPH_VISUALIZE_TREE_OUTPUT_FORMAT"
);
if
(
!
format
)
{
format
=
"png"
;
}
ss
<<
"dot -T"
<<
format
<<
" "
<<
tmp_file
<<
" -o "
<<
m_name
;
ss
<<
"dot -T"
<<
get_file_ext
()
<<
" "
<<
tmp_file
<<
" -o "
<<
m_name
;
auto
cmd
=
ss
.
str
();
auto
stream
=
popen
(
cmd
.
c_str
(),
"r"
);
pclose
(
stream
);
...
...
src/ngraph/pass/visualize_tree.hpp
View file @
f076fea9
...
...
@@ -36,6 +36,8 @@ public:
VisualizeTree
(
const
std
::
string
&
file_name
);
bool
run_on_module
(
std
::
vector
<
std
::
shared_ptr
<
ngraph
::
Function
>>&
)
override
;
static
std
::
string
get_file_ext
();
private
:
std
::
string
add_attributes
(
std
::
shared_ptr
<
Node
>
node
);
std
::
string
get_attributes
(
std
::
shared_ptr
<
Node
>
node
);
...
...
src/tools/nbench/nbench.cpp
View file @
f076fea9
...
...
@@ -22,6 +22,9 @@
#include <fstream>
#include <ngraph/file_util.hpp>
#include <ngraph/file_util.hpp>
#include <ngraph/pass/manager.hpp>
#include <ngraph/pass/visualize_tree.hpp>
#include <ngraph/runtime/backend.hpp>
#include <ngraph/runtime/call_frame.hpp>
#include <ngraph/runtime/manager.hpp>
...
...
@@ -41,6 +44,7 @@ int main(int argc, char** argv)
bool
failed
=
false
;
bool
statistics
=
false
;
bool
timing_detail
=
false
;
bool
visualize
=
false
;
for
(
size_t
i
=
1
;
i
<
argc
;
i
++
)
{
string
arg
=
argv
[
i
];
...
...
@@ -72,6 +76,10 @@ int main(int argc, char** argv)
{
timing_detail
=
true
;
}
else
if
(
arg
==
"-v"
||
arg
==
"--visualize"
)
{
visualize
=
true
;
}
else
{
cout
<<
"Unknown option: "
<<
arg
<<
endl
;
...
...
@@ -98,6 +106,7 @@ OPTIONS
-b|--backend Backend to use (default: CPU)
-i|--iterations Iterations (default: 10)
-s|--statistics Display op stastics
-v|--visualize Visualize a model (WARNING: requires GraphViz installed)
--timing_detail Gather detailed timing
)###"
;
return
1
;
...
...
@@ -106,6 +115,17 @@ OPTIONS
const
string
json_string
=
file_util
::
read_file_to_string
(
model
);
stringstream
ss
(
json_string
);
shared_ptr
<
Function
>
f
=
deserialize
(
ss
);
if
(
visualize
)
{
auto
model_file_name
=
ngraph
::
file_util
::
get_file_name
(
model
)
+
std
::
string
(
"."
)
+
pass
::
VisualizeTree
::
get_file_ext
();
pass
::
Manager
pass_manager
;
pass_manager
.
register_pass
<
pass
::
VisualizeTree
>
(
model_file_name
);
pass_manager
.
run_passes
(
f
);
}
if
(
statistics
)
{
cout
<<
"statistics:"
<<
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