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
2775b0bf
Unverified
Commit
2775b0bf
authored
Jan 14, 2018
by
Robert Kimball
Committed by
GitHub
Jan 14, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make CPU emit functions static so they can be called by other backends (#376)
parent
c682fbf4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
76 deletions
+64
-76
cpu_emitter.cpp
src/ngraph/runtime/cpu/cpu_emitter.cpp
+0
-0
cpu_emitter.hpp
src/ngraph/runtime/cpu/cpu_emitter.hpp
+60
-71
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+3
-4
cpu_external_function.hpp
src/ngraph/runtime/cpu/cpu_external_function.hpp
+1
-1
No files found.
src/ngraph/runtime/cpu/cpu_emitter.cpp
View file @
2775b0bf
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/ngraph/runtime/cpu/cpu_emitter.hpp
View file @
2775b0bf
...
...
@@ -23,7 +23,8 @@
#include "ngraph/runtime/cpu/cpu_tensor_view_wrapper.hpp"
#define EMITTER_DECL(E) \
E(const ngraph::Node* n, \
E(codegen::CodeWriter& writer, \
const ngraph::Node* n, \
const std::vector<ngraph::runtime::cpu::TensorViewWrapper>& args, \
const std::vector<ngraph::runtime::cpu::TensorViewWrapper>& out)
...
...
@@ -35,79 +36,67 @@ namespace ngraph
{
class
CPU_Emitter
{
protected
:
codegen
::
CodeWriter
m_out
;
bool
m_use_ref_kernels
;
public
:
CPU_Emitter
()
:
m_out
()
,
m_use_ref_kernels
(
std
::
getenv
(
"NGRAPH_CPU_USE_REF_KERNELS"
)
!=
nullptr
)
{
}
std
::
string
get_code
()
{
return
m_out
.
get_code
();
}
codegen
::
CodeWriter
&
get_code_writer
()
{
return
m_out
;
}
void
EMITTER_DECL
(
EmitNop
);
void
EMITTER_DECL
(
EmitAdd
);
void
EMITTER_DECL
(
EmitDot
);
void
EMITTER_DECL
(
EmitMultiply
);
void
EMITTER_DECL
(
EmitGetOutputElement
);
void
EMITTER_DECL
(
EmitXLAGetTupleElement
);
void
EMITTER_DECL
(
EmitTuple
);
void
EMITTER_DECL
(
EmitAbs
);
void
EMITTER_DECL
(
EmitConcat
);
void
EMITTER_DECL
(
EmitDivide
);
void
EMITTER_DECL
(
EmitEqual
);
void
EMITTER_DECL
(
EmitGreater
);
void
EMITTER_DECL
(
EmitGreaterEq
);
void
EMITTER_DECL
(
EmitLess
);
void
EMITTER_DECL
(
EmitLessEq
);
void
EMITTER_DECL
(
EmitLog
);
void
EMITTER_DECL
(
EmitMaximum
);
void
EMITTER_DECL
(
EmitMinimum
);
void
EMITTER_DECL
(
EmitNegative
);
void
EMITTER_DECL
(
EmitNotEqual
);
void
EMITTER_DECL
(
EmitSelect
);
void
EMITTER_DECL
(
EmitSubtract
);
void
EMITTER_DECL
(
EmitBroadcast
);
void
EMITTER_DECL
(
EmitConvert
);
void
EMITTER_DECL
(
EmitConstant
);
void
EMITTER_DECL
(
EmitReshape
);
void
EMITTER_DECL
(
EmitFunctionCall
);
void
EMITTER_DECL
(
EmitReduce
);
void
EMITTER_DECL
(
EmitSign
);
void
EMITTER_DECL
(
EmitSlice
);
void
EMITTER_DECL
(
EmitSum
);
void
EMITTER_DECL
(
EmitExp
);
void
EMITTER_DECL
(
EmitSin
);
void
EMITTER_DECL
(
EmitSinh
);
void
EMITTER_DECL
(
EmitCos
);
void
EMITTER_DECL
(
EmitCosh
);
void
EMITTER_DECL
(
EmitTan
);
void
EMITTER_DECL
(
EmitTanh
);
void
EMITTER_DECL
(
EmitAsin
);
void
EMITTER_DECL
(
EmitAcos
);
void
EMITTER_DECL
(
EmitAtan
);
void
EMITTER_DECL
(
EmitPower
);
void
EMITTER_DECL
(
EmitReplaceSlice
);
void
EMITTER_DECL
(
EmitOneHot
);
void
EMITTER_DECL
(
EmitFloor
);
void
EMITTER_DECL
(
EmitCeiling
);
void
EMITTER_DECL
(
EmitSqrt
);
void
EMITTER_DECL
(
EmitConvolution
);
void
EMITTER_DECL
(
EmitNot
);
void
EMITTER_DECL
(
EmitMaxPool
);
void
EMITTER_DECL
(
EmitReverse
);
void
EMITTER_DECL
(
EmitReduceWindow
);
static
void
EMITTER_DECL
(
EmitNop
);
static
void
EMITTER_DECL
(
EmitAdd
);
static
void
EMITTER_DECL
(
EmitDot
);
static
void
EMITTER_DECL
(
EmitMultiply
);
static
void
EMITTER_DECL
(
EmitGetOutputElement
);
static
void
EMITTER_DECL
(
EmitXLAGetTupleElement
);
static
void
EMITTER_DECL
(
EmitTuple
);
static
void
EMITTER_DECL
(
EmitAbs
);
static
void
EMITTER_DECL
(
EmitConcat
);
static
void
EMITTER_DECL
(
EmitDivide
);
static
void
EMITTER_DECL
(
EmitEqual
);
static
void
EMITTER_DECL
(
EmitGreater
);
static
void
EMITTER_DECL
(
EmitGreaterEq
);
static
void
EMITTER_DECL
(
EmitLess
);
static
void
EMITTER_DECL
(
EmitLessEq
);
static
void
EMITTER_DECL
(
EmitLog
);
static
void
EMITTER_DECL
(
EmitMaximum
);
static
void
EMITTER_DECL
(
EmitMinimum
);
static
void
EMITTER_DECL
(
EmitNegative
);
static
void
EMITTER_DECL
(
EmitNotEqual
);
static
void
EMITTER_DECL
(
EmitSelect
);
static
void
EMITTER_DECL
(
EmitSubtract
);
static
void
EMITTER_DECL
(
EmitBroadcast
);
static
void
EMITTER_DECL
(
EmitConvert
);
static
void
EMITTER_DECL
(
EmitConstant
);
static
void
EMITTER_DECL
(
EmitReshape
);
static
void
EMITTER_DECL
(
EmitFunctionCall
);
static
void
EMITTER_DECL
(
EmitReduce
);
static
void
EMITTER_DECL
(
EmitSign
);
static
void
EMITTER_DECL
(
EmitSlice
);
static
void
EMITTER_DECL
(
EmitSum
);
static
void
EMITTER_DECL
(
EmitExp
);
static
void
EMITTER_DECL
(
EmitSin
);
static
void
EMITTER_DECL
(
EmitSinh
);
static
void
EMITTER_DECL
(
EmitCos
);
static
void
EMITTER_DECL
(
EmitCosh
);
static
void
EMITTER_DECL
(
EmitTan
);
static
void
EMITTER_DECL
(
EmitTanh
);
static
void
EMITTER_DECL
(
EmitAsin
);
static
void
EMITTER_DECL
(
EmitAcos
);
static
void
EMITTER_DECL
(
EmitAtan
);
static
void
EMITTER_DECL
(
EmitPower
);
static
void
EMITTER_DECL
(
EmitReplaceSlice
);
static
void
EMITTER_DECL
(
EmitOneHot
);
static
void
EMITTER_DECL
(
EmitFloor
);
static
void
EMITTER_DECL
(
EmitCeiling
);
static
void
EMITTER_DECL
(
EmitSqrt
);
static
void
EMITTER_DECL
(
EmitConvolution
);
static
void
EMITTER_DECL
(
EmitNot
);
static
void
EMITTER_DECL
(
EmitMaxPool
);
static
void
EMITTER_DECL
(
EmitReverse
);
static
void
EMITTER_DECL
(
EmitReduceWindow
);
private
:
void
generate_call
(
const
std
::
vector
<
TensorViewWrapper
>&
args
,
const
std
::
vector
<
TensorViewWrapper
>&
out
,
std
::
shared_ptr
<
Function
>
function
);
std
::
string
emit_vector
(
const
TensorViewWrapper
&
,
const
std
::
string
&
name
=
""
);
std
::
string
emit_array1d
(
const
TensorViewWrapper
&
,
const
std
::
string
&
name
=
""
);
std
::
string
emit_matrix
(
const
TensorViewWrapper
&
,
const
std
::
string
&
name
=
""
);
static
std
::
string
emit_vector
(
const
TensorViewWrapper
&
,
const
std
::
string
&
name
=
""
);
static
std
::
string
emit_array1d
(
const
TensorViewWrapper
&
,
const
std
::
string
&
name
=
""
);
static
std
::
string
emit_matrix
(
const
TensorViewWrapper
&
,
const
std
::
string
&
name
=
""
);
};
}
}
...
...
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
2775b0bf
...
...
@@ -216,8 +216,7 @@ void runtime::cpu::CPU_ExternalFunction::compile()
pass_manager
.
register_pass
<
pass
::
DumpSorted
>
(
dump_filename
);
pass_manager
.
run_passes
(
m_function
);
CPU_Emitter
emitter
;
codegen
::
CodeWriter
&
writer
=
emitter
.
get_code_writer
();
codegen
::
CodeWriter
writer
;
writer
+=
R"(// Generated by the NGraph CPU backend
...
...
@@ -432,7 +431,7 @@ using namespace ngraph::runtime;
writer
<<
"
\n
)
\n
"
;
writer
<<
"{
\n
"
;
writer
.
indent
++
;
handler
->
second
(
&
emit
ter
,
&
n
,
in
,
out
);
handler
->
second
(
wri
ter
,
&
n
,
in
,
out
);
writer
.
indent
--
;
writer
<<
"}
\n
"
;
}
...
...
@@ -632,7 +631,7 @@ using namespace ngraph::runtime;
}
if
(
func_name
.
empty
())
{
handler
->
second
(
&
emit
ter
,
node
.
get
(),
in
,
out
);
handler
->
second
(
wri
ter
,
node
.
get
(),
in
,
out
);
}
else
{
...
...
src/ngraph/runtime/cpu/cpu_external_function.hpp
View file @
2775b0bf
...
...
@@ -38,7 +38,7 @@ namespace ngraph
class
CPU_Emitter
;
class
CPU_CallFrame
;
using
OpFunction
=
std
::
function
<
void
(
CPU_Emitter
*
,
using
OpFunction
=
std
::
function
<
void
(
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