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
85a17aeb
Unverified
Commit
85a17aeb
authored
Feb 09, 2018
by
Jayaram Bobba
Committed by
GitHub
Feb 09, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #476 from NervanaSystems/jbobba/gradpool_PR
MKLDNN Avg Pool Backprop kernel
parents
da50410b
ff364beb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
11 deletions
+54
-11
cpu_emitter.cpp
src/ngraph/runtime/cpu/cpu_emitter.cpp
+52
-10
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+2
-1
No files found.
src/ngraph/runtime/cpu/cpu_emitter.cpp
View file @
85a17aeb
...
...
@@ -2372,18 +2372,60 @@ void runtime::cpu::CPU_Emitter::EmitAvgPoolBackprop(
auto
apb
=
static_cast
<
const
op
::
AvgPoolBackprop
*>
(
n
);
auto
delta_shape
=
args
[
0
].
get_shape
();
auto
delta_rank
=
delta_shape
.
size
();
auto
out_shape
=
out
[
0
].
get_shape
();
writer
<<
"kernel::avg_pool_backprop<"
<<
out
[
0
].
get_type
()
<<
">("
<<
args
[
0
].
get_name
()
<<
",
\n
"
;
writer
<<
" "
<<
out
[
0
].
get_name
()
<<
",
\n
"
;
writer
<<
" {"
<<
join
(
delta_shape
)
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
out_shape
)
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_window_shape
())
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_window_movement_strides
())
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_padding_below
())
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_padding_above
())
<<
"}
\n
"
;
writer
<<
" );
\n
"
;
if
(
delta_rank
==
4
&&
apb
->
get_window_shape
().
size
()
==
2
&&
args
[
0
].
get_element_type
()
==
element
::
f32
)
{
const
string
&
et
=
get_mkldnn_data_type
(
args
[
0
].
get_element_type
().
c_type_string
());
writer
<<
"{
\n
"
;
writer
.
indent
++
;
writer
<<
"engine cpu_engine = engine(engine::cpu, 0);
\n
"
;
writer
<<
"memory::desc input_data_desc = memory::desc({"
<<
join
(
delta_shape
)
<<
"}, "
<<
et
<<
", memory::format::nchw);
\n
"
;
writer
<<
"memory::desc result_desc = memory::desc({"
<<
join
(
out_shape
)
<<
"}, "
<<
et
<<
", memory::format::nchw);
\n
"
;
writer
<<
"memory input_data = memory({input_data_desc, cpu_engine}, "
<<
args
[
0
].
get_name
()
<<
");
\n
"
;
writer
<<
"memory result = memory({result_desc, cpu_engine}, "
<<
out
[
0
].
get_name
()
<<
");
\n
"
;
// Dummy forward primitive descriptor to keep MKLDNN happy
writer
<<
"pooling_forward::primitive_desc fwd_pd = pooling_forward::primitive_desc("
<<
"{prop_kind::forward, algorithm::pooling_avg_exclude_padding, "
<<
"result_desc, input_data_desc, {"
<<
join
(
apb
->
get_window_movement_strides
())
<<
"}, {"
<<
join
(
apb
->
get_window_shape
())
<<
"}, "
<<
"{"
<<
join
(
apb
->
get_padding_below
())
<<
"}, "
<<
"{"
<<
join
(
apb
->
get_padding_above
())
<<
"}, "
<<
"padding_kind::zero}, cpu_engine);
\n
"
;
writer
<<
"auto avg_pooling = pooling_backward(pooling_backward::primitive_desc("
<<
"pooling_backward::desc(algorithm::pooling_avg_exclude_padding, "
<<
"result_desc, input_data_desc, {"
<<
join
(
apb
->
get_window_movement_strides
())
<<
"}, {"
<<
join
(
apb
->
get_window_shape
())
<<
"}, "
<<
"{"
<<
join
(
apb
->
get_padding_below
())
<<
"}, "
<<
"{"
<<
join
(
apb
->
get_padding_above
())
<<
"}, "
<<
"padding_kind::zero), cpu_engine, fwd_pd), "
<<
"input_data, result);
\n
"
;
writer
<<
"auto s = stream(stream::kind::eager);
\n
"
<<
"s.submit({avg_pooling}).wait();
\n
"
;
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
else
{
writer
<<
"kernel::avg_pool_backprop<"
<<
out
[
0
].
get_type
()
<<
">("
<<
args
[
0
].
get_name
()
<<
",
\n
"
;
writer
<<
" "
<<
out
[
0
].
get_name
()
<<
",
\n
"
;
writer
<<
" {"
<<
join
(
delta_shape
)
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
out_shape
)
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_window_shape
())
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_window_movement_strides
())
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_padding_below
())
<<
"},
\n
"
;
writer
<<
" {"
<<
join
(
apb
->
get_padding_above
())
<<
"}
\n
"
;
writer
<<
" );
\n
"
;
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMaxPoolBackprop
(
...
...
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
85a17aeb
...
...
@@ -241,7 +241,8 @@ void runtime::cpu::CPU_ExternalFunction::compile()
for
(
shared_ptr
<
Node
>
node
:
current_function
->
get_ordered_ops
())
{
if
(
dynamic_cast
<
op
::
Convolution
*>
(
node
.
get
())
||
dynamic_cast
<
op
::
AvgPool
*>
(
node
.
get
())
||
dynamic_cast
<
op
::
MaxPool
*>
(
node
.
get
()))
dynamic_cast
<
op
::
AvgPool
*>
(
node
.
get
())
||
dynamic_cast
<
op
::
MaxPool
*>
(
node
.
get
())
||
dynamic_cast
<
op
::
AvgPoolBackprop
*>
(
node
.
get
()))
{
include_mkldnn_headers
=
true
;
}
...
...
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