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
a87ee09e
Commit
a87ee09e
authored
Oct 15, 2018
by
amy.zhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No in place concat immediately after non-concat in place ops.
parent
6ca1a511
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
15 deletions
+42
-15
memory_layout.cpp
src/ngraph/pass/memory_layout.cpp
+18
-15
cpu_memory_optimization.cpp
src/ngraph/runtime/cpu/pass/cpu_memory_optimization.cpp
+24
-0
No files found.
src/ngraph/pass/memory_layout.cpp
View file @
a87ee09e
...
@@ -74,24 +74,27 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function)
...
@@ -74,24 +74,27 @@ bool pass::MemoryLayout::run_on_function(shared_ptr<ngraph::Function> function)
?
in_place_outputs
.
at
(
tensor
)
->
get_pool_offset
()
?
in_place_outputs
.
at
(
tensor
)
->
get_pool_offset
()
:
mm
.
allocate
(
tensor
->
size
());
:
mm
.
allocate
(
tensor
->
size
());
tensor
->
set_pool_offset
(
offset
);
tensor
->
set_pool_offset
(
offset
);
// check if the op is concat
}
if
(
auto
concat
=
std
::
dynamic_pointer_cast
<
op
::
Concat
>
(
node
))
// check if the op is concat
if
(
auto
concat
=
std
::
dynamic_pointer_cast
<
op
::
Concat
>
(
node
))
{
if
(
auto
op_annotations
=
concat
->
get_op_annotations
())
{
{
if
(
auto
op_annotations
=
concat
->
get_op_annotations
())
auto
in_place_oi_pairs
=
op_annotations
->
get_in_place_oi_pairs
();
if
(
in_place_oi_pairs
.
size
()
>
0
)
{
{
auto
in_place_oi_pairs
=
op_annotations
->
get_in_place_oi_pairs
();
auto
output_tensor
=
&
concat
->
get_output_tensor
();
if
(
in_place_oi_pairs
.
size
()
>
0
)
auto
offset
=
output_tensor
->
get_pool_offset
();
for
(
auto
arg
:
concat
->
get_arguments
())
{
{
for
(
auto
arg
:
concat
->
get_arguments
())
auto
input_node
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
arg
);
{
auto
input_tensor
=
&
input_node
->
get_output_tensor
();
auto
input_node
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
arg
);
auto
old_offset
=
input_tensor
->
get_pool_offset
();
auto
input_tensor
=
&
input_node
->
get_output_tensor
();
input_tensor
->
set_pool_offset
(
offset
);
auto
old_offset
=
input_tensor
->
get_pool_offset
();
NGRAPH_DEBUG
<<
"memeory_layout: change offset, old offset is "
input_tensor
->
set_pool_offset
(
offset
);
<<
old_offset
<<
", new offset is "
<<
offset
<<
std
::
endl
;
NGRAPH_DEBUG
<<
"memeory_layout: change offset, old offset is "
offset
+=
input_tensor
->
size
();
<<
old_offset
<<
", new offset is "
<<
offset
<<
std
::
endl
;
offset
+=
input_tensor
->
size
();
}
}
}
}
}
}
}
...
...
src/ngraph/runtime/cpu/pass/cpu_memory_optimization.cpp
View file @
a87ee09e
...
@@ -66,6 +66,30 @@ bool runtime::cpu::pass::CPUMemoryOptimization::run_on_function(std::shared_ptr<
...
@@ -66,6 +66,30 @@ bool runtime::cpu::pass::CPUMemoryOptimization::run_on_function(std::shared_ptr<
break
;
break
;
}
}
if
(
arg
->
get_output_size
()
!=
1
)
{
NGRAPH_DEBUG
<<
"cpu_post_layout_assignment: "
<<
arg
->
get_name
()
<<
": multiple outputs, no in place concat"
;
in_place_concat
=
false
;
break
;
}
if
(
!
std
::
dynamic_pointer_cast
<
op
::
Concat
>
(
arg
))
{
if
(
auto
op
=
std
::
dynamic_pointer_cast
<
op
::
Op
>
(
arg
))
{
auto
annotation
=
op
->
get_op_annotations
();
if
(
annotation
&&
annotation
->
get_in_place_oi_pairs
().
size
()
>
0
)
{
NGRAPH_DEBUG
<<
"cpu_post_layout_assignment: "
<<
arg
->
get_name
()
<<
": in place non concat op, no in place concat"
;
in_place_concat
=
false
;
break
;
}
}
}
if
(
output
.
get_inputs
().
size
()
!=
1
)
if
(
output
.
get_inputs
().
size
()
!=
1
)
{
{
// check if we can do in place concat
// check if we can do in place concat
...
...
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