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
c0ab7d42
Unverified
Commit
c0ab7d42
authored
Aug 02, 2019
by
Scott Cyphers
Committed by
GitHub
Aug 02, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3251 from NervanaSystems/pruthvi/cpu_static_backend
pruthvi/cpu static backend
parents
410d6e61
7a4cc10c
Hide whitespace changes
Inline
Side-by-side
Showing
71 changed files
with
572 additions
and
66 deletions
+572
-66
CMakeLists.txt
CMakeLists.txt
+31
-23
backend.cpp
src/ngraph/runtime/backend.cpp
+46
-2
backend.hpp
src/ngraph/runtime/backend.hpp
+17
-8
backend_manager.cpp
src/ngraph/runtime/backend_manager.cpp
+15
-22
CMakeLists.txt
src/ngraph/runtime/cpu/CMakeLists.txt
+11
-2
add.cpp
src/ngraph/runtime/cpu/builder/add.cpp
+4
-0
allreduce.cpp
src/ngraph/runtime/cpu/builder/allreduce.cpp
+4
-0
argmax.cpp
src/ngraph/runtime/cpu/builder/argmax.cpp
+4
-0
argmin.cpp
src/ngraph/runtime/cpu/builder/argmin.cpp
+3
-0
avg_pool.cpp
src/ngraph/runtime/cpu/builder/avg_pool.cpp
+4
-0
batch_norm.cpp
src/ngraph/runtime/cpu/builder/batch_norm.cpp
+4
-0
bounded_relu.cpp
src/ngraph/runtime/cpu/builder/bounded_relu.cpp
+3
-0
broadcast.cpp
src/ngraph/runtime/cpu/builder/broadcast.cpp
+3
-0
broadcast_distributed.cpp
src/ngraph/runtime/cpu/builder/broadcast_distributed.cpp
+3
-0
concat.cpp
src/ngraph/runtime/cpu/builder/concat.cpp
+3
-0
convert.cpp
src/ngraph/runtime/cpu/builder/convert.cpp
+3
-0
convert_layout.cpp
src/ngraph/runtime/cpu/builder/convert_layout.cpp
+3
-0
convolution.cpp
src/ngraph/runtime/cpu/builder/convolution.cpp
+4
-0
dot.cpp
src/ngraph/runtime/cpu/builder/dot.cpp
+3
-0
dropout.cpp
src/ngraph/runtime/cpu/builder/dropout.cpp
+3
-0
embedding_lookup.cpp
src/ngraph/runtime/cpu/builder/embedding_lookup.cpp
+3
-0
erf.cpp
src/ngraph/runtime/cpu/builder/erf.cpp
+3
-0
gather.cpp
src/ngraph/runtime/cpu/builder/gather.cpp
+3
-0
gather_nd.cpp
src/ngraph/runtime/cpu/builder/gather_nd.cpp
+3
-0
get_output_element.cpp
src/ngraph/runtime/cpu/builder/get_output_element.cpp
+3
-0
leaky_relu.cpp
src/ngraph/runtime/cpu/builder/leaky_relu.cpp
+3
-0
lrn.cpp
src/ngraph/runtime/cpu/builder/lrn.cpp
+3
-0
lstm.cpp
src/ngraph/runtime/cpu/builder/lstm.cpp
+3
-0
matmul_bias.cpp
src/ngraph/runtime/cpu/builder/matmul_bias.cpp
+3
-0
max.cpp
src/ngraph/runtime/cpu/builder/max.cpp
+3
-0
max_pool.cpp
src/ngraph/runtime/cpu/builder/max_pool.cpp
+3
-0
min.cpp
src/ngraph/runtime/cpu/builder/min.cpp
+3
-0
one_hot.cpp
src/ngraph/runtime/cpu/builder/one_hot.cpp
+3
-0
pad.cpp
src/ngraph/runtime/cpu/builder/pad.cpp
+3
-0
product.cpp
src/ngraph/runtime/cpu/builder/product.cpp
+3
-0
quantization.cpp
src/ngraph/runtime/cpu/builder/quantization.cpp
+3
-0
quantized_avg_pool.cpp
src/ngraph/runtime/cpu/builder/quantized_avg_pool.cpp
+3
-0
quantized_conv.cpp
src/ngraph/runtime/cpu/builder/quantized_conv.cpp
+3
-0
quantized_dot.cpp
src/ngraph/runtime/cpu/builder/quantized_dot.cpp
+3
-0
quantized_matmul.cpp
src/ngraph/runtime/cpu/builder/quantized_matmul.cpp
+3
-0
reduce_function.cpp
src/ngraph/runtime/cpu/builder/reduce_function.cpp
+3
-0
relu.cpp
src/ngraph/runtime/cpu/builder/relu.cpp
+3
-0
replace_slice.cpp
src/ngraph/runtime/cpu/builder/replace_slice.cpp
+3
-0
reshape.cpp
src/ngraph/runtime/cpu/builder/reshape.cpp
+3
-0
reverse.cpp
src/ngraph/runtime/cpu/builder/reverse.cpp
+3
-0
reverse_sequence.cpp
src/ngraph/runtime/cpu/builder/reverse_sequence.cpp
+3
-0
rnn.cpp
src/ngraph/runtime/cpu/builder/rnn.cpp
+3
-0
scatter_add.cpp
src/ngraph/runtime/cpu/builder/scatter_add.cpp
+3
-0
scatter_nd_add.cpp
src/ngraph/runtime/cpu/builder/scatter_nd_add.cpp
+3
-0
select.cpp
src/ngraph/runtime/cpu/builder/select.cpp
+3
-0
sigmoid.cpp
src/ngraph/runtime/cpu/builder/sigmoid.cpp
+3
-0
slice.cpp
src/ngraph/runtime/cpu/builder/slice.cpp
+3
-0
softmax.cpp
src/ngraph/runtime/cpu/builder/softmax.cpp
+3
-0
state.cpp
src/ngraph/runtime/cpu/builder/state.cpp
+3
-0
sum.cpp
src/ngraph/runtime/cpu/builder/sum.cpp
+3
-0
tile.cpp
src/ngraph/runtime/cpu/builder/tile.cpp
+3
-0
topk.cpp
src/ngraph/runtime/cpu/builder/topk.cpp
+3
-0
update_slice.cpp
src/ngraph/runtime/cpu/builder/update_slice.cpp
+3
-0
cpu_backend.cpp
src/ngraph/runtime/cpu/cpu_backend.cpp
+21
-2
cpu_backend.hpp
src/ngraph/runtime/cpu/cpu_backend.hpp
+2
-1
cpu_builder.cpp
src/ngraph/runtime/cpu/cpu_builder.cpp
+1
-0
cpu_builder_registry.cpp
src/ngraph/runtime/cpu/cpu_builder_registry.cpp
+84
-0
cpu_builder_registry.hpp
src/ngraph/runtime/cpu/cpu_builder_registry.hpp
+82
-0
cpu_external_function.cpp
src/ngraph/runtime/cpu/cpu_external_function.cpp
+6
-0
static_initialize.hpp
src/ngraph/runtime/cpu/static_initialize.hpp
+10
-3
CMakeLists.txt
src/ngraph/runtime/interpreter/CMakeLists.txt
+10
-2
int_backend.cpp
src/ngraph/runtime/interpreter/int_backend.cpp
+20
-1
int_backend.hpp
src/ngraph/runtime/interpreter/int_backend.hpp
+1
-0
static_initialize.hpp
src/ngraph/runtime/interpreter/static_initialize.hpp
+28
-0
nbench.cpp
src/tools/nbench/nbench.cpp
+11
-0
main.cpp
test/main.cpp
+11
-0
No files found.
CMakeLists.txt
View file @
c0ab7d42
...
...
@@ -182,6 +182,8 @@ option(NGRAPH_DISTRIBUTED_ENABLE "Enable distributed training using MLSL/OpenMPI
option
(
NGRAPH_FAST_MATH_ENABLE
"Enable fast math"
ON
)
option
(
NGRAPH_JSON_ENABLE
"Enable JSON based serialization and tracing features"
TRUE
)
option
(
NGRAPH_STATIC_LIB_ENABLE
"Enable build nGraph static library"
FALSE
)
option
(
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
"Enable build INTERPRETER backend static library"
FALSE
)
option
(
NGRAPH_CPU_STATIC_LIB_ENABLE
"Enable build CPU backend static library"
FALSE
)
if
(
NGRAPH_CPU_ENABLE
AND
...
...
@@ -257,29 +259,35 @@ NORMALIZE_BOOL(NGRAPH_PYTHON_BUILD_ENABLE)
NORMALIZE_BOOL
(
NGRAPH_USE_PREBUILT_LLVM
)
NORMALIZE_BOOL
(
NGRAPH_PLAIDML_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_JSON_ENABLE
)
message
(
STATUS
"NGRAPH_UNIT_TEST_ENABLE:
${
NGRAPH_UNIT_TEST_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_TOOLS_ENABLE:
${
NGRAPH_TOOLS_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_CPU_ENABLE:
${
NGRAPH_CPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_MLIR_ENABLE:
${
NGRAPH_MLIR_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_INTELGPU_ENABLE:
${
NGRAPH_INTELGPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_GPU_ENABLE:
${
NGRAPH_GPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_INTERPRETER_ENABLE:
${
NGRAPH_INTERPRETER_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_NOP_ENABLE:
${
NGRAPH_NOP_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_GPUH_ENABLE:
${
NGRAPH_GPUH_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_GENERIC_CPU_ENABLE:
${
NGRAPH_GENERIC_CPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DEBUG_ENABLE:
${
NGRAPH_DEBUG_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DEPRECATED_ENABLE:
${
NGRAPH_DEPRECATED_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_ONNX_IMPORT_ENABLE:
${
NGRAPH_ONNX_IMPORT_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DEX_ONLY:
${
NGRAPH_DEX_ONLY
}
"
)
message
(
STATUS
"NGRAPH_ENABLE_CPU_CONV_AUTO:
${
NGRAPH_ENABLE_CPU_CONV_AUTO
}
"
)
message
(
STATUS
"NGRAPH_CODE_COVERAGE_ENABLE:
${
NGRAPH_CODE_COVERAGE_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_LIB_VERSIONING_ENABLE:
${
NGRAPH_LIB_VERSIONING_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_PYTHON_BUILD_ENABLE:
${
NGRAPH_PYTHON_BUILD_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_USE_PREBUILT_LLVM:
${
NGRAPH_USE_PREBUILT_LLVM
}
"
)
message
(
STATUS
"NGRAPH_PLAIDML_ENABLE:
${
NGRAPH_PLAIDML_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DISTRIBUTED_ENABLE:
${
NGRAPH_DISTRIBUTED_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_JSON_ENABLE:
${
NGRAPH_JSON_ENABLE
}
"
)
NORMALIZE_BOOL
(
NGRAPH_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_CPU_STATIC_LIB_ENABLE
)
message
(
STATUS
"NGRAPH_UNIT_TEST_ENABLE:
${
NGRAPH_UNIT_TEST_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_TOOLS_ENABLE:
${
NGRAPH_TOOLS_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_CPU_ENABLE:
${
NGRAPH_CPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_MLIR_ENABLE:
${
NGRAPH_MLIR_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_INTELGPU_ENABLE:
${
NGRAPH_INTELGPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_GPU_ENABLE:
${
NGRAPH_GPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_INTERPRETER_ENABLE:
${
NGRAPH_INTERPRETER_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_NOP_ENABLE:
${
NGRAPH_NOP_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_GPUH_ENABLE:
${
NGRAPH_GPUH_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_GENERIC_CPU_ENABLE:
${
NGRAPH_GENERIC_CPU_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DEBUG_ENABLE:
${
NGRAPH_DEBUG_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DEPRECATED_ENABLE:
${
NGRAPH_DEPRECATED_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_ONNX_IMPORT_ENABLE:
${
NGRAPH_ONNX_IMPORT_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DEX_ONLY:
${
NGRAPH_DEX_ONLY
}
"
)
message
(
STATUS
"NGRAPH_ENABLE_CPU_CONV_AUTO:
${
NGRAPH_ENABLE_CPU_CONV_AUTO
}
"
)
message
(
STATUS
"NGRAPH_CODE_COVERAGE_ENABLE:
${
NGRAPH_CODE_COVERAGE_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_LIB_VERSIONING_ENABLE:
${
NGRAPH_LIB_VERSIONING_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_PYTHON_BUILD_ENABLE:
${
NGRAPH_PYTHON_BUILD_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_USE_PREBUILT_LLVM:
${
NGRAPH_USE_PREBUILT_LLVM
}
"
)
message
(
STATUS
"NGRAPH_PLAIDML_ENABLE:
${
NGRAPH_PLAIDML_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DISTRIBUTED_ENABLE:
${
NGRAPH_DISTRIBUTED_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_JSON_ENABLE:
${
NGRAPH_JSON_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_STATIC_LIB_ENABLE:
${
NGRAPH_STATIC_LIB_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_INTERPRETER_STATIC_LIB_ENABLE:
${
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_CPU_STATIC_LIB_ENABLE:
${
NGRAPH_CPU_STATIC_LIB_ENABLE
}
"
)
#-----------------------------------------------------------------------------------------------
# Installation logic...
...
...
src/ngraph/runtime/backend.cpp
View file @
c0ab7d42
...
...
@@ -14,6 +14,12 @@
// limitations under the License.
//*****************************************************************************
#ifdef _WIN32
#include <windows.h>
#elif defined(__linux) || defined(__APPLE__)
#include <dlfcn.h>
#endif
#include <sstream>
#include "ngraph/file_util.hpp"
...
...
@@ -25,6 +31,29 @@
using
namespace
std
;
using
namespace
ngraph
;
std
::
mutex
runtime
::
Backend
::
m_mtx
;
std
::
string
runtime
::
Backend
::
s_backend_shared_library_search_directory
;
// This finds the full path of the containing shared library
static
string
find_my_pathname
()
{
#ifdef _WIN32
HMODULE
hModule
=
GetModuleHandleW
(
L"ngraph.dll"
);
WCHAR
wpath
[
MAX_PATH
];
GetModuleFileNameW
(
hModule
,
wpath
,
MAX_PATH
);
wstring
ws
(
wpath
);
string
path
(
ws
.
begin
(),
ws
.
end
());
replace
(
path
.
begin
(),
path
.
end
(),
'\\'
,
'/'
);
path
=
file_util
::
get_directory
(
path
);
path
+=
"/"
;
return
path
;
#elif defined(__linux) || defined(__APPLE__)
Dl_info
dl_info
;
dladdr
(
reinterpret_cast
<
void
*>
(
find_my_pathname
),
&
dl_info
);
return
dl_info
.
dli_fname
;
#endif
}
runtime
::
Backend
::~
Backend
()
{
}
...
...
@@ -86,6 +115,11 @@ void runtime::Backend::remove_compiled_function(std::shared_ptr<Executable> exec
{
}
std
::
shared_ptr
<
runtime
::
Executable
>
runtime
::
Backend
::
load
(
istream
&
input_stream
)
{
throw
runtime_error
(
"load operation unimplemented."
);
}
bool
runtime
::
Backend
::
is_device_memory
(
void
*
ptr
)
{
// override this method for each supported backend to determine if the passed pointer is in
...
...
@@ -93,9 +127,19 @@ bool runtime::Backend::is_device_memory(void* ptr)
return
false
;
}
std
::
shared_ptr
<
runtime
::
Executable
>
runtime
::
Backend
::
load
(
istream
&
input_stream
)
void
runtime
::
Backend
::
set_backend_shared_library_search_directory
(
const
string
&
path
)
{
throw
runtime_error
(
"load opertion unimplemented."
);
std
::
lock_guard
<
std
::
mutex
>
lock
(
runtime
::
Backend
::
m_mtx
);
s_backend_shared_library_search_directory
=
path
;
}
const
string
&
runtime
::
Backend
::
get_backend_shared_library_search_directory
()
{
if
(
s_backend_shared_library_search_directory
.
empty
())
{
s_backend_shared_library_search_directory
=
find_my_pathname
();
}
return
s_backend_shared_library_search_directory
;
}
bool
runtime
::
Backend
::
set_config
(
const
map
<
string
,
string
>&
config
,
string
&
error
)
...
...
src/ngraph/runtime/backend.hpp
View file @
c0ab7d42
...
...
@@ -17,6 +17,7 @@
#pragma once
#include <memory>
#include <mutex>
#include "ngraph/function.hpp"
#include "ngraph/pass/pass_config.hpp"
...
...
@@ -142,6 +143,18 @@ public:
/// \returns a shared pointer to the op if found, else nullptr
virtual
std
::
shared_ptr
<
ngraph
::
Node
>
get_backend_op
(
const
std
::
string
&
op_name
,
...);
/// \brief Allows sending backend specific configuration. The map contains key, value pairs
/// specific to a particluar backend. The definition of these key, value pairs is
/// defined by each backend.
/// \param config The configuration map sent to the backend
/// \param error An error string describing any error encountered
/// \returns true if the configuration is supported, false otherwise. On false the error
/// parameter value is valid.
virtual
bool
set_config
(
const
std
::
map
<
std
::
string
,
std
::
string
>&
config
,
std
::
string
&
error
);
static
void
set_backend_shared_library_search_directory
(
const
std
::
string
&
path
);
static
const
std
::
string
&
get_backend_shared_library_search_directory
();
/// \brief Returns memory allocator used by backend for host allocations
virtual
Allocator
*
get_host_memory_allocator
()
{
return
nullptr
;
}
/// \brief Set the host memory allocator to be used by the backend
...
...
@@ -159,12 +172,8 @@ public:
/// \param ptr pointer to the memory to determine if its in device memory or not
virtual
bool
is_device_memory
(
void
*
ptr
);
/// \brief Allows sending backend specific configuration. The map contains key, value pairs
/// specific to a particluar backend. The definition of these key, value pairs is
/// defined by each backend.
/// \param config The configuration map sent to the backend
/// \param error An error string describing any error encountered
/// \returns true if the configuration is supported, false otherwise. On false the error
/// parameter value is valid.
virtual
bool
set_config
(
const
std
::
map
<
std
::
string
,
std
::
string
>&
config
,
std
::
string
&
error
);
private
:
// mutex to modify s_backend_shared_library_search_directory thread safe
static
std
::
mutex
m_mtx
;
static
std
::
string
s_backend_shared_library_search_directory
;
};
src/ngraph/runtime/backend_manager.cpp
View file @
c0ab7d42
...
...
@@ -25,6 +25,8 @@
#include "ngraph/file_util.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/cpu/static_initialize.hpp"
#include "ngraph/runtime/interpreter/static_initialize.hpp"
#include "ngraph/util.hpp"
using
namespace
std
;
...
...
@@ -68,6 +70,14 @@ vector<string> runtime::BackendManager::get_registered_backends()
shared_ptr
<
runtime
::
Backend
>
runtime
::
BackendManager
::
create_backend
(
const
std
::
string
&
config
)
{
#ifdef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
runtime
::
interpreter
::
static_initialize
();
#endif
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
runtime
::
cpu
::
static_initialize
();
#endif
shared_ptr
<
runtime
::
Backend
>
backend
;
string
type
=
config
;
...
...
@@ -107,6 +117,7 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
if
(
get_backend_constructor_pointer
)
{
backend
=
get_backend_constructor_pointer
()
->
create
(
config
);
register_backend
(
type
,
get_backend_constructor_pointer
());
}
else
{
...
...
@@ -125,26 +136,6 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
return
backend
;
}
// This doodad finds the full path of the containing shared library
static
string
find_my_file
()
{
#ifdef _WIN32
HMODULE
hModule
=
GetModuleHandleW
(
L"ngraph.dll"
);
WCHAR
wpath
[
MAX_PATH
];
GetModuleFileNameW
(
hModule
,
wpath
,
MAX_PATH
);
wstring
ws
(
wpath
);
string
path
(
ws
.
begin
(),
ws
.
end
());
replace
(
path
.
begin
(),
path
.
end
(),
'\\'
,
'/'
);
path
=
file_util
::
get_directory
(
path
);
path
+=
"/"
;
return
path
;
#else
Dl_info
dl_info
;
dladdr
(
reinterpret_cast
<
void
*>
(
find_my_file
),
&
dl_info
);
return
dl_info
.
dli_fname
;
#endif
}
DL_HANDLE
runtime
::
BackendManager
::
open_shared_library
(
string
type
)
{
string
lib_prefix
=
SHARED_LIB_PREFIX
;
...
...
@@ -160,7 +151,8 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
}
string
library_name
=
lib_prefix
+
to_lower
(
type
)
+
"_backend"
+
lib_suffix
;
string
my_directory
=
file_util
::
get_directory
(
find_my_file
());
string
my_directory
=
file_util
::
get_directory
(
Backend
::
get_backend_shared_library_search_directory
());
string
library_path
=
file_util
::
path_join
(
my_directory
,
library_name
);
string
error
;
#ifdef _WIN32
...
...
@@ -185,7 +177,8 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
map
<
string
,
string
>
runtime
::
BackendManager
::
get_registered_device_map
()
{
map
<
string
,
string
>
rc
;
string
my_directory
=
file_util
::
get_directory
(
find_my_file
());
string
my_directory
=
file_util
::
get_directory
(
Backend
::
get_backend_shared_library_search_directory
());
vector
<
string
>
backend_list
;
auto
f
=
[
&
](
const
string
&
file
,
bool
is_dir
)
{
...
...
src/ngraph/runtime/cpu/CMakeLists.txt
View file @
c0ab7d42
...
...
@@ -16,9 +16,16 @@
include
(
FindOpenMP
)
if
(
NGRAPH_CPU_STATIC_LIB_ENABLE
)
set
(
LIBRARY_TYPE STATIC
)
else
()
set
(
LIBRARY_TYPE SHARED
)
endif
()
set
(
SRC
cpu_backend.cpp
cpu_builder.cpp
cpu_builder_registry.cpp
cpu_call_frame.cpp
cpu_executor.cpp
cpu_external_function.cpp
...
...
@@ -124,7 +131,6 @@ set(SRC
pass/cpu_post_layout_optimizations.cpp
pass/cpu_rnn_fusion.cpp
pass/cpu_workspace_insertion.cpp
ngraph_version.cpp
)
if
(
NOT NGRAPH_DEX_ONLY
)
...
...
@@ -156,7 +162,10 @@ endif()
if
(
NGRAPH_CPU_ENABLE
)
set
(
NGRAPH_CPU_DEBUGINFO_ENABLE 0 CACHE STRING
"Enable debuginfo in the CPU backend"
)
add_library
(
cpu_backend SHARED
${
SRC
}
)
add_library
(
cpu_backend
${
LIBRARY_TYPE
}
${
SRC
}
)
if
(
NGRAPH_CPU_STATIC_LIB_ENABLE
)
target_compile_definitions
(
cpu_backend PRIVATE
"NGRAPH_CPU_STATIC_LIB_ENABLE"
)
endif
()
if
(
NGRAPH_LIB_VERSIONING_ENABLE
)
set_target_properties
(
cpu_backend PROPERTIES
VERSION
${
NGRAPH_VERSION
}
...
...
src/ngraph/runtime/cpu/builder/add.cpp
View file @
c0ab7d42
...
...
@@ -79,6 +79,10 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Add
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_add_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/allreduce.cpp
View file @
c0ab7d42
...
...
@@ -69,6 +69,10 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
AllReduce
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_allreduce_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/argmax.cpp
View file @
c0ab7d42
...
...
@@ -210,6 +210,10 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
ArgMax
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_argmax_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/argmin.cpp
View file @
c0ab7d42
...
...
@@ -210,6 +210,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
ArgMin
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_argmin_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/avg_pool.cpp
View file @
c0ab7d42
...
...
@@ -197,6 +197,10 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
AvgPool
);
REGISTER_OP_BUILDER
(
AvgPoolBackprop
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_avg_pool_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/batch_norm.cpp
View file @
c0ab7d42
...
...
@@ -508,6 +508,10 @@ namespace ngraph
REGISTER_OP_BUILDER
(
BatchNormTrainingRelu
);
REGISTER_OP_BUILDER
(
BatchNormInferenceRelu
);
REGISTER_OP_BUILDER
(
BatchNormTrainingBackprop
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_batch_norm_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/bounded_relu.cpp
View file @
c0ab7d42
...
...
@@ -88,6 +88,9 @@ namespace ngraph
}
}
REGISTER_OP_BUILDER
(
BoundedRelu
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_bounded_relu_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/broadcast.cpp
View file @
c0ab7d42
...
...
@@ -232,6 +232,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Broadcast
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_broadcast_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/broadcast_distributed.cpp
View file @
c0ab7d42
...
...
@@ -44,6 +44,9 @@ namespace ngraph
functors
.
emplace_back
(
functor
);
}
REGISTER_OP_BUILDER
(
BroadcastDistributed
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_broadcast_distributed_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/concat.cpp
View file @
c0ab7d42
...
...
@@ -170,6 +170,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Concat
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_concat_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/convert.cpp
View file @
c0ab7d42
...
...
@@ -115,6 +115,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Convert
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_convert_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/convert_layout.cpp
View file @
c0ab7d42
...
...
@@ -104,6 +104,9 @@ namespace ngraph
functors
.
emplace_back
(
functor
);
}
REGISTER_CPU_OP_BUILDER
(
ConvertLayout
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_convert_layout_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/convolution.cpp
View file @
c0ab7d42
...
...
@@ -832,6 +832,10 @@ namespace ngraph
REGISTER_OP_BUILDER
(
ConvolutionAdd
);
REGISTER_OP_BUILDER
(
GroupConvolutionBias
);
REGISTER_OP_BUILDER
(
DeconvolutionBias
)
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_convolution_cpp
()
{}
#endif
}
// namespace cpu
}
// namespace runtime
}
// namespace ngraph
src/ngraph/runtime/cpu/builder/dot.cpp
View file @
c0ab7d42
...
...
@@ -258,6 +258,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Dot
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_dot_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/dropout.cpp
View file @
c0ab7d42
...
...
@@ -127,6 +127,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Dropout
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_dropout_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/embedding_lookup.cpp
View file @
c0ab7d42
...
...
@@ -245,6 +245,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
EmbeddingLookup
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_embedding_lookup_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/erf.cpp
View file @
c0ab7d42
...
...
@@ -72,6 +72,9 @@ namespace ngraph
}
}
REGISTER_OP_BUILDER
(
Erf
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_erf_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/gather.cpp
View file @
c0ab7d42
...
...
@@ -237,6 +237,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Gather
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_gather_cpp
()
{}
#endif
}
// namespace cpu
}
// namespace runtime
}
// namespace ngraph
src/ngraph/runtime/cpu/builder/gather_nd.cpp
View file @
c0ab7d42
...
...
@@ -139,6 +139,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
GatherND
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_gather_nd_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/get_output_element.cpp
View file @
c0ab7d42
...
...
@@ -48,6 +48,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
GetOutputElement
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_get_output_element_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/leaky_relu.cpp
View file @
c0ab7d42
...
...
@@ -86,6 +86,9 @@ namespace ngraph
}
}
REGISTER_OP_BUILDER
(
CPULeakyRelu
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_leaky_relu_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/lrn.cpp
View file @
c0ab7d42
...
...
@@ -123,6 +123,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
LRN
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_lrn_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/lstm.cpp
View file @
c0ab7d42
...
...
@@ -108,6 +108,9 @@ namespace ngraph
functors
.
emplace_back
(
functor
);
}
REGISTER_OP_BUILDER
(
Lstm
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_lstm_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/matmul_bias.cpp
View file @
c0ab7d42
...
...
@@ -396,6 +396,9 @@ namespace ngraph
REGISTER_OP_BUILDER
(
MatmulBias
);
REGISTER_OP_BUILDER
(
BatchMatMul
);
REGISTER_OP_BUILDER
(
BatchMatMulTranspose
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_matmul_bias_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/max.cpp
View file @
c0ab7d42
...
...
@@ -38,6 +38,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Max
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_max_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/max_pool.cpp
View file @
c0ab7d42
...
...
@@ -337,6 +337,9 @@ namespace ngraph
REGISTER_OP_BUILDER
(
MaxPoolBackprop
);
REGISTER_OP_BUILDER
(
MaxPoolWithIndices
);
REGISTER_OP_BUILDER
(
MaxPoolWithIndicesBackprop
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_max_pool_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/min.cpp
View file @
c0ab7d42
...
...
@@ -38,6 +38,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Min
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_min_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/one_hot.cpp
View file @
c0ab7d42
...
...
@@ -109,6 +109,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
OneHot
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_one_hot_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/pad.cpp
View file @
c0ab7d42
...
...
@@ -171,6 +171,9 @@ namespace ngraph
}
}
REGISTER_CF_BUILDER
(
Pad
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_pad_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/product.cpp
View file @
c0ab7d42
...
...
@@ -38,6 +38,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Product
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_product_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/quantization.cpp
View file @
c0ab7d42
...
...
@@ -585,6 +585,9 @@ namespace ngraph
REGISTER_OP_BUILDER
(
Dequantize
);
REGISTER_OP_BUILDER
(
Quantize
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_quantization_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/quantized_avg_pool.cpp
View file @
c0ab7d42
...
...
@@ -69,6 +69,9 @@ namespace ngraph
}
}
REGISTER_OP_BUILDER
(
QuantizedAvgPool
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_quantized_avg_pool_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/quantized_conv.cpp
View file @
c0ab7d42
...
...
@@ -708,6 +708,9 @@ namespace ngraph
REGISTER_OP_BUILDER
(
QuantizedConvolutionBias
);
REGISTER_OP_BUILDER
(
QuantizedConvolutionBiasAdd
);
REGISTER_OP_BUILDER
(
QuantizedConvolutionBiasSignedAdd
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_quantized_conv_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/quantized_dot.cpp
View file @
c0ab7d42
...
...
@@ -163,6 +163,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
QuantizedDotBias
);
REGISTER_OP_BUILDER
(
QuantizedDot
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_quantized_dot_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/quantized_matmul.cpp
View file @
c0ab7d42
...
...
@@ -103,6 +103,9 @@ namespace ngraph
}
}
REGISTER_OP_BUILDER
(
QuantizedMatmul
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_quantized_matmul_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/reduce_function.cpp
View file @
c0ab7d42
...
...
@@ -84,6 +84,9 @@ namespace ngraph
REGISTER_OP_BUILDER
(
Any
);
REGISTER_OP_BUILDER
(
All
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_reduce_function_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/relu.cpp
View file @
c0ab7d42
...
...
@@ -134,6 +134,9 @@ namespace ngraph
REGISTER_OP_BUILDER
(
Relu
);
REGISTER_OP_BUILDER
(
ReluBackprop
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_relu_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/replace_slice.cpp
View file @
c0ab7d42
...
...
@@ -135,6 +135,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
ReplaceSlice
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_replace_slice_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/reshape.cpp
View file @
c0ab7d42
...
...
@@ -248,6 +248,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Reshape
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_reshape_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/reverse.cpp
View file @
c0ab7d42
...
...
@@ -63,6 +63,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Reverse
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_reverse_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/reverse_sequence.cpp
View file @
c0ab7d42
...
...
@@ -80,6 +80,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
ReverseSequence
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_reverse_sequence_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/rnn.cpp
View file @
c0ab7d42
...
...
@@ -103,6 +103,9 @@ namespace ngraph
functors
.
emplace_back
(
functor
);
}
REGISTER_OP_BUILDER
(
Rnn
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_rnn_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/scatter_add.cpp
View file @
c0ab7d42
...
...
@@ -140,6 +140,9 @@ namespace ngraph
}
}
REGISTER_OP_BUILDER
(
ScatterAdd
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_scatter_add_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/scatter_nd_add.cpp
View file @
c0ab7d42
...
...
@@ -157,6 +157,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
ScatterNDAdd
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_scatter_nd_add_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/select.cpp
View file @
c0ab7d42
...
...
@@ -63,6 +63,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Select
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_select_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/sigmoid.cpp
View file @
c0ab7d42
...
...
@@ -189,6 +189,9 @@ namespace ngraph
REGISTER_OP_BUILDER
(
SigmoidBackprop
);
REGISTER_OP_BUILDER
(
SigmoidMultiply
);
REGISTER_OP_BUILDER
(
SigmoidMultiplyBackprop
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_sigmoid_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/slice.cpp
View file @
c0ab7d42
...
...
@@ -188,6 +188,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Slice
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_slice_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/softmax.cpp
View file @
c0ab7d42
...
...
@@ -196,6 +196,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Softmax
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_softmax_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/state.cpp
View file @
c0ab7d42
...
...
@@ -140,6 +140,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
GenerateMask
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_state_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/sum.cpp
View file @
c0ab7d42
...
...
@@ -38,6 +38,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Sum
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_sum_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/tile.cpp
View file @
c0ab7d42
...
...
@@ -76,6 +76,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
Tile
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_tile_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/topk.cpp
View file @
c0ab7d42
...
...
@@ -161,6 +161,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
TopK
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_topk_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/builder/update_slice.cpp
View file @
c0ab7d42
...
...
@@ -125,6 +125,9 @@ namespace ngraph
}
REGISTER_OP_BUILDER
(
UpdateSlice
);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void
register_builders_update_slice_cpp
()
{}
#endif
}
}
}
src/ngraph/runtime/cpu/cpu_backend.cpp
View file @
c0ab7d42
...
...
@@ -23,6 +23,7 @@
#include "ngraph/runtime/cpu/cpu_call_frame.hpp"
#include "ngraph/runtime/cpu/cpu_external_function.hpp"
#include "ngraph/runtime/cpu/cpu_tensor_view.hpp"
#include "ngraph/runtime/cpu/static_initialize.hpp"
#include "ngraph/util.hpp"
#ifdef NGRAPH_MLIR_ENABLE
...
...
@@ -32,7 +33,7 @@
using
namespace
ngraph
;
using
namespace
std
;
extern
"C"
runtime
::
BackendConstructor
*
get_backend_constructor_pointer
()
runtime
::
BackendConstructor
*
runtime
::
cpu
::
get_backend_constructor_pointer
()
{
class
CPU_BackendConstructor
:
public
runtime
::
BackendConstructor
{
...
...
@@ -50,6 +51,23 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
return
s_backend_constructor
.
get
();
}
#if !defined(NGRAPH_CPU_STATIC_LIB_ENABLE)
extern
"C"
runtime
::
BackendConstructor
*
get_backend_constructor_pointer
()
{
return
runtime
::
cpu
::
get_backend_constructor_pointer
();
}
#endif
void
runtime
::
cpu
::
static_initialize
()
{
static
bool
s_is_initialized
=
false
;
if
(
!
s_is_initialized
)
{
s_is_initialized
=
true
;
BackendManager
::
register_backend
(
"CPU"
,
runtime
::
cpu
::
get_backend_constructor_pointer
());
}
}
namespace
{
static
class
CPUStaticInit
...
...
@@ -57,7 +75,8 @@ namespace
public
:
CPUStaticInit
()
{
runtime
::
BackendManager
::
register_backend
(
"CPU"
,
get_backend_constructor_pointer
());
runtime
::
BackendManager
::
register_backend
(
"CPU"
,
runtime
::
cpu
::
get_backend_constructor_pointer
());
}
~
CPUStaticInit
()
{}
}
s_cpu_static_init
;
...
...
src/ngraph/runtime/cpu/cpu_backend.hpp
View file @
c0ab7d42
...
...
@@ -24,6 +24,7 @@
#include "ngraph/pass/pass_config.hpp"
#include "ngraph/runtime/allocator.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp"
namespace
ngraph
{
...
...
@@ -33,7 +34,7 @@ namespace ngraph
{
class
CPU_ExternalFunction
;
class
CPU_CallFrame
;
BackendConstructor
*
get_backend_constructor_pointer
();
class
CPU_BACKEND_API
CPU_Backend
:
public
runtime
::
Backend
{
public
:
...
...
src/ngraph/runtime/cpu/cpu_builder.cpp
View file @
c0ab7d42
...
...
@@ -65,6 +65,7 @@
#include "ngraph/op/subtract.hpp"
#include "ngraph/op/tan.hpp"
#include "ngraph/op/tanh.hpp"
#include "ngraph/runtime/cpu/cpu_builder_registry.hpp"
#include "ngraph/runtime/cpu/cpu_kernels.hpp"
#include "ngraph/runtime/cpu/cpu_op_annotations.hpp"
#include "ngraph/runtime/cpu/kernel/abs.hpp"
...
...
src/ngraph/runtime/cpu/cpu_builder_registry.cpp
0 → 100644
View file @
c0ab7d42
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "ngraph/runtime/cpu/cpu_builder_registry.hpp"
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
void
register_builders
()
{
register_builders_add_cpp
();
register_builders_allreduce_cpp
();
register_builders_argmax_cpp
();
register_builders_argmin_cpp
();
register_builders_avg_pool_cpp
();
register_builders_batch_norm_cpp
();
register_builders_bounded_relu_cpp
();
register_builders_broadcast_cpp
();
register_builders_broadcast_distributed_cpp
();
register_builders_concat_cpp
();
register_builders_convert_cpp
();
register_builders_convert_layout_cpp
();
register_builders_convolution_cpp
();
register_builders_dot_cpp
();
register_builders_dropout_cpp
();
register_builders_embedding_lookup_cpp
();
register_builders_erf_cpp
();
register_builders_gather_cpp
();
register_builders_gather_nd_cpp
();
register_builders_get_output_element_cpp
();
register_builders_leaky_relu_cpp
();
register_builders_lrn_cpp
();
register_builders_lstm_cpp
();
register_builders_matmul_bias_cpp
();
register_builders_max_cpp
();
register_builders_max_pool_cpp
();
register_builders_min_cpp
();
register_builders_one_hot_cpp
();
register_builders_pad_cpp
();
register_builders_product_cpp
();
register_builders_quantization_cpp
();
register_builders_quantized_avg_pool_cpp
();
register_builders_quantized_conv_cpp
();
register_builders_quantized_dot_cpp
();
register_builders_quantized_matmul_cpp
();
register_builders_reduce_function_cpp
();
register_builders_relu_cpp
();
register_builders_replace_slice_cpp
();
register_builders_reshape_cpp
();
register_builders_reverse_cpp
();
register_builders_reverse_sequence_cpp
();
register_builders_rnn_cpp
();
register_builders_scatter_add_cpp
();
register_builders_scatter_nd_add_cpp
();
register_builders_select_cpp
();
register_builders_state_cpp
();
register_builders_sigmoid_cpp
();
register_builders_slice_cpp
();
register_builders_softmax_cpp
();
register_builders_sum_cpp
();
register_builders_tile_cpp
();
register_builders_topk_cpp
();
register_builders_update_slice_cpp
();
}
}
}
}
#endif
src/ngraph/runtime/cpu/cpu_builder_registry.hpp
0 → 100644
View file @
c0ab7d42
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
namespace
ngraph
{
namespace
runtime
{
namespace
cpu
{
void
register_builders
();
void
register_builders_add_cpp
();
void
register_builders_allreduce_cpp
();
void
register_builders_argmax_cpp
();
void
register_builders_argmin_cpp
();
void
register_builders_avg_pool_cpp
();
void
register_builders_batch_norm_cpp
();
void
register_builders_bounded_relu_cpp
();
void
register_builders_broadcast_cpp
();
void
register_builders_broadcast_distributed_cpp
();
void
register_builders_concat_cpp
();
void
register_builders_convert_cpp
();
void
register_builders_convert_layout_cpp
();
void
register_builders_convolution_cpp
();
void
register_builders_dot_cpp
();
void
register_builders_dropout_cpp
();
void
register_builders_embedding_lookup_cpp
();
void
register_builders_erf_cpp
();
void
register_builders_gather_cpp
();
void
register_builders_gather_nd_cpp
();
void
register_builders_get_output_element_cpp
();
void
register_builders_leaky_relu_cpp
();
void
register_builders_lrn_cpp
();
void
register_builders_lstm_cpp
();
void
register_builders_matmul_bias_cpp
();
void
register_builders_max_cpp
();
void
register_builders_max_pool_cpp
();
void
register_builders_min_cpp
();
void
register_builders_one_hot_cpp
();
void
register_builders_pad_cpp
();
void
register_builders_product_cpp
();
void
register_builders_quantization_cpp
();
void
register_builders_quantized_avg_pool_cpp
();
void
register_builders_quantized_conv_cpp
();
void
register_builders_quantized_dot_cpp
();
void
register_builders_quantized_matmul_cpp
();
void
register_builders_reduce_function_cpp
();
void
register_builders_relu_cpp
();
void
register_builders_replace_slice_cpp
();
void
register_builders_reshape_cpp
();
void
register_builders_reverse_cpp
();
void
register_builders_reverse_sequence_cpp
();
void
register_builders_rnn_cpp
();
void
register_builders_scatter_add_cpp
();
void
register_builders_scatter_nd_add_cpp
();
void
register_builders_select_cpp
();
void
register_builders_state_cpp
();
void
register_builders_sigmoid_cpp
();
void
register_builders_slice_cpp
();
void
register_builders_softmax_cpp
();
void
register_builders_sum_cpp
();
void
register_builders_tile_cpp
();
void
register_builders_topk_cpp
();
void
register_builders_update_slice_cpp
();
}
}
}
#endif
src/ngraph/runtime/cpu/cpu_external_function.cpp
View file @
c0ab7d42
...
...
@@ -156,6 +156,7 @@
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/runtime/cpu/cpu_backend.hpp"
#include "ngraph/runtime/cpu/cpu_builder.hpp"
#include "ngraph/runtime/cpu/cpu_builder_registry.hpp"
#include "ngraph/runtime/cpu/cpu_call_frame.hpp"
#include "ngraph/runtime/cpu/cpu_cse.hpp"
#include "ngraph/runtime/cpu/cpu_emitter.hpp"
...
...
@@ -1354,6 +1355,11 @@ void runtime::cpu::CPU_ExternalFunction::build(ngraph::pass::PassConfig& pass_co
"enabled due to concurrent graph execution"
);
}
// reference all the builders for static library
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
ngraph
::
runtime
::
cpu
::
register_builders
();
#endif
// stream writer to dump the debug manifest for the DEX
static
const
string
s_debug_dir
=
"cpu_codegen"
;
static
StaticInitializers
s_static_initializers
(
s_debug_dir
);
...
...
src/ngraph/runtime/cpu/
ngraph_version.c
pp
→
src/ngraph/runtime/cpu/
static_initialize.h
pp
View file @
c0ab7d42
...
...
@@ -13,9 +13,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include "cpu_backend_visibility.h"
extern
"C"
CPU_BACKEND_API
const
char
*
get_ngraph_version_string
()
#pragma once
namespace
ngraph
{
return
NGRAPH_VERSION
;
namespace
runtime
{
namespace
cpu
{
void
static_initialize
();
}
}
}
src/ngraph/runtime/interpreter/CMakeLists.txt
View file @
c0ab7d42
...
...
@@ -14,15 +14,23 @@
# limitations under the License.
# ******************************************************************************
if
(
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
)
set
(
LIBRARY_TYPE STATIC
)
else
()
set
(
LIBRARY_TYPE SHARED
)
endif
()
if
(
NGRAPH_INTERPRETER_ENABLE
)
add_library
(
interpreter_backend
SHARED
int_backend.cpp node_wrapper.cpp int_executable.cpp
)
add_library
(
interpreter_backend
${
LIBRARY_TYPE
}
int_backend.cpp node_wrapper.cpp int_executable.cpp
)
if
(
NGRAPH_LIB_VERSIONING_ENABLE
)
set_target_properties
(
interpreter_backend PROPERTIES
VERSION
${
NGRAPH_VERSION
}
SOVERSION
${
NGRAPH_API_VERSION
}
)
endif
()
target_link_libraries
(
interpreter_backend PUBLIC ngraph
)
if
(
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
)
target_compile_definitions
(
interpreter_backend PUBLIC NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
)
endif
()
install
(
TARGETS interpreter_backend
LIBRARY DESTINATION
"
${
NGRAPH_INSTALL_LIB
}
"
ARCHIVE DESTINATION
"
${
NGRAPH_INSTALL_LIB
}
"
...
...
src/ngraph/runtime/interpreter/int_backend.cpp
View file @
c0ab7d42
...
...
@@ -20,13 +20,14 @@
#include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/interpreter/int_executable.hpp"
#include "ngraph/runtime/interpreter/static_initialize.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
using
namespace
std
;
using
namespace
ngraph
;
extern
"C"
runtime
::
BackendConstructor
*
get_backend_constructor_pointer
()
runtime
::
BackendConstructor
*
runtime
::
interpreter
::
get_backend_constructor_pointer
()
{
class
INTBackendConstructor
:
public
runtime
::
BackendConstructor
{
...
...
@@ -42,6 +43,24 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
return
s_backend_constructor
.
get
();
}
#ifndef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
extern
"C"
runtime
::
BackendConstructor
*
get_backend_constructor_pointer
()
{
return
runtime
::
interpreter
::
get_backend_constructor_pointer
();
}
#endif
void
runtime
::
interpreter
::
static_initialize
()
{
static
bool
s_is_initialized
=
false
;
if
(
!
s_is_initialized
)
{
s_is_initialized
=
true
;
BackendManager
::
register_backend
(
"INTERPRETER"
,
runtime
::
interpreter
::
get_backend_constructor_pointer
());
}
}
runtime
::
interpreter
::
INTBackend
::
INTBackend
()
{
}
...
...
src/ngraph/runtime/interpreter/int_backend.hpp
View file @
c0ab7d42
...
...
@@ -34,6 +34,7 @@ namespace ngraph
class
INTBackend
;
class
INTExecutable
;
class
INTBackendConstructor
;
BackendConstructor
*
get_backend_constructor_pointer
();
}
}
}
...
...
src/ngraph/runtime/interpreter/static_initialize.hpp
0 → 100644
View file @
c0ab7d42
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
namespace
ngraph
{
namespace
runtime
{
namespace
interpreter
{
void
static_initialize
();
}
}
}
src/tools/nbench/nbench.cpp
View file @
c0ab7d42
...
...
@@ -34,12 +34,22 @@
#include "ngraph/pass/memory_layout.hpp"
#include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/interpreter/int_backend.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
using
namespace
std
;
using
namespace
ngraph
;
static
void
configure_static_backends
()
{
#ifdef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
ngraph
::
runtime
::
BackendManager
::
register_backend
(
"INTERPRETER"
,
ngraph
::
runtime
::
interpreter
::
get_backend_constructor_pointer
());
#endif
}
class
PerfShape
:
public
ngraph
::
runtime
::
PerformanceCounter
{
public
:
...
...
@@ -184,6 +194,7 @@ int main(int argc, char** argv)
bool
dot_file
=
false
;
bool
double_buffer
=
false
;
configure_static_backends
();
for
(
size_t
i
=
1
;
i
<
argc
;
i
++
)
{
string
arg
=
argv
[
i
];
...
...
test/main.cpp
View file @
c0ab7d42
...
...
@@ -19,11 +19,22 @@
#include "gtest/gtest.h"
#include "ngraph/log.hpp"
#include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/interpreter/int_backend.hpp"
using
namespace
std
;
static
void
configure_static_backends
()
{
#ifdef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
ngraph
::
runtime
::
BackendManager
::
register_backend
(
"INTERPRETER"
,
ngraph
::
runtime
::
interpreter
::
get_backend_constructor_pointer
());
#endif
}
int
main
(
int
argc
,
char
**
argv
)
{
configure_static_backends
();
const
char
*
exclude
=
"--gtest_filter=-benchmark.*"
;
vector
<
char
*>
argv_vector
;
argv_vector
.
push_back
(
argv
[
0
]);
...
...
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