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
8578694b
Commit
8578694b
authored
Feb 26, 2018
by
pthoreho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
style fix
parent
f9191dd9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
32 deletions
+38
-32
cpu_emitter.cpp
src/ngraph/runtime/cpu/cpu_emitter.cpp
+22
-19
mkldnn_emitter.cpp
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
+10
-7
mkldnn_emitter.hpp
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
+6
-5
cpu_assignment.cpp
src/ngraph/runtime/cpu/pass/cpu_assignment.cpp
+0
-1
No files found.
src/ngraph/runtime/cpu/cpu_emitter.cpp
View file @
8578694b
...
...
@@ -150,34 +150,37 @@ namespace ngraph
<<
args
[
1
].
get_name
()
<<
");
\n
"
;
writer
<<
"out = arg0 + arg1;
\n
"
;
#else
if
(
runtime
::
cpu
::
mkldnn_utils
::
use_mkldnn_kernel
(
node
))
{
// get input element type
const
string
&
et
=
runtime
::
cpu
::
mkldnn_utils
::
get_mkldnn_data_type_string
(
args
[
1
].
get_element_type
());
std
::
vector
<
float
>
scale_vector
(
2
,
1
);
std
::
vector
<
float
>
scale_vector
(
2
,
1
);
std
::
vector
<
mkldnn
::
memory
::
primitive_desc
>
inputs_pd
;
auto
input0_format
=
runtime
::
cpu
::
mkldnn_utils
::
get_input_mkldnn_format
(
node
,
0
);
auto
input1_format
=
runtime
::
cpu
::
mkldnn_utils
::
get_input_mkldnn_format
(
node
,
1
);
auto
result_format
=
runtime
::
cpu
::
mkldnn_utils
::
get_output_mkldnn_format
(
node
,
0
);
auto
input0_format
=
runtime
::
cpu
::
mkldnn_utils
::
get_input_mkldnn_format
(
node
,
0
);
auto
input1_format
=
runtime
::
cpu
::
mkldnn_utils
::
get_input_mkldnn_format
(
node
,
1
);
auto
result_format
=
runtime
::
cpu
::
mkldnn_utils
::
get_output_mkldnn_format
(
node
,
0
);
auto
&
mkldnn_emitter
=
external_function
->
get_mkldnn_emitter
();
auto
input0_data_desc
=
mkldnn_emitter
->
build_memory_descriptor
(
args
[
0
],
input0_format
);
auto
input1_data_desc
=
mkldnn_emitter
->
build_memory_descriptor
(
args
[
1
],
input1
_format
);
auto
result_desc
=
mkldnn_emitter
->
build_memory_descriptor
(
out
[
0
],
result_format
);
inputs_pd
.
push_back
(
mkldnn
::
memory
::
primitive_desc
(
input0_data_desc
,
runtime
::
cpu
::
mkldnn_utils
::
global_cpu_engine
));
inputs_pd
.
push_back
(
mkldnn
::
memory
::
primitive_desc
(
input1_data_desc
,
runtime
::
cpu
::
mkldnn_utils
::
global_cpu_engine
));
size_t
add_index
=
0
;
add_index
=
mkldnn_emitter
->
build_elementwise_add
(
input0_data_desc
,
input1_data_desc
,
result_desc
,
scale_vector
,
inputs_pd
);
auto
input0_data_desc
=
mkldnn_emitter
->
build_memory_descriptor
(
args
[
0
],
input0
_format
);
auto
input1_data_desc
=
mkldnn_emitter
->
build_memory_descriptor
(
args
[
1
],
input1_format
);
auto
result_desc
=
mkldnn_emitter
->
build_memory_descriptor
(
out
[
0
],
result_format
);
inputs_pd
.
push_back
(
mkldnn
::
memory
::
primitive_desc
(
input0_data_desc
,
runtime
::
cpu
::
mkldnn_utils
::
global_cpu_engine
));
inputs_pd
.
push_back
(
mkldnn
::
memory
::
primitive_desc
(
input1_data_desc
,
runtime
::
cpu
::
mkldnn_utils
::
global_cpu_engine
));
size_t
add_index
=
0
;
add_index
=
mkldnn_emitter
->
build_elementwise_add
(
input0_data_desc
,
input1_data_desc
,
result_desc
,
scale_vector
,
inputs_pd
);
auto
&
deps
=
mkldnn_emitter
->
get_primitive_deps
(
add_index
);
writer
<<
"cpu::mkldnn_utils::set_memory_ptr(ctx, "
<<
to_string
(
deps
[
0
])
<<
", "
<<
args
[
0
].
get_name
()
<<
");
\n
"
;
...
...
src/ngraph/runtime/cpu/mkldnn_emitter.cpp
View file @
8578694b
...
...
@@ -137,11 +137,12 @@ size_t MKLDNNEmitter::build_convolution_forward(const mkldnn::memory::desc& inpu
return
conv_index
;
}
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
)
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
;
...
...
@@ -154,9 +155,11 @@ size_t MKLDNNEmitter::build_elementwise_add(const mkldnn::memory::desc& input0_d
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
);
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
]));
size_t
add_index
=
insert_primitive
(
new
mkldnn
::
sum
(
sum_pd
,
inputs_primitive
,
*
mkldnn_primitives
[
result_index
]));
primitive_deps
[
add_index
]
=
{
input1_data_index
,
input0_data_index
,
result_index
};
return
add_index
;
...
...
src/ngraph/runtime/cpu/mkldnn_emitter.hpp
View file @
8578694b
...
...
@@ -68,11 +68,12 @@ namespace ngraph
const
ngraph
::
CoordinateDiff
&
padding_below
,
const
ngraph
::
CoordinateDiff
&
padding_above
);
size_t
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
>&
input_pd
);
size_t
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
>&
input_pd
);
private
:
std
::
shared_ptr
<
CPU_ExternalFunction
>
external_function
;
...
...
src/ngraph/runtime/cpu/pass/cpu_assignment.cpp
View file @
8578694b
...
...
@@ -43,7 +43,6 @@ namespace ngraph
{
namespace
pass
{
template
<>
void
CPUAssignment
::
ASSIGN_DECL
(
ngraph
::
op
::
Add
)
{
...
...
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