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
62695a3f
Commit
62695a3f
authored
Sep 06, 2017
by
Bob Kimball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add attributes to nodes
parent
d6fb6c39
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
3 deletions
+39
-3
visualize.cpp
src/ngraph/visualize.cpp
+33
-1
visualize.hpp
src/ngraph/visualize.hpp
+6
-2
No files found.
src/ngraph/visualize.cpp
View file @
62695a3f
...
...
@@ -34,11 +34,43 @@ void Visualize::add(node_ptr p)
traverse_nodes
(
p
,
[
&
](
node_ptr
node
)
{
for
(
auto
arg
:
node
->
get_arguments
())
{
m_ss
<<
" "
<<
arg
->
get_node_id
()
<<
" -> "
<<
node
->
get_node_id
()
<<
";
\n
"
;
m_ss
<<
add_attributes
(
arg
);
m_ss
<<
add_attributes
(
node
);
m_ss
<<
" "
<<
arg
->
get_node_id
()
<<
" -> "
<<
node
->
get_node_id
();
m_ss
<<
";
\n
"
;
}
});
}
std
::
string
Visualize
::
add_attributes
(
node_ptr
node
)
{
string
rc
;
if
(
!
contains
(
m_nodes_with_attributes
,
node
))
{
m_nodes_with_attributes
.
insert
(
node
);
rc
=
get_attributes
(
node
);
}
return
rc
;
}
std
::
string
Visualize
::
get_attributes
(
node_ptr
node
)
{
stringstream
ss
;
if
(
node
->
is_parameter
())
{
ss
<<
" "
<<
node
->
get_node_id
()
<<
" [shape=box color=blue]
\n
"
;
}
else
if
(
node
->
is_op
())
{
ss
<<
" "
<<
node
->
get_node_id
()
<<
" [shape=ellipse color=black]
\n
"
;
}
else
{
ss
<<
" "
<<
node
->
get_node_id
()
<<
" [shape=diamond color=red]
\n
"
;
}
return
ss
.
str
();
}
void
Visualize
::
save_dot
(
const
string
&
path
)
const
{
#if GRAPHVIZ_FOUND
...
...
src/ngraph/visualize.hpp
View file @
62695a3f
...
...
@@ -36,6 +36,10 @@ public:
void
save_dot
(
const
std
::
string
&
path
)
const
;
private
:
std
::
stringstream
m_ss
;
std
::
string
m_name
;
std
::
string
add_attributes
(
node_ptr
node
);
std
::
string
get_attributes
(
node_ptr
node
);
std
::
stringstream
m_ss
;
std
::
string
m_name
;
std
::
set
<
node_ptr
>
m_nodes_with_attributes
;
};
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