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
9c395596
Commit
9c395596
authored
Mar 01, 2018
by
Louis Feng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed previous merge errors.
parent
4e9dae99
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
17 deletions
+64
-17
mkldnn_emitter.cpp
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
+63
-17
mkldnn_emitter.hpp
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
+1
-0
No files found.
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
View file @
9c395596
...
...
@@ -87,26 +87,31 @@ size_t MKLDNNEmitter::build_convolution_forward(const mkldnn::memory::desc& inpu
size_t
result_index
=
build_memory_primitive
(
result_desc
);
size_t
conv_index
=
insert_primitive
(
new
mkldnn
::
convolution_forward
(
{{
mkldnn
::
prop_kind
::
forward
,
mkldnn
::
algorithm
::
convolution_direct
,
input_data_desc
,
weights_desc
,
result_desc
,
mkldnn
::
memory
::
dims
(
strides
.
begin
(),
strides
.
end
()),
mkldnn
::
memory
::
dims
(
dilation_strides
.
begin
(),
dilation_strides
.
end
()),
mkldnn
::
memory
::
dims
(
padding_below
.
begin
(),
padding_below
.
end
()),
mkldnn
::
memory
::
dims
(
padding_above
.
begin
(),
padding_above
.
end
()),
mkldnn
::
padding_kind
::
zero
},
mkldnn_utils
::
global_cpu_engine
},
*
mkldnn_primitives
[
input_data_index
],
*
mkldnn_primitives
[
weights_index
],
*
mkldnn_primitives
[
result_index
]));
{{
mkldnn
::
prop_kind
::
forward
,
mkldnn
::
algorithm
::
convolution_direct
,
input_data_desc
,
weights_desc
,
result_desc
,
mkldnn
::
memory
::
dims
(
strides
.
begin
(),
strides
.
end
()),
mkldnn
::
memory
::
dims
(
dilation_strides
.
begin
(),
dilation_strides
.
end
()),
mkldnn
::
memory
::
dims
(
padding_below
.
begin
(),
padding_below
.
end
()),
mkldnn
::
memory
::
dims
(
padding_above
.
begin
(),
padding_above
.
end
()),
mkldnn
::
padding_kind
::
zero
},
mkldnn_utils
::
global_cpu_engine
},
*
mkldnn_primitives
[
input_data_index
],
*
mkldnn_primitives
[
weights_index
],
*
mkldnn_primitives
[
result_index
]));
primitive_deps
[
conv_index
]
=
{
input_data_index
,
weights_index
,
result_index
};
return
conv_index
;
}
size_t
MKLDNNEmitter
::
build_convolution_forward
(
const
mkldnn
::
memory
::
desc
&
input_data_desc
,
const
mkldnn
::
memory
::
desc
&
weights_desc
,
const
mkldnn
::
memory
::
desc
&
bias_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
)
...
...
@@ -116,6 +121,7 @@ size_t MKLDNNEmitter::build_convolution_forward(const mkldnn::memory::desc& inpu
const
size_t
bias_index
=
build_memory_primitive
(
bias_desc
);
const
size_t
result_index
=
build_memory_primitive
(
result_desc
);
const
size_t
conv_index
=
insert_primitive
(
new
mkldnn
::
convolution_forward
(
{{
mkldnn
::
prop_kind
::
forward
,
mkldnn
::
algorithm
::
convolution_direct
,
input_data_desc
,
...
...
@@ -147,6 +153,9 @@ size_t MKLDNNEmitter::build_convolution_backward_data(const mkldnn::memory::desc
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
());
...
...
@@ -176,13 +185,18 @@ size_t MKLDNNEmitter::build_convolution_backward_data(const mkldnn::memory::desc
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
,
...
...
@@ -193,6 +207,7 @@ size_t MKLDNNEmitter::build_convolution_backward_filters_bias(const mkldnn::memo
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
());
...
...
@@ -225,6 +240,38 @@ size_t MKLDNNEmitter::build_convolution_backward_filters_bias(const mkldnn::memo
const
size_t
conv_index
=
insert_primitive
(
new
mkldnn
::
convolution_backward_weights
(
bwd_pd
,
*
mkldnn_primitives
[
in_data_index
],
*
mkldnn_primitives
[
out_bias_delta_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
size_t
MKLDNNEmitter
::
build_elementwise_add
(
const
mkldnn
::
memory
::
desc
&
input0_data_desc
,
const
mkldnn
::
memory
::
desc
&
input1_data_desc
,
const
mkldnn
::
memory
::
desc
&
result_desc
,
const
std
::
vector
<
float
>&
scale_vector
,
const
std
::
vector
<
mkldnn
::
memory
::
primitive_desc
>&
inputs_pd
)
{
std
::
vector
<
mkldnn
::
memory
::
primitive
::
at
>
inputs_primitive
;
size_t
input0_data_index
=
build_memory_primitive
(
input0_data_desc
);
size_t
input1_data_index
=
build_memory_primitive
(
input1_data_desc
);
size_t
result_index
=
build_memory_primitive
(
result_desc
);
inputs_primitive
.
push_back
(
*
mkldnn_primitives
[
input0_data_index
]);
inputs_primitive
.
push_back
(
*
mkldnn_primitives
[
input1_data_index
]);
// elementwise sum primtive descriptor
mkldnn
::
sum
::
primitive_desc
sum_pd
=
mkldnn
::
sum
::
primitive_desc
(
result_desc
,
scale_vector
,
inputs_pd
);
// sum primitive
size_t
add_index
=
insert_primitive
(
new
mkldnn
::
sum
(
sum_pd
,
inputs_primitive
,
*
mkldnn_primitives
[
result_index
]));
primitive_deps
[
add_index
]
=
{
input0_data_index
,
input1_data_index
,
result_index
};
return
add_index
;
}
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
View file @
9c395596
...
...
@@ -101,6 +101,7 @@ namespace ngraph
const
mkldnn
::
memory
::
desc
&
result_desc
,
const
std
::
vector
<
float
>&
scale_vector
,
const
std
::
vector
<
mkldnn
::
memory
::
primitive_desc
>&
input_pd
);
private
:
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
;
std
::
vector
<
mkldnn
::
primitive
*>
mkldnn_primitives
;
...
...
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