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
2b0cd2fd
Commit
2b0cd2fd
authored
Feb 09, 2018
by
Jayaram Bobba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added MKLDNN avg pool backprop kernel
parent
bce27b39
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
12 deletions
+52
-12
cpu_emitter.cpp
src/ngraph/runtime/cpu/cpu_emitter.cpp
+50
-11
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 @
2b0cd2fd
...
...
@@ -91,7 +91,7 @@ static const string& get_mkldnn_data_type(const string& type)
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMKLDNNPreamble
(
codegen
::
CodeWriter
&
writer
)
{
writer
<<
"// MKLDNN Preamble
\n
"
;
writer
<<
"#include <mkldnn.hpp>
;
\n
"
;
writer
<<
"#include <mkldnn.hpp>
\n
"
;
writer
<<
"using namespace mkldnn;
\n\n
"
;
}
...
...
@@ -2370,18 +2370,57 @@ 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
();
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
<<
"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
"
;
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 @
2b0cd2fd
...
...
@@ -239,7 +239,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