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
c9eef901
Commit
c9eef901
authored
Dec 11, 2018
by
Nick Korovaiko
Committed by
Scott Cyphers
Dec 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
is_op (#2203)
parent
90aa7336
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
36 additions
and
23 deletions
+36
-23
graph_util.cpp
src/ngraph/graph_util.cpp
+2
-1
node.hpp
src/ngraph/node.hpp
+1
-0
op.hpp
src/ngraph/op/op.hpp
+1
-0
common_function_collection.cpp
src/ngraph/pass/common_function_collection.cpp
+2
-1
memory_layout.cpp
src/ngraph/pass/memory_layout.cpp
+2
-1
propagate_cacheability.cpp
src/ngraph/pass/propagate_cacheability.cpp
+4
-2
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+15
-12
cpu_memory_optimization.cpp
src/ngraph/runtime/cpu/pass/cpu_memory_optimization.cpp
+4
-2
gpu_external_function.cpp
src/ngraph/runtime/gpu/gpu_external_function.cpp
+5
-4
No files found.
src/ngraph/graph_util.cpp
View file @
c9eef901
...
...
@@ -590,8 +590,9 @@ bool ngraph::possibly_overwritten(Node* node)
{
for
(
const
descriptor
::
Input
*
input
:
output
.
get_inputs
())
{
if
(
auto
op
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
input
->
get_node
()
))
if
(
input
->
get_node
()
->
is_op
(
))
{
auto
op
=
std
::
static_pointer_cast
<
ngraph
::
op
::
Op
>
(
input
->
get_node
());
if
(
auto
op_annotations
=
op
->
get_op_annotations
())
{
for
(
auto
oi_pair
:
op_annotations
->
get_in_place_oi_pairs
())
...
...
src/ngraph/node.hpp
View file @
c9eef901
...
...
@@ -140,6 +140,7 @@ namespace ngraph
bool
is_parameter
()
const
;
virtual
bool
is_output
()
const
;
virtual
bool
is_constant
()
const
;
virtual
bool
is_op
()
const
{
return
false
;
}
virtual
bool
is_commutative
()
{
return
false
;
}
size_t
get_instance_id
()
const
{
return
m_instance_id
;
}
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
,
const
Node
&
);
...
...
src/ngraph/op/op.hpp
View file @
c9eef901
...
...
@@ -38,6 +38,7 @@ namespace ngraph
return
m_op_annotations
;
}
virtual
bool
is_op
()
const
override
{
return
true
;
}
protected
:
Op
(
const
std
::
string
&
node_type
,
const
NodeVector
&
arguments
);
...
...
src/ngraph/pass/common_function_collection.cpp
View file @
c9eef901
...
...
@@ -52,8 +52,9 @@ bool pass::CommonFunctionCollection::run_on_module(vector<shared_ptr<Function>>&
{
continue
;
}
if
(
auto
op
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
n
))
if
(
n
->
is_op
(
))
{
auto
op
=
std
::
static_pointer_cast
<
op
::
Op
>
(
n
);
auto
annotations
=
op
->
get_op_annotations
();
// If an op is passed through, do not add it to the common function
// collection so that the emitter can decide to eliminate it if desired
...
...
src/ngraph/pass/memory_layout.cpp
View file @
c9eef901
...
...
@@ -47,8 +47,9 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function)
std
::
map
<
descriptor
::
Tensor
*
,
descriptor
::
Tensor
*>
in_place_outputs
;
std
::
set
<
const
descriptor
::
Tensor
*>
reused_inputs
;
if
(
auto
op
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
node
))
if
(
node
->
is_op
(
))
{
auto
op
=
std
::
static_pointer_cast
<
op
::
Op
>
(
node
);
// concat and slice in_place_oi should be treated differently
if
(
!
std
::
dynamic_pointer_cast
<
op
::
Concat
>
(
node
)
&&
!
std
::
dynamic_pointer_cast
<
op
::
Slice
>
(
node
))
...
...
src/ngraph/pass/propagate_cacheability.cpp
View file @
c9eef901
...
...
@@ -28,8 +28,9 @@ bool ngraph::pass::PropagateCacheability::run_on_function(std::shared_ptr<Functi
{
for
(
auto
&
node
:
function
->
get_ordered_ops
())
{
if
(
auto
op
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
node
))
if
(
node
->
is_op
(
))
{
auto
op
=
std
::
static_pointer_cast
<
op
::
Op
>
(
node
);
NGRAPH_DEBUG
<<
"propagate cacheability: node is "
<<
node
->
get_name
();
auto
op_annotations
=
op
->
get_op_annotations
();
if
(
!
op_annotations
)
...
...
@@ -55,8 +56,9 @@ bool ngraph::pass::PropagateCacheability::run_on_function(std::shared_ptr<Functi
for
(
auto
arg
:
node
->
get_arguments
())
{
NGRAPH_DEBUG
<<
"propagate cacheability: arg is "
<<
arg
->
get_name
();
if
(
a
uto
arg_op
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
arg
))
if
(
a
rg
->
is_op
(
))
{
auto
arg_op
=
std
::
static_pointer_cast
<
op
::
Op
>
(
arg
);
auto
arg_op_annotations
=
arg_op
->
get_op_annotations
();
NGRAPH_ASSERT
(
arg_op_annotations
);
if
(
!
arg_op_annotations
->
is_cacheable
())
...
...
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
c9eef901
...
...
@@ -1135,12 +1135,14 @@ void runtime::cpu::CPU_ExternalFunction::propagate_in_place_input(
stack
.
pop_front
();
for
(
auto
input
:
it
->
get_inputs
())
{
auto
c_op
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
input
->
get_node
());
if
(
!
c_op
||
c_op
->
is_output
()
||
dynamic_pointer_cast
<
ngraph
::
op
::
Slice
>
(
c_op
))
auto
input_node
=
input
->
get_node
();
if
(
!
input_node
->
is_op
()
||
input_node
->
is_output
()
||
dynamic_pointer_cast
<
ngraph
::
op
::
Slice
>
(
input_node
))
{
continue
;
}
auto
c_op
=
std
::
static_pointer_cast
<
ngraph
::
op
::
Op
>
(
input_node
);
if
(
auto
op_annotations
=
c_op
->
get_op_annotations
())
{
for
(
auto
oi_pair
:
op_annotations
->
get_in_place_oi_pairs
())
...
...
@@ -1182,12 +1184,13 @@ void runtime::cpu::CPU_ExternalFunction::propagate_in_place_constant(
stack
.
pop_front
();
for
(
auto
input
:
it
->
get_inputs
())
{
auto
c_op
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
input
->
get_node
()
);
if
(
!
c_op
||
c_op
->
is_output
())
auto
input_node
=
input
->
get_node
(
);
if
(
!
input_node
->
is_op
()
||
input_node
->
is_output
())
{
continue
;
}
auto
c_op
=
std
::
static_pointer_cast
<
ngraph
::
op
::
Op
>
(
input_node
);
if
(
auto
op_annotations
=
c_op
->
get_op_annotations
())
{
for
(
auto
oi_pair
:
op_annotations
->
get_in_place_oi_pairs
())
...
...
@@ -1229,11 +1232,14 @@ void runtime::cpu::CPU_ExternalFunction::propagate_in_place_output(
do
{
propagate_further
=
false
;
auto
arg
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
it
->
get_node
());
if
(
!
arg
||
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Slice
>
(
it
->
get_node
()))
auto
it_node
=
it
->
get_node
();
if
(
!
it_node
->
is_op
()
||
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Slice
>
(
it_node
))
{
break
;
}
auto
arg
=
std
::
static_pointer_cast
<
ngraph
::
op
::
Op
>
(
it_node
);
if
(
auto
op_annotations
=
arg
->
get_op_annotations
())
{
for
(
auto
oi_pair
:
op_annotations
->
get_in_place_oi_pairs
())
...
...
@@ -1284,8 +1290,7 @@ void runtime::cpu::CPU_ExternalFunction::process_in_place_concat(
auto
offset
=
output_tensor
->
get_pool_offset
();
for
(
auto
arg
:
concat
->
get_arguments
())
{
auto
input_node
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
arg
);
auto
input_tensor
=
&
input_node
->
get_output_tensor
();
auto
input_tensor
=
&
arg
->
get_output_tensor
();
auto
old_offset
=
input_tensor
->
get_pool_offset
();
input_tensor
->
set_pool_offset
(
offset
);
NGRAPH_DEBUG
<<
"cpu_external_function: change offset, old offset is "
...
...
@@ -1349,8 +1354,7 @@ void runtime::cpu::CPU_ExternalFunction::propagate_in_place_concat(
auto
offset
=
output_tensor
->
get_pool_offset
();
for
(
auto
arg
:
it
->
get_arguments
())
{
auto
input_node
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
arg
);
auto
input_tensor
=
&
input_node
->
get_output_tensor
();
auto
input_tensor
=
&
arg
->
get_output_tensor
();
auto
old_offset
=
input_tensor
->
get_pool_offset
();
input_tensor
->
set_pool_offset
(
offset
);
NGRAPH_DEBUG
...
...
@@ -1383,8 +1387,7 @@ void runtime::cpu::CPU_ExternalFunction::process_in_place_slice(
auto
input
=
&
slice
->
get_inputs
().
at
(
0
);
auto
arg
=
input
->
get_output
().
get_node
();
auto
index
=
input
->
get_output
().
get_index
();
auto
input_node
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
arg
);
auto
input_tensor
=
&
input_node
->
get_output_tensor
(
index
);
auto
input_tensor
=
&
arg
->
get_output_tensor
(
index
);
if
(
m_tensor_roles
[
input_tensor
->
get_name
()]
==
CPUTensorRole
::
INPUT
)
{
NGRAPH_DEBUG
<<
"cpu_external_function: function input pointer passed to "
...
...
src/ngraph/runtime/cpu/pass/cpu_memory_optimization.cpp
View file @
c9eef901
...
...
@@ -132,8 +132,9 @@ bool runtime::cpu::pass::CPUMemoryOptimization::run_on_function(std::shared_ptr<
if
(
!
std
::
dynamic_pointer_cast
<
op
::
Concat
>
(
arg
))
{
if
(
a
uto
op
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
arg
))
if
(
a
rg
->
is_op
(
))
{
auto
op
=
std
::
static_pointer_cast
<
op
::
Op
>
(
arg
);
auto
annotation
=
op
->
get_op_annotations
();
if
(
annotation
&&
annotation
->
get_in_place_oi_pairs
().
size
()
>
0
)
...
...
@@ -174,8 +175,9 @@ bool runtime::cpu::pass::CPUMemoryOptimization::run_on_function(std::shared_ptr<
{
if
((
user
!=
concat
))
{
if
(
auto
op
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
user
))
if
(
user
->
is_op
(
))
{
auto
op
=
std
::
static_pointer_cast
<
op
::
Op
>
(
user
);
if
(
auto
op_annotations
=
op
->
get_op_annotations
())
{
if
(
op_annotations
->
get_in_place_oi_pairs
().
size
()
>
0
)
...
...
src/ngraph/runtime/gpu/gpu_external_function.cpp
View file @
c9eef901
...
...
@@ -765,12 +765,13 @@ void runtime::gpu::GPU_ExternalFunction::propagate_in_place_input(
stack
.
pop_front
();
for
(
auto
input
:
it
->
get_inputs
())
{
auto
c_op
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
input
->
get_node
()
);
if
(
!
c_op
||
c_op
->
is_output
())
auto
input_node
=
input
->
get_node
(
);
if
(
!
input_node
->
is_op
()
||
input_node
->
is_output
())
{
continue
;
}
auto
c_op
=
std
::
static_pointer_cast
<
ngraph
::
op
::
Op
>
(
input_node
);
if
(
auto
op_annotations
=
c_op
->
get_op_annotations
())
{
for
(
auto
oi_pair
:
op_annotations
->
get_in_place_oi_pairs
())
...
...
@@ -804,11 +805,11 @@ void runtime::gpu::GPU_ExternalFunction::propagate_in_place_output(
do
{
propagate_further
=
false
;
auto
arg
=
std
::
dynamic_pointer_cast
<
ngraph
::
op
::
Op
>
(
it
->
get_node
());
if
(
!
arg
)
if
(
!
it
->
get_node
()
->
is_op
())
{
break
;
}
auto
arg
=
std
::
static_pointer_cast
<
ngraph
::
op
::
Op
>
(
it
->
get_node
());
if
(
auto
op_annotations
=
arg
->
get_op_annotations
())
{
for
(
auto
oi_pair
:
op_annotations
->
get_in_place_oi_pairs
())
...
...
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