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
62342c4e
Unverified
Commit
62342c4e
authored
Feb 14, 2018
by
Jai Menon
Committed by
GitHub
Feb 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CPU: Restore use of the single-specification helper macro EMITTER_DECL (#495)
in emitter function definitions
parent
7cf242d3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
167 additions
and
351 deletions
+167
-351
cpu_emitter.cpp
src/ngraph/runtime/cpu/cpu_emitter.cpp
+160
-346
cpu_emitter.hpp
src/ngraph/runtime/cpu/cpu_emitter.hpp
+3
-2
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+2
-2
cpu_external_function.hpp
src/ngraph/runtime/cpu/cpu_external_function.hpp
+2
-1
No files found.
src/ngraph/runtime/cpu/cpu_emitter.cpp
View file @
62342c4e
...
...
@@ -97,21 +97,15 @@ void runtime::cpu::CPU_Emitter::EmitMKLDNNPreamble(codegen::CodeWriter& writer)
writer
<<
"using namespace mkldnn;
\n\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitNop
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitNop
)
{
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitAdd
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitAdd
)
{
// TODO: Audit all uses of Add and fix this to use
// the right alignment instead of Eigen::Unaligned
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
"Eigen::Map<Eigen::Array<"
<<
out
[
0
].
get_element_type
().
c_type_string
()
<<
", "
...
...
@@ -137,10 +131,7 @@ void runtime::cpu::CPU_Emitter::EmitAdd(codegen::CodeWriter& writer,
//a) emitting customized code for initializing output/bias
//b) emitting two cblas calls (one for gemm on W and x and the second for gemm on Bias and E^T + the result of the first gemm)
//@jbobba suggests b) is more efficient but we should benchmark both
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMatmulBias
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
node
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitMatmulBias
)
{
const
ngraph
::
op
::
MatmulBias
*
cg
=
static_cast
<
const
ngraph
::
op
::
MatmulBias
*>
(
node
);
...
...
@@ -189,12 +180,9 @@ void runtime::cpu::CPU_Emitter::EmitMatmulBias(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitDot
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitDot
)
{
const
ngraph
::
op
::
Dot
*
dot
=
static_cast
<
const
ngraph
::
op
::
Dot
*>
(
n
);
const
ngraph
::
op
::
Dot
*
dot
=
static_cast
<
const
ngraph
::
op
::
Dot
*>
(
n
ode
);
const
Shape
&
arg0_shape
=
args
[
0
].
get_shape
();
const
Shape
&
arg1_shape
=
args
[
1
].
get_shape
();
...
...
@@ -203,7 +191,7 @@ void runtime::cpu::CPU_Emitter::EmitDot(codegen::CodeWriter& writer,
auto
&
first
=
(
arg0_shape
.
empty
()
?
args
[
0
]
:
args
[
1
]);
auto
&
second
=
(
arg0_shape
.
empty
()
?
args
[
1
]
:
args
[
0
]);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
])
<<
"
\n
= "
;
writer
<<
first
.
get_name
()
<<
"[0]
\n
* "
<<
emit_vector
(
second
)
<<
";
\n
"
;
...
...
@@ -213,7 +201,7 @@ void runtime::cpu::CPU_Emitter::EmitDot(codegen::CodeWriter& writer,
else
if
((
arg0_shape
.
size
()
==
1
)
&&
(
arg1_shape
.
size
()
==
1
)
&&
dot
->
get_reduction_axes_count
()
==
1
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
])
<<
" <<
\n
"
<<
" "
<<
emit_vector
(
args
[
0
])
<<
".dot("
<<
emit_vector
(
args
[
1
])
<<
");
\n
"
;
...
...
@@ -223,7 +211,7 @@ void runtime::cpu::CPU_Emitter::EmitDot(codegen::CodeWriter& writer,
else
if
((
arg0_shape
.
size
()
==
2
)
&&
(
arg1_shape
.
size
()
==
1
)
&&
dot
->
get_reduction_axes_count
()
==
1
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_matrix
(
args
[
0
])
<<
" * "
<<
emit_vector
(
args
[
1
])
<<
";
\n
"
;
...
...
@@ -237,7 +225,7 @@ void runtime::cpu::CPU_Emitter::EmitDot(codegen::CodeWriter& writer,
// clang-format off
if
(
args
[
0
].
get_element_type
()
==
element
::
f32
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
"cblas::cblas_sgemm("
<<
"cblas::Layout::RowMajor, "
...
...
@@ -252,7 +240,7 @@ void runtime::cpu::CPU_Emitter::EmitDot(codegen::CodeWriter& writer,
// clang-format on
else
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_matrix
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_matrix
(
args
[
0
])
<<
" * "
<<
emit_matrix
(
args
[
1
])
<<
";
\n
"
;
...
...
@@ -272,12 +260,9 @@ void runtime::cpu::CPU_Emitter::EmitDot(codegen::CodeWriter& writer,
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMultiply
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitMultiply
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -295,15 +280,11 @@ void runtime::cpu::CPU_Emitter::EmitMultiply(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitGetOutputElement
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitGetOutputElement
)
{
auto
get_tuple_element
=
static_cast
<
const
op
::
GetOutputElement
*>
(
n
);
auto
get_tuple_element
=
static_cast
<
const
op
::
GetOutputElement
*>
(
n
ode
);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
get_tuple_element
->
get_n
()].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -311,12 +292,9 @@ void runtime::cpu::CPU_Emitter::EmitGetOutputElement(
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitTuple
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitTuple
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
for
(
size_t
i
=
0
;
i
<
args
.
size
();
++
i
)
{
...
...
@@ -327,12 +305,9 @@ void runtime::cpu::CPU_Emitter::EmitTuple(codegen::CodeWriter& writer,
writer
+=
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitAbs
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitAbs
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
;
...
...
@@ -348,17 +323,14 @@ void runtime::cpu::CPU_Emitter::EmitAbs(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitConcat
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitConcat
)
{
auto
result_shape
=
out
[
0
].
get_shape
();
#if PREFER_EIGEN == 1
if
(
result_shape
.
size
()
==
1
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
],
"out_vector"
)
<<
";
\n
"
;
...
...
@@ -374,9 +346,9 @@ void runtime::cpu::CPU_Emitter::EmitConcat(codegen::CodeWriter& writer,
}
else
if
(
result_shape
.
size
()
==
2
)
{
auto
axis
=
(
dynamic_cast
<
const
op
::
Concat
*>
(
n
))
->
get_concatenation_axis
();
auto
axis
=
(
dynamic_cast
<
const
op
::
Concat
*>
(
n
ode
))
->
get_concatenation_axis
();
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_matrix
(
out
[
0
],
"out_matrix"
)
<<
";
\n
"
;
...
...
@@ -439,7 +411,7 @@ void runtime::cpu::CPU_Emitter::EmitConcat(codegen::CodeWriter& writer,
}
}
#else
auto
axis
=
(
dynamic_cast
<
const
op
::
Concat
*>
(
n
))
->
get_concatenation_axis
();
auto
axis
=
(
dynamic_cast
<
const
op
::
Concat
*>
(
n
ode
))
->
get_concatenation_axis
();
std
::
vector
<
std
::
string
>
arg_names
;
std
::
vector
<
Shape
>
arg_shapes
;
...
...
@@ -460,14 +432,11 @@ void runtime::cpu::CPU_Emitter::EmitConcat(codegen::CodeWriter& writer,
#endif
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitDivide
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitDivide
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
if
(
n
->
get_element_type
().
is_real
()
==
false
)
if
(
n
ode
->
get_element_type
().
is_real
()
==
false
)
{
// Check for divide by zero for integer types only
size_t
element_count
=
args
[
1
].
get_size
();
...
...
@@ -493,12 +462,9 @@ void runtime::cpu::CPU_Emitter::EmitDivide(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitEqual
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitEqual
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -516,12 +482,9 @@ void runtime::cpu::CPU_Emitter::EmitEqual(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitGreater
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitGreater
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" xxx
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" xxx
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -539,12 +502,9 @@ void runtime::cpu::CPU_Emitter::EmitGreater(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitGreaterEq
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitGreaterEq
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -562,12 +522,9 @@ void runtime::cpu::CPU_Emitter::EmitGreaterEq(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitLess
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitLess
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -585,12 +542,9 @@ void runtime::cpu::CPU_Emitter::EmitLess(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitLessEq
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitLessEq
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -608,12 +562,9 @@ void runtime::cpu::CPU_Emitter::EmitLessEq(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitLog
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitLog
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -629,12 +580,9 @@ void runtime::cpu::CPU_Emitter::EmitLog(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMaximum
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitMaximum
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -653,12 +601,9 @@ void runtime::cpu::CPU_Emitter::EmitMaximum(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMinimum
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitMinimum
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -677,12 +622,9 @@ void runtime::cpu::CPU_Emitter::EmitMinimum(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitNegative
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitNegative
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -698,12 +640,9 @@ void runtime::cpu::CPU_Emitter::EmitNegative(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitNotEqual
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitNotEqual
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -721,12 +660,9 @@ void runtime::cpu::CPU_Emitter::EmitNotEqual(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSelect
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSelect
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -745,12 +681,9 @@ void runtime::cpu::CPU_Emitter::EmitSelect(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSubtract
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSubtract
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -768,14 +701,11 @@ void runtime::cpu::CPU_Emitter::EmitSubtract(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitBroadcast
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitBroadcast
)
{
auto
broadcast
=
static_cast
<
const
op
::
Broadcast
*>
(
n
);
auto
broadcast
=
static_cast
<
const
op
::
Broadcast
*>
(
n
ode
);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
auto
arg_shape
=
args
[
0
].
get_shape
();
...
...
@@ -783,7 +713,7 @@ void runtime::cpu::CPU_Emitter::EmitBroadcast(codegen::CodeWriter& writer,
if
(
broadcast
->
get_broadcast_axes
().
empty
())
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
0
].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -792,7 +722,7 @@ void runtime::cpu::CPU_Emitter::EmitBroadcast(codegen::CodeWriter& writer,
}
else
if
(
arg_shape
.
size
()
==
0
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_array1d
(
args
[
0
])
<<
"(0, 0);
\n
"
;
...
...
@@ -803,7 +733,7 @@ void runtime::cpu::CPU_Emitter::EmitBroadcast(codegen::CodeWriter& writer,
{
if
(
broadcast
->
get_broadcast_axes
()
==
AxisSet
{
1
})
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_matrix
(
out
[
0
])
<<
".colwise() =
\n
"
<<
" "
<<
emit_vector
(
args
[
0
])
<<
";
\n
"
;
...
...
@@ -812,7 +742,7 @@ void runtime::cpu::CPU_Emitter::EmitBroadcast(codegen::CodeWriter& writer,
}
else
if
(
broadcast
->
get_broadcast_axes
()
==
AxisSet
{
0
})
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
"Eigen::Map<Eigen::Matrix<"
<<
out
[
0
].
get_element_type
().
c_type_string
()
...
...
@@ -856,14 +786,11 @@ void runtime::cpu::CPU_Emitter::EmitBroadcast(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitConvert
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitConvert
)
{
auto
&
result_element_type
=
out
[
0
].
get_element_type
();
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -881,20 +808,14 @@ void runtime::cpu::CPU_Emitter::EmitConvert(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitConstant
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitConstant
)
{
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitReshape
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitReshape
)
{
auto
reshape
=
static_cast
<
const
op
::
Reshape
*>
(
n
);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
auto
reshape
=
static_cast
<
const
op
::
Reshape
*>
(
n
ode
);
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
auto
arg_shape
=
args
[
0
].
get_shape
();
...
...
@@ -917,7 +838,7 @@ void runtime::cpu::CPU_Emitter::EmitReshape(codegen::CodeWriter& writer,
// we can just copy.
if
(
same_layout
||
result_shape_product
<
2
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 1
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 1
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
0
].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -931,7 +852,7 @@ void runtime::cpu::CPU_Emitter::EmitReshape(codegen::CodeWriter& writer,
// clang-format off
if
(
result_element_type
==
ngraph
::
element
::
f32
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 2
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 2
\n
"
;
writer
.
indent
++
;
writer
<<
"mkl::MKL_Somatcopy('R', 'T', "
<<
to_string
(
arg_shape
[
0
])
<<
",
\n
"
<<
" "
<<
to_string
(
arg_shape
[
1
])
<<
", 1.0f,
\n
"
<<
...
...
@@ -945,7 +866,7 @@ void runtime::cpu::CPU_Emitter::EmitReshape(codegen::CodeWriter& writer,
// clang-format on
else
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 3
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 3
\n
"
;
writer
.
indent
++
;
writer
<<
emit_matrix
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_matrix
(
args
[
0
])
<<
".transpose();
\n
"
;
...
...
@@ -976,13 +897,9 @@ void runtime::cpu::CPU_Emitter::EmitReshape(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitFunctionCall
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitFunctionCall
)
{
auto
function_call
=
static_cast
<
const
op
::
FunctionCall
*>
(
n
);
auto
function_call
=
static_cast
<
const
op
::
FunctionCall
*>
(
n
ode
);
shared_ptr
<
Function
>
function
=
function_call
->
get_functions
()[
0
];
writer
<<
"{ // Call "
<<
function
->
get_name
()
<<
"
\n
"
;
...
...
@@ -1026,12 +943,9 @@ void runtime::cpu::CPU_Emitter::EmitFunctionCall(
// the compiled version of these ops is intended to have semantics identical
// to what's seen there (for now atleast)
void
runtime
::
cpu
::
CPU_Emitter
::
EmitReduce
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitReduce
)
{
auto
reduce
=
static_cast
<
const
op
::
Reduce
*>
(
n
);
auto
reduce
=
static_cast
<
const
op
::
Reduce
*>
(
n
ode
);
auto
reduction_function
=
reduce
->
get_functions
()[
0
];
auto
reductee_shape
=
args
[
0
].
get_shape
();
...
...
@@ -1044,7 +958,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
// Trivial case: no reduction axes (this includes the scalar-reductee case).
if
(
reduction_axes
.
empty
())
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 1
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 1
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
0
].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -1081,7 +995,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
{
if
(
reductee_shape
.
at
(
0
)
==
0
||
(
reductee_shape
.
size
()
==
2
&&
reductee_shape
.
at
(
1
)
==
0
))
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 2
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 2
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
1
].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -1090,7 +1004,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
}
else
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 3
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 3
\n
"
;
writer
.
indent
++
;
string
type
=
f_result_element_type
.
c_type_string
();
writer
<<
"auto f = [&]("
<<
type
<<
" x, "
<<
type
<<
" y) -> "
<<
type
<<
"
\n
{"
;
...
...
@@ -1113,7 +1027,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
{
if
(
reductee_shape
.
at
(
1
)
==
0
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 4
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 4
\n
"
;
writer
.
indent
++
;
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_array1d
(
args
[
1
])
<<
"(0, 0);
\n
"
;
...
...
@@ -1126,7 +1040,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
// dynamic_pointer_cast<CallFrame>(external->make_call_frame());
// ef->get_callees().emplace_back(cf);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 5
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 5
\n
"
;
writer
.
indent
++
;
string
type
=
f_result_element_type
.
c_type_string
();
writer
<<
"auto f = [&]("
<<
type
<<
" x, "
<<
type
<<
" y) -> "
<<
type
<<
"
\n
{"
;
...
...
@@ -1149,7 +1063,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
{
if
(
reductee_shape
.
at
(
0
)
==
0
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 6
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 6
\n
"
;
writer
.
indent
++
;
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_array1d
(
args
[
1
])
<<
"(0, 0);
\n
"
;
...
...
@@ -1158,7 +1072,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
}
else
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 7
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 7
\n
"
;
writer
.
indent
++
;
string
type
=
f_result_element_type
.
c_type_string
();
writer
<<
"auto f = [&]("
<<
type
<<
" x, "
<<
type
<<
" y) -> "
<<
type
<<
"
\n
{"
;
...
...
@@ -1179,7 +1093,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
}
else
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
string
type
=
f_result_element_type
.
c_type_string
();
...
...
@@ -1206,7 +1120,7 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
#else
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 1
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 1
\n
"
;
writer
.
indent
++
;
string
type
=
f_result_element_type
.
c_type_string
();
...
...
@@ -1236,12 +1150,9 @@ void runtime::cpu::CPU_Emitter::EmitReduce(codegen::CodeWriter& writer,
#endif
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSign
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSign
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1258,14 +1169,11 @@ void runtime::cpu::CPU_Emitter::EmitSign(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSlice
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSlice
)
{
const
op
::
Slice
*
slice
=
static_cast
<
const
op
::
Slice
*>
(
n
);
const
op
::
Slice
*
slice
=
static_cast
<
const
op
::
Slice
*>
(
n
ode
);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
size_t
arg_rank
=
args
[
0
].
get_shape
().
size
();
...
...
@@ -1286,7 +1194,7 @@ void runtime::cpu::CPU_Emitter::EmitSlice(codegen::CodeWriter& writer,
// Scalar slice is necessarily just a copy.
if
(
!
strided
&&
arg_rank
==
0
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 1
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 1
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
0
].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -1295,7 +1203,7 @@ void runtime::cpu::CPU_Emitter::EmitSlice(codegen::CodeWriter& writer,
}
else
if
(
!
strided
&&
arg_rank
==
1
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 2
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 2
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_vector
(
args
[
0
])
<<
".segment(
\n
"
...
...
@@ -1306,7 +1214,7 @@ void runtime::cpu::CPU_Emitter::EmitSlice(codegen::CodeWriter& writer,
}
else
if
(
!
strided
&&
arg_rank
==
2
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 3
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 3
\n
"
;
writer
.
indent
++
;
writer
<<
emit_matrix
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_matrix
(
args
[
0
])
<<
".block("
<<
to_string
(
lower_bounds
[
0
])
...
...
@@ -1342,13 +1250,10 @@ void runtime::cpu::CPU_Emitter::EmitSlice(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSum
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSum
)
{
const
op
::
Sum
*
sum
=
static_cast
<
const
op
::
Sum
*>
(
n
);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
const
op
::
Sum
*
sum
=
static_cast
<
const
op
::
Sum
*>
(
n
ode
);
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
const
Shape
&
arg_shape
=
args
[
0
].
get_shape
();
...
...
@@ -1358,7 +1263,7 @@ void runtime::cpu::CPU_Emitter::EmitSum(codegen::CodeWriter& writer,
// Trivial case: no reduction axes.
if
(
reduction_axes
.
size
()
==
0
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
0
].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -1369,7 +1274,7 @@ void runtime::cpu::CPU_Emitter::EmitSum(codegen::CodeWriter& writer,
else
if
((
arg_rank
==
1
&&
reduction_axes
==
AxisSet
{
0
})
||
(
arg_rank
==
2
&&
reduction_axes
==
AxisSet
{
0
,
1
}))
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_array1d
(
args
[
0
])
<<
".sum();
\n
"
;
...
...
@@ -1378,7 +1283,7 @@ void runtime::cpu::CPU_Emitter::EmitSum(codegen::CodeWriter& writer,
}
else
if
(
arg_rank
==
2
&&
reduction_axes
==
AxisSet
{
1
})
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_matrix
(
args
[
0
])
<<
".rowwise().sum();
\n
"
;
...
...
@@ -1387,7 +1292,7 @@ void runtime::cpu::CPU_Emitter::EmitSum(codegen::CodeWriter& writer,
}
else
if
(
arg_rank
==
2
&&
reduction_axes
==
AxisSet
{
0
})
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_matrix
(
args
[
0
])
<<
".colwise().sum();
\n
"
;
...
...
@@ -1415,12 +1320,9 @@ void runtime::cpu::CPU_Emitter::EmitSum(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitExp
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitExp
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1436,12 +1338,9 @@ void runtime::cpu::CPU_Emitter::EmitExp(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSin
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSin
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1457,12 +1356,9 @@ void runtime::cpu::CPU_Emitter::EmitSin(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSinh
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSinh
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1478,12 +1374,9 @@ void runtime::cpu::CPU_Emitter::EmitSinh(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitCos
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitCos
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1499,12 +1392,9 @@ void runtime::cpu::CPU_Emitter::EmitCos(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitCosh
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitCosh
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1520,12 +1410,9 @@ void runtime::cpu::CPU_Emitter::EmitCosh(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitTan
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitTan
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1541,16 +1428,13 @@ void runtime::cpu::CPU_Emitter::EmitTan(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitTanh
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitTanh
)
{
// Eigen's generic_fast_tanh_float<float> is currently miscompiled by Clang/LLVM
// so we fall-back to tanh
// TODO: Implement our own internal fast/approximate tanh if this actually gets used
// by models
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 0
writer
<<
"#pragma omp parallel for
\n
"
;
...
...
@@ -1563,12 +1447,9 @@ void runtime::cpu::CPU_Emitter::EmitTanh(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitAsin
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitAsin
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1584,12 +1465,9 @@ void runtime::cpu::CPU_Emitter::EmitAsin(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitAcos
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitAcos
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1605,12 +1483,9 @@ void runtime::cpu::CPU_Emitter::EmitAcos(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitAtan
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitAtan
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
...
...
@@ -1626,12 +1501,9 @@ void runtime::cpu::CPU_Emitter::EmitAtan(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitPower
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitPower
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
writer
<<
emit_array1d
(
out
[
0
])
<<
" =
\n
"
;
...
...
@@ -1651,14 +1523,10 @@ void runtime::cpu::CPU_Emitter::EmitPower(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitReplaceSlice
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitReplaceSlice
)
{
auto
replace_slice
=
static_cast
<
const
op
::
Slice
*>
(
n
);
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
auto
replace_slice
=
static_cast
<
const
op
::
Slice
*>
(
n
ode
);
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
#if PREFER_EIGEN == 1
size_t
arg0_rank
=
args
[
0
].
get_shape
().
size
();
...
...
@@ -1679,7 +1547,7 @@ void runtime::cpu::CPU_Emitter::EmitReplaceSlice(
// Scalar slice is necessarily just a copy.
if
(
!
strided
&&
arg0_rank
==
0
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 1
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 1
\n
"
;
writer
.
indent
++
;
writer
<<
"memcpy("
<<
out
[
0
].
get_name
()
<<
", "
<<
args
[
1
].
get_name
()
<<
", "
<<
out
[
0
].
get_size
()
*
out
[
0
].
get_element_type
().
size
()
<<
");
\n
"
;
...
...
@@ -1688,7 +1556,7 @@ void runtime::cpu::CPU_Emitter::EmitReplaceSlice(
}
else
if
(
!
strided
&&
arg0_rank
==
1
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 2
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 2
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_vector
(
args
[
0
])
<<
";
\n
"
...
...
@@ -1701,7 +1569,7 @@ void runtime::cpu::CPU_Emitter::EmitReplaceSlice(
}
else
if
(
!
strided
&&
arg0_rank
==
2
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 3
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 3
\n
"
;
writer
.
indent
++
;
writer
<<
emit_matrix
(
out
[
0
])
<<
" =
\n
"
<<
" "
<<
emit_matrix
(
args
[
0
])
<<
";
\n
"
...
...
@@ -1743,12 +1611,9 @@ void runtime::cpu::CPU_Emitter::EmitReplaceSlice(
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitOneHot
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitOneHot
)
{
auto
oh
=
static_cast
<
const
op
::
OneHot
*>
(
n
);
auto
oh
=
static_cast
<
const
op
::
OneHot
*>
(
n
ode
);
auto
arg_rank
=
args
[
0
].
get_shape
().
size
();
...
...
@@ -1756,7 +1621,7 @@ void runtime::cpu::CPU_Emitter::EmitOneHot(codegen::CodeWriter& writer,
if
(
arg_rank
==
0
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 1
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 1
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
out
[
0
],
"out_vector"
)
<<
";
\n
"
;
...
...
@@ -1787,7 +1652,7 @@ void runtime::cpu::CPU_Emitter::EmitOneHot(codegen::CodeWriter& writer,
}
else
if
(
arg_rank
==
1
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
" 1
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
" 1
\n
"
;
writer
.
indent
++
;
writer
<<
emit_vector
(
args
[
0
],
"arg_vector"
)
<<
";
\n
"
;
...
...
@@ -1838,12 +1703,9 @@ void runtime::cpu::CPU_Emitter::EmitOneHot(codegen::CodeWriter& writer,
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitCeiling
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitCeiling
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
size_t
element_count
=
out
[
0
].
get_size
();
#if PREFER_EIGEN == 0
...
...
@@ -1857,12 +1719,9 @@ void runtime::cpu::CPU_Emitter::EmitCeiling(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitFloor
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitFloor
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
size_t
element_count
=
out
[
0
].
get_size
();
#if PREFER_EIGEN == 0
...
...
@@ -1876,12 +1735,9 @@ void runtime::cpu::CPU_Emitter::EmitFloor(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSqrt
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSqrt
)
{
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
size_t
element_count
=
out
[
0
].
get_size
();
#if PREFER_EIGEN == 0
...
...
@@ -1895,12 +1751,9 @@ void runtime::cpu::CPU_Emitter::EmitSqrt(codegen::CodeWriter& writer,
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitConvolution
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitConvolution
)
{
auto
convolution
=
static_cast
<
const
op
::
Convolution
*>
(
n
);
auto
convolution
=
static_cast
<
const
op
::
Convolution
*>
(
n
ode
);
auto
arg0_shape
=
args
[
0
].
get_shape
();
auto
arg1_shape
=
args
[
1
].
get_shape
();
...
...
@@ -2025,13 +1878,9 @@ void runtime::cpu::CPU_Emitter::EmitConvolution(codegen::CodeWriter& writer,
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitConvolutionBackpropFilters
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitConvolutionBackpropFilters
)
{
auto
convolution
=
static_cast
<
const
op
::
ConvolutionBackpropFilters
*>
(
n
);
auto
convolution
=
static_cast
<
const
op
::
ConvolutionBackpropFilters
*>
(
n
ode
);
auto
arg0_shape
=
args
[
0
].
get_shape
();
auto
arg1_shape
=
args
[
1
].
get_shape
();
...
...
@@ -2136,13 +1985,9 @@ void runtime::cpu::CPU_Emitter::EmitConvolutionBackpropFilters(
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitConvolutionBackpropData
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitConvolutionBackpropData
)
{
auto
convolution
=
static_cast
<
const
op
::
ConvolutionBackpropData
*>
(
n
);
auto
convolution
=
static_cast
<
const
op
::
ConvolutionBackpropData
*>
(
n
ode
);
auto
arg0_shape
=
args
[
0
].
get_shape
();
auto
arg1_shape
=
args
[
1
].
get_shape
();
...
...
@@ -2246,22 +2091,16 @@ void runtime::cpu::CPU_Emitter::EmitConvolutionBackpropData(
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitNot
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitNot
)
{
writer
<<
"kernel::logical_not("
<<
args
[
0
].
get_name
()
<<
",
\n
"
<<
" "
<<
out
[
0
].
get_name
()
<<
",
\n
"
<<
" "
<<
out
[
0
].
get_size
()
<<
");
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMaxPool
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitMaxPool
)
{
auto
max_pool
=
static_cast
<
const
op
::
MaxPool
*>
(
n
);
auto
max_pool
=
static_cast
<
const
op
::
MaxPool
*>
(
n
ode
);
auto
arg_shape
=
args
[
0
].
get_shape
();
auto
arg_rank
=
arg_shape
.
size
();
...
...
@@ -2318,12 +2157,9 @@ void runtime::cpu::CPU_Emitter::EmitMaxPool(codegen::CodeWriter& writer,
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitReverse
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitReverse
)
{
auto
reverse
=
static_cast
<
const
op
::
Reverse
*>
(
n
);
auto
reverse
=
static_cast
<
const
op
::
Reverse
*>
(
n
ode
);
auto
arg_shape
=
args
[
0
].
get_shape
();
auto
result_shape
=
out
[
0
].
get_shape
();
...
...
@@ -2335,20 +2171,16 @@ void runtime::cpu::CPU_Emitter::EmitReverse(codegen::CodeWriter& writer,
writer
<<
" {"
<<
join
(
reverse
->
get_reversed_axes
())
<<
"});
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitReduceWindow
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitReduceWindow
)
{
auto
reduce_window
=
static_cast
<
const
op
::
ReduceWindow
*>
(
n
);
auto
reduce_window
=
static_cast
<
const
op
::
ReduceWindow
*>
(
n
ode
);
auto
arg_reductee_shape
=
args
[
0
].
get_shape
();
auto
result_shape
=
out
[
0
].
get_shape
();
auto
reduction_function
=
reduce_window
->
get_functions
()[
0
];
auto
&
f_result_element_type
=
out
[
0
].
get_element_type
();
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
string
type
=
f_result_element_type
.
c_type_string
();
...
...
@@ -2377,13 +2209,9 @@ void runtime::cpu::CPU_Emitter::EmitReduceWindow(
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitSelectAndScatter
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitSelectAndScatter
)
{
auto
select_and_scatter
=
static_cast
<
const
op
::
SelectAndScatter
*>
(
n
);
auto
select_and_scatter
=
static_cast
<
const
op
::
SelectAndScatter
*>
(
n
ode
);
auto
selection_function
=
select_and_scatter
->
get_functions
()[
0
];
auto
scatter_function
=
select_and_scatter
->
get_functions
()[
1
];
...
...
@@ -2391,10 +2219,10 @@ void runtime::cpu::CPU_Emitter::EmitSelectAndScatter(
auto
arg1_shape
=
args
[
1
].
get_shape
();
auto
result_shape
=
out
[
0
].
get_shape
();
writer
<<
"{ // "
<<
n
->
get_name
()
<<
"
\n
"
;
writer
<<
"{ // "
<<
n
ode
->
get_name
()
<<
"
\n
"
;
writer
.
indent
++
;
string
type
=
n
->
get_output_element_type
(
0
).
c_type_string
();
string
type
=
n
ode
->
get_output_element_type
(
0
).
c_type_string
();
writer
<<
"auto f_select = [&]("
<<
type
<<
" x, "
<<
type
<<
" y) -> char
\n
{"
;
writer
.
indent
++
;
...
...
@@ -2436,12 +2264,9 @@ void runtime::cpu::CPU_Emitter::EmitSelectAndScatter(
writer
<<
"}
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitAvgPool
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitAvgPool
)
{
auto
avg_pool
=
static_cast
<
const
op
::
AvgPool
*>
(
n
);
auto
avg_pool
=
static_cast
<
const
op
::
AvgPool
*>
(
n
ode
);
auto
arg_shape
=
args
[
0
].
get_shape
();
auto
arg_rank
=
arg_shape
.
size
();
...
...
@@ -2501,12 +2326,9 @@ void runtime::cpu::CPU_Emitter::EmitAvgPool(codegen::CodeWriter& writer,
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitPad
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitPad
)
{
auto
pad
=
static_cast
<
const
op
::
Pad
*>
(
n
);
auto
pad
=
static_cast
<
const
op
::
Pad
*>
(
n
ode
);
auto
arg0_shape
=
args
[
0
].
get_shape
();
auto
result_shape
=
out
[
0
].
get_shape
();
...
...
@@ -2521,13 +2343,9 @@ void runtime::cpu::CPU_Emitter::EmitPad(codegen::CodeWriter& writer,
writer
<<
" {"
<<
join
(
pad
->
get_padding_interior
())
<<
"});
\n
"
;
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitAvgPoolBackprop
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitAvgPoolBackprop
)
{
auto
apb
=
static_cast
<
const
op
::
AvgPoolBackprop
*>
(
n
);
auto
apb
=
static_cast
<
const
op
::
AvgPoolBackprop
*>
(
n
ode
);
auto
delta_shape
=
args
[
0
].
get_shape
();
auto
delta_rank
=
delta_shape
.
size
();
...
...
@@ -2586,13 +2404,9 @@ void runtime::cpu::CPU_Emitter::EmitAvgPoolBackprop(
}
}
void
runtime
::
cpu
::
CPU_Emitter
::
EmitMaxPoolBackprop
(
codegen
::
CodeWriter
&
writer
,
const
ngraph
::
Node
*
n
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
args
,
const
vector
<
runtime
::
cpu
::
TensorViewWrapper
>&
out
)
void
runtime
::
cpu
::
CPU_Emitter
::
EMITTER_DECL
(
EmitMaxPoolBackprop
)
{
auto
mpb
=
static_cast
<
const
op
::
MaxPoolBackprop
*>
(
n
);
auto
mpb
=
static_cast
<
const
op
::
MaxPoolBackprop
*>
(
n
ode
);
auto
delta_shape
=
args
[
1
].
get_shape
();
auto
out_shape
=
out
[
0
].
get_shape
();
...
...
src/ngraph/runtime/cpu/cpu_emitter.hpp
View file @
62342c4e
...
...
@@ -25,8 +25,9 @@
#include "ngraph/runtime/cpu/cpu_tensor_view_wrapper.hpp"
#define EMITTER_DECL(E) \
E(codegen::CodeWriter& writer, \
const ngraph::Node* n, \
E(ngraph::runtime::cpu::CPU_ExternalFunction* external_function, \
codegen::CodeWriter& writer, \
const ngraph::Node* node, \
const std::vector<ngraph::runtime::cpu::TensorViewWrapper>& args, \
const std::vector<ngraph::runtime::cpu::TensorViewWrapper>& out)
...
...
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
62342c4e
...
...
@@ -677,7 +677,7 @@ using namespace ngraph::runtime;
}
if
(
func_name
.
empty
())
{
handler
->
second
(
writer
,
node
.
get
(),
in
,
out
);
handler
->
second
(
this
,
writer
,
node
.
get
(),
in
,
out
);
}
else
{
...
...
@@ -952,7 +952,7 @@ string runtime::cpu::CPU_ExternalFunction::emit_op_as_function(const Node& node,
writer
<<
"
\n
)
\n
"
;
writer
<<
"{
\n
"
;
writer
.
indent
++
;
handler
->
second
(
writer
,
&
node
,
in
,
out
);
handler
->
second
(
this
,
writer
,
&
node
,
in
,
out
);
writer
.
indent
--
;
writer
<<
"}
\n
"
;
...
...
src/ngraph/runtime/cpu/cpu_external_function.hpp
View file @
62342c4e
...
...
@@ -43,7 +43,8 @@ namespace ngraph
class
CPU_Emitter
;
class
CPU_CallFrame
;
using
OpFunction
=
std
::
function
<
void
(
codegen
::
CodeWriter
&
,
using
OpFunction
=
std
::
function
<
void
(
CPU_ExternalFunction
*
external_function
,
codegen
::
CodeWriter
&
,
const
ngraph
::
Node
*
,
const
std
::
vector
<
TensorViewWrapper
>&
inputs
,
const
std
::
vector
<
TensorViewWrapper
>&
outputs
)
>
;
...
...
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