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
2427b205
Unverified
Commit
2427b205
authored
Jul 10, 2019
by
Scott Cyphers
Committed by
GitHub
Jul 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement traverse nodes with pointers (#3205)
parent
9b3d5732
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
20 deletions
+15
-20
graph_util.cpp
src/ngraph/graph_util.cpp
+15
-20
No files found.
src/ngraph/graph_util.cpp
View file @
2427b205
...
...
@@ -69,39 +69,34 @@ void ngraph::traverse_nodes(const NodeVector& subgraph_results,
bool
include_control_deps
,
const
NodeVector
&
subgraph_params
)
{
std
::
unordered_set
<
std
::
shared_ptr
<
Node
>>
instances_seen
{
subgraph_params
.
begin
(),
subgraph_params
.
end
()};
std
::
deque
<
std
::
shared_ptr
<
Node
>>
stack
;
for
(
auto
r
:
subgraph_results
)
std
::
unordered_set
<
Node
*>
instances_seen
;
std
::
deque
<
Node
*>
stack
;
for
(
auto
&
node_ptr
:
subgraph_params
)
{
stack
.
push_front
(
r
);
instances_seen
.
insert
(
node_ptr
.
get
());
}
for
(
auto
&
node_ptr
:
subgraph_results
)
{
stack
.
push_front
(
node_ptr
.
get
());
}
while
(
stack
.
size
()
>
0
)
{
std
::
shared_ptr
<
Node
>
n
=
stack
.
front
();
Node
*
n
=
stack
.
front
();
stack
.
pop_front
();
if
(
instances_seen
.
count
(
n
)
==
0
)
if
(
instances_seen
.
insert
(
n
).
second
)
{
instances_seen
.
insert
(
n
);
f
(
n
);
for
(
auto
arg
:
n
->
get_arguments
())
f
(
n
->
shared_from_this
());
for
(
auto
&
arg
:
n
->
get_arguments
())
{
if
(
instances_seen
.
count
(
arg
)
==
0
)
{
stack
.
push_front
(
arg
);
}
stack
.
push_front
(
arg
.
get
());
}
if
(
include_control_deps
)
{
for
(
auto
cdep
:
n
->
get_control_dependencies
())
for
(
auto
&
cdep
:
n
->
get_control_dependencies
())
{
if
(
instances_seen
.
count
(
cdep
)
==
0
)
{
stack
.
push_front
(
cdep
);
}
stack
.
push_front
(
cdep
.
get
());
}
}
}
...
...
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