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
76047c77
Commit
76047c77
authored
Apr 09, 2018
by
Robert Kimball
Committed by
Scott Cyphers
Apr 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use less complex pass base where possible (#829)
parent
81c0ef79
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
52 deletions
+30
-52
assign_layout.hpp
src/ngraph/pass/assign_layout.hpp
+15
-18
assign_placement.cpp
src/ngraph/pass/assign_placement.cpp
+3
-13
assign_placement.hpp
src/ngraph/pass/assign_placement.hpp
+2
-3
get_output_element_elimination.cpp
src/ngraph/pass/get_output_element_elimination.cpp
+8
-11
get_output_element_elimination.hpp
src/ngraph/pass/get_output_element_elimination.hpp
+2
-7
No files found.
src/ngraph/pass/assign_layout.hpp
View file @
76047c77
...
...
@@ -27,32 +27,29 @@ namespace ngraph
namespace
pass
{
template
<
typename
LT
>
class
AssignLayout
:
public
CallGraph
Pass
class
AssignLayout
:
public
Node
Pass
{
public
:
virtual
bool
run_on_
call_graph
(
const
std
::
list
<
std
::
shared_ptr
<
Node
>>&
nodes
)
override
virtual
bool
run_on_
node
(
std
::
shared_ptr
<
Node
>
node
)
override
{
for
(
const
std
::
shared_ptr
<
Node
>&
node
:
nodes
)
try
{
try
for
(
size_t
i
=
0
;
i
<
node
->
get_output_size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
node
->
get_output_size
();
++
i
)
auto
tv
=
node
->
get_output_tensor_view
(
i
);
if
(
nullptr
==
tv
->
get_tensor_view_layout
())
{
auto
tv
=
node
->
get_output_tensor_view
(
i
);
if
(
nullptr
==
tv
->
get_tensor_view_layout
())
{
auto
layout
=
std
::
make_shared
<
LT
>
(
*
tv
);
tv
->
set_tensor_view_layout
(
layout
);
}
auto
layout
=
std
::
make_shared
<
LT
>
(
*
tv
);
tv
->
set_tensor_view_layout
(
layout
);
}
}
catch
(
const
std
::
exception
&
e
)
{
std
::
stringstream
ss
;
ss
<<
"Error with node "
<<
*
node
<<
": "
;
ss
<<
e
.
what
()
;
throw
std
::
invalid_argument
(
ss
.
str
()
);
}
}
catch
(
const
std
::
exception
&
e
)
{
std
::
stringstream
ss
;
ss
<<
"Error with node "
<<
*
node
<<
": "
;
ss
<<
e
.
what
(
);
throw
std
::
invalid_argument
(
ss
.
str
());
}
return
false
;
}
...
...
src/ngraph/pass/assign_placement.cpp
View file @
76047c77
...
...
@@ -18,25 +18,15 @@
#include "ngraph/node.hpp"
#include "ngraph/placement.hpp"
using
namespace
std
;
using
namespace
ngraph
;
using
namespace
std
;
ngraph
::
pass
::
AssignPlacement
::
AssignPlacement
(
std
::
function
<
Placement
(
std
::
shared_ptr
<
Node
>
)
>
placement_policy
)
pass
::
AssignPlacement
::
AssignPlacement
(
function
<
Placement
(
shared_ptr
<
Node
>
)
>
placement_policy
)
:
m_placement_policy
(
placement_policy
)
{
}
bool
ngraph
::
pass
::
AssignPlacement
::
run_on_call_graph
(
const
std
::
list
<
std
::
shared_ptr
<
Node
>>&
nodes
)
{
for
(
const
std
::
shared_ptr
<
Node
>&
node
:
nodes
)
{
run_on_node
(
node
);
}
return
false
;
}
bool
ngraph
::
pass
::
AssignPlacement
::
run_on_node
(
shared_ptr
<
Node
>
node
)
bool
pass
::
AssignPlacement
::
run_on_node
(
shared_ptr
<
Node
>
node
)
{
node
->
set_placement
(
m_placement_policy
(
node
));
return
false
;
...
...
src/ngraph/pass/assign_placement.hpp
View file @
76047c77
...
...
@@ -27,15 +27,14 @@ namespace ngraph
{
namespace
pass
{
class
AssignPlacement
:
public
CallGraph
Pass
class
AssignPlacement
:
public
Node
Pass
{
public
:
// TODO: make policy a class
AssignPlacement
(
std
::
function
<
Placement
(
std
::
shared_ptr
<
Node
>
)
>
placement_policy
);
virtual
bool
run_on_call_graph
(
const
std
::
list
<
std
::
shared_ptr
<
Node
>>&
nodes
)
override
;
private
:
bool
run_on_node
(
std
::
shared_ptr
<
Node
>
node
);
bool
run_on_node
(
std
::
shared_ptr
<
Node
>
node
)
override
;
std
::
function
<
Placement
(
std
::
shared_ptr
<
Node
>
)
>
m_placement_policy
;
};
}
...
...
src/ngraph/pass/get_output_element_elimination.cpp
View file @
76047c77
...
...
@@ -30,22 +30,19 @@
#include "ngraph/op/sum.hpp"
using
namespace
ngraph
;
using
namespace
std
;
bool
ngraph
::
pass
::
GetOutputElementElimination
::
run_on_function
(
std
::
shared_ptr
<
ngraph
::
Function
>
f
)
bool
pass
::
GetOutputElementElimination
::
run_on_node
(
shared_ptr
<
Node
>
n
)
{
bool
optimized
=
false
;
for
(
auto
n
:
f
->
get_ordered_op
s
())
for
(
auto
&
input
:
n
->
get_input
s
())
{
for
(
auto
&
input
:
n
->
get_inputs
(
))
if
(
auto
goe
=
dynamic_pointer_cast
<
op
::
GetOutputElement
>
(
input
.
get_output
().
get_node
()
))
{
if
(
auto
goe
=
std
::
dynamic_pointer_cast
<
op
::
GetOutputElement
>
(
input
.
get_output
().
get_node
()))
{
auto
multi
=
goe
->
get_inputs
().
at
(
0
).
get_output
().
get_node
();
input
.
replace_output
(
goe
->
get_inputs
().
at
(
goe
->
get_n
()).
get_output
());
//we don't need to fix anything w.r.t GetOutputElement as it will become unreachable
optimized
=
true
;
}
auto
multi
=
goe
->
get_inputs
().
at
(
0
).
get_output
().
get_node
();
input
.
replace_output
(
goe
->
get_inputs
().
at
(
goe
->
get_n
()).
get_output
());
// we don't need to fix anything w.r.t GetOutputElement as it will become unreachable
optimized
=
true
;
}
}
return
optimized
;
...
...
src/ngraph/pass/get_output_element_elimination.hpp
View file @
76047c77
...
...
@@ -26,13 +26,8 @@ namespace ngraph
}
}
class
ngraph
::
pass
::
GetOutputElementElimination
:
public
Function
Pass
class
ngraph
::
pass
::
GetOutputElementElimination
:
public
Node
Pass
{
public
:
GetOutputElementElimination
()
:
FunctionPass
()
{
}
virtual
bool
run_on_function
(
std
::
shared_ptr
<
ngraph
::
Function
>
f
);
bool
run_on_node
(
std
::
shared_ptr
<
Node
>
node
)
override
;
};
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