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
4893411b
Commit
4893411b
authored
Mar 01, 2018
by
Louis Feng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added conv+bias backprop mkldnn and op.
parent
dc4acb4e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
138 additions
and
0 deletions
+138
-0
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+7
-0
mkldnn_emitter.cpp
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
+106
-0
mkldnn_emitter.hpp
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
+25
-0
conv_bias.cpp
src/ngraph/runtime/cpu/ops/conv_bias.cpp
+0
-0
conv_bias.hpp
src/ngraph/runtime/cpu/ops/conv_bias.hpp
+0
-0
No files found.
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
4893411b
...
...
@@ -104,6 +104,7 @@
#include "ngraph/runtime/cpu/cpu_tensor_view.hpp"
#include "ngraph/runtime/cpu/cpu_tracing.hpp"
#include "ngraph/runtime/cpu/mkldnn_utils.hpp"
#include "ngraph/runtime/cpu/ops/conv_bias.hpp"
#include "ngraph/runtime/cpu/ops/matmul_bias.hpp"
#include "ngraph/runtime/cpu/pass/cpu_fusion.hpp"
#include "ngraph/runtime/cpu/pass/cpu_layout.hpp"
...
...
@@ -216,6 +217,12 @@ static const runtime::cpu::OpMap dispatcher{
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
ConvolutionBackpropFilters
>
},
{
TI
(
ngraph
::
op
::
ConvolutionBackpropData
),
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
ConvolutionBackpropData
>
},
{
TI
(
ngraph
::
op
::
ConvolutionBias
),
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
ConvolutionBias
>
},
{
TI
(
ngraph
::
op
::
ConvolutionBiasBackpropFiltersBias
),
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
ConvolutionBiasBackpropFiltersBias
>
},
// conv+bias backprop for data share the same implementation as conv backprop data
{
TI
(
ngraph
::
op
::
ConvolutionBiasBackpropData
),
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
ConvolutionBackpropData
>
},
{
TI
(
ngraph
::
op
::
Not
),
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
Not
>
},
{
TI
(
ngraph
::
op
::
MaxPool
),
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
MaxPool
>
},
{
TI
(
ngraph
::
op
::
Reverse
),
&
runtime
::
cpu
::
CPU_Emitter
::
emit
<
op
::
Reverse
>
},
...
...
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
View file @
4893411b
...
...
@@ -141,3 +141,108 @@ size_t MKLDNNEmitter::build_convolution_forward(const mkldnn::memory::desc& inpu
primitive_deps
[
conv_index
]
=
{
input_data_index
,
weights_index
,
bias_index
,
result_index
};
return
conv_index
;
}
size_t
MKLDNNEmitter
::
build_convolution_backward_data
(
const
mkldnn
::
memory
::
desc
&
in_weights_desc
,
const
mkldnn
::
memory
::
desc
&
in_delta_desc
,
const
mkldnn
::
memory
::
desc
&
out_data_delta_desc
,
const
ngraph
::
Strides
&
ng_strides
,
const
ngraph
::
Strides
&
ng_dilation_strides
,
const
ngraph
::
CoordinateDiff
&
ng_padding_below
,
const
ngraph
::
CoordinateDiff
&
ng_padding_above
)
{
const
size_t
in_weights_index
=
build_memory_primitive
(
in_weights_desc
);
const
size_t
in_delta_index
=
build_memory_primitive
(
in_delta_desc
);
const
size_t
out_data_delta_index
=
build_memory_primitive
(
out_data_delta_desc
);
mkldnn
::
memory
::
dims
strides
(
ng_strides
.
begin
(),
ng_strides
.
end
());
mkldnn
::
memory
::
dims
dilation
(
ng_dilation_strides
.
begin
(),
ng_dilation_strides
.
end
());
mkldnn
::
memory
::
dims
padding_l
(
ng_padding_below
.
begin
(),
ng_padding_below
.
end
());
mkldnn
::
memory
::
dims
padding_r
(
ng_padding_above
.
begin
(),
ng_padding_above
.
end
());
mkldnn
::
convolution_forward
::
primitive_desc
fwd_pd
{{
mkldnn
::
prop_kind
::
forward
,
mkldnn
::
algorithm
::
convolution_direct
,
out_data_delta_desc
,
in_weights_desc
,
in_delta_desc
,
strides
,
dilation
,
padding_l
,
padding_r
,
mkldnn
::
padding_kind
::
zero
},
mkldnn_utils
::
global_cpu_engine
};
mkldnn
::
convolution_backward_data
::
primitive_desc
bwd_pd
{{
mkldnn
::
algorithm
::
convolution_direct
,
out_data_delta_desc
,
in_weights_desc
,
in_delta_desc
,
strides
,
dilation
,
padding_l
,
padding_r
,
mkldnn
::
padding_kind
::
zero
},
mkldnn_utils
::
global_cpu_engine
,
fwd_pd
};
const
size_t
conv_index
=
insert_primitive
(
new
mkldnn
::
convolution_backward_data
(
bwd_pd
,
*
mkldnn_primitives
[
in_delta_index
],
*
mkldnn_primitives
[
in_weights_index
],
*
mkldnn_primitives
[
out_data_delta_index
]));
primitive_deps
[
conv_index
]
=
{
in_weights_index
,
in_delta_index
,
out_data_delta_index
};
return
conv_index
;
}
size_t
MKLDNNEmitter
::
build_convolution_backward_filters_bias
(
const
mkldnn
::
memory
::
desc
&
in_data_desc
,
const
mkldnn
::
memory
::
desc
&
in_delta_desc
,
const
mkldnn
::
memory
::
desc
&
out_weights_delta_desc
,
const
mkldnn
::
memory
::
desc
&
out_bias_delta_desc
,
const
ngraph
::
Strides
&
ng_strides
,
const
ngraph
::
Strides
&
ng_dilation_strides
,
const
ngraph
::
CoordinateDiff
&
ng_padding_below
,
const
ngraph
::
CoordinateDiff
&
ng_padding_above
)
{
const
size_t
in_data_index
=
build_memory_primitive
(
in_data_desc
);
const
size_t
in_delta_index
=
build_memory_primitive
(
in_delta_desc
);
const
size_t
out_weights_delta_index
=
build_memory_primitive
(
out_weights_delta_desc
);
const
size_t
out_bias_delta_index
=
build_memory_primitive
(
out_bias_delta_desc
);
mkldnn
::
memory
::
dims
strides
(
ng_strides
.
begin
(),
ng_strides
.
end
());
mkldnn
::
memory
::
dims
dilation
(
ng_dilation_strides
.
begin
(),
ng_dilation_strides
.
end
());
mkldnn
::
memory
::
dims
padding_l
(
ng_padding_below
.
begin
(),
ng_padding_below
.
end
());
mkldnn
::
memory
::
dims
padding_r
(
ng_padding_above
.
begin
(),
ng_padding_above
.
end
());
mkldnn
::
convolution_forward
::
primitive_desc
fwd_pd
{{
mkldnn
::
prop_kind
::
forward
,
mkldnn
::
algorithm
::
convolution_direct
,
in_data_desc
,
out_weights_delta_desc
,
out_bias_delta_desc
,
in_delta_desc
,
strides
,
dilation
,
padding_l
,
padding_r
,
mkldnn
::
padding_kind
::
zero
},
mkldnn_utils
::
global_cpu_engine
};
mkldnn
::
convolution_backward_weights
::
primitive_desc
bwd_pd
{{
mkldnn
::
algorithm
::
convolution_direct
,
in_data_desc
,
out_weights_delta_desc
,
out_bias_delta_desc
,
in_delta_desc
,
strides
,
dilation
,
padding_l
,
padding_r
,
mkldnn
::
padding_kind
::
zero
},
mkldnn_utils
::
global_cpu_engine
,
fwd_pd
};
const
size_t
conv_index
=
insert_primitive
(
new
mkldnn
::
convolution_backward_weights
(
bwd_pd
,
*
mkldnn_primitives
[
in_data_index
],
*
mkldnn_primitives
[
in_delta_index
],
*
mkldnn_primitives
[
out_weights_delta_index
],
*
mkldnn_primitives
[
out_bias_delta_index
]);
primitive_deps
[
conv_index
]
=
{
in_data_index
,
in_delta_index
,
out_weights_delta_index
,
out_bias_delta_index
};
return
conv_index
;
}
\ No newline at end of file
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
View file @
4893411b
...
...
@@ -61,6 +61,9 @@ namespace ngraph
const
ngraph
::
CoordinateDiff
&
padding_below
,
const
ngraph
::
CoordinateDiff
&
padding_above
);
/**
* Convolution + bias forward
*/
size_t
build_convolution_forward
(
const
mkldnn
::
memory
::
desc
&
input_data_desc
,
const
mkldnn
::
memory
::
desc
&
weights_desc
,
const
mkldnn
::
memory
::
desc
&
bias_desc
,
...
...
@@ -69,6 +72,28 @@ namespace ngraph
const
ngraph
::
Strides
&
dilation_strides
,
const
ngraph
::
CoordinateDiff
&
padding_below
,
const
ngraph
::
CoordinateDiff
&
padding_above
);
/**
* Convolution backprop for data
*/
size_t
build_convolution_backward_data
(
const
mkldnn
::
memory
::
desc
&
in_weights_desc
,
const
mkldnn
::
memory
::
desc
&
in_delta_desc
,
const
mkldnn
::
memory
::
desc
&
out_data_delta_desc
,
const
ngraph
::
Strides
&
ng_strides
,
const
ngraph
::
Strides
&
ng_dilation_strides
,
const
ngraph
::
CoordinateDiff
&
ng_padding_below
,
const
ngraph
::
CoordinateDiff
&
ng_padding_above
);
/**
* Convolution + bias backprop for filters and bias
*/
size_t
build_convolution_backward_filters_bias
(
const
mkldnn
::
memory
::
desc
&
input_data_desc
,
const
mkldnn
::
memory
::
desc
&
weights_desc
,
const
mkldnn
::
memory
::
desc
&
out_weights_delta_desc
,
const
mkldnn
::
memory
::
desc
&
result_desc
,
const
ngraph
::
Strides
&
strides
,
const
ngraph
::
Strides
&
dilation_strides
,
const
ngraph
::
CoordinateDiff
&
padding_below
,
const
ngraph
::
CoordinateDiff
&
padding_above
);
private
:
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
;
std
::
vector
<
mkldnn
::
primitive
*>
mkldnn_primitives
;
...
...
src/ngraph/runtime/cpu/ops/conv_bias.cpp
View file @
4893411b
This diff is collapsed.
Click to expand it.
src/ngraph/runtime/cpu/ops/conv_bias.hpp
View file @
4893411b
This diff is collapsed.
Click to expand it.
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