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
c3b53e5d
Unverified
Commit
c3b53e5d
authored
Aug 19, 2019
by
Scott Cyphers
Committed by
GitHub
Aug 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cyphers/mdynamic (#3463)
* Separate dynamic loading from static linking * Missed find_my_pathname
parent
fe81964d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
CMakeLists.txt
CMakeLists.txt
+7
-0
backend.cpp
src/ngraph/runtime/backend.cpp
+3
-3
backend_manager.cpp
src/ngraph/runtime/backend_manager.cpp
+6
-6
No files found.
CMakeLists.txt
View file @
c3b53e5d
...
@@ -185,6 +185,7 @@ option(NGRAPH_JSON_ENABLE "Enable JSON based serialization and tracing features"
...
@@ -185,6 +185,7 @@ option(NGRAPH_JSON_ENABLE "Enable JSON based serialization and tracing features"
option
(
NGRAPH_STATIC_LIB_ENABLE
"Enable build nGraph static library"
FALSE
)
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_INTERPRETER_STATIC_LIB_ENABLE
"Enable build INTERPRETER backend static library"
FALSE
)
option
(
NGRAPH_CPU_STATIC_LIB_ENABLE
"Enable build CPU backend static library"
FALSE
)
option
(
NGRAPH_CPU_STATIC_LIB_ENABLE
"Enable build CPU backend static library"
FALSE
)
option
(
NGRAPH_DYNAMIC_COMPONENTS_ENABLE
"Enable dynamic loading of components"
TRUE
)
if
(
NGRAPH_CPU_ENABLE
if
(
NGRAPH_CPU_ENABLE
AND
AND
...
@@ -263,6 +264,7 @@ NORMALIZE_BOOL(NGRAPH_JSON_ENABLE)
...
@@ -263,6 +264,7 @@ NORMALIZE_BOOL(NGRAPH_JSON_ENABLE)
NORMALIZE_BOOL
(
NGRAPH_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_CPU_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_CPU_STATIC_LIB_ENABLE
)
NORMALIZE_BOOL
(
NGRAPH_DYNAMIC_COMPONENTS_ENABLE
)
message
(
STATUS
"NGRAPH_UNIT_TEST_ENABLE:
${
NGRAPH_UNIT_TEST_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_UNIT_TEST_ENABLE:
${
NGRAPH_UNIT_TEST_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_TOOLS_ENABLE:
${
NGRAPH_TOOLS_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_TOOLS_ENABLE:
${
NGRAPH_TOOLS_ENABLE
}
"
)
...
@@ -289,6 +291,7 @@ message(STATUS "NGRAPH_JSON_ENABLE: ${NGRAPH_JSON_ENABLE}")
...
@@ -289,6 +291,7 @@ message(STATUS "NGRAPH_JSON_ENABLE: ${NGRAPH_JSON_ENABLE}")
message
(
STATUS
"NGRAPH_STATIC_LIB_ENABLE:
${
NGRAPH_STATIC_LIB_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_INTERPRETER_STATIC_LIB_ENABLE:
${
NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_CPU_STATIC_LIB_ENABLE:
${
NGRAPH_CPU_STATIC_LIB_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_CPU_STATIC_LIB_ENABLE:
${
NGRAPH_CPU_STATIC_LIB_ENABLE
}
"
)
message
(
STATUS
"NGRAPH_DYNAMIC_COMPONENTS_ENABLE:
${
NGRAPH_DYNAMIC_COMPONENTS_ENABLE
}
"
)
#-----------------------------------------------------------------------------------------------
#-----------------------------------------------------------------------------------------------
# Installation logic...
# Installation logic...
...
@@ -402,6 +405,10 @@ if (NGRAPH_STATIC_LIB_ENABLE)
...
@@ -402,6 +405,10 @@ if (NGRAPH_STATIC_LIB_ENABLE)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNGRAPH_STATIC_LIB_ENABLE"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNGRAPH_STATIC_LIB_ENABLE"
)
endif
()
endif
()
if
(
NGRAPH_DYNAMIC_COMPONENTS_ENABLE
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-DNGRAPH_DYNAMIC_COMPONENTS_ENABLE"
)
endif
()
if
(
NGRAPH_PLAIDML_ENABLE
)
if
(
NGRAPH_PLAIDML_ENABLE
)
find_package
(
PlaidML CONFIG
)
find_package
(
PlaidML CONFIG
)
if
(
NOT PLAIDML_FOUND
)
if
(
NOT PLAIDML_FOUND
)
...
...
src/ngraph/runtime/backend.cpp
View file @
c3b53e5d
...
@@ -37,9 +37,7 @@ std::string runtime::Backend::s_backend_shared_library_search_directory;
...
@@ -37,9 +37,7 @@ std::string runtime::Backend::s_backend_shared_library_search_directory;
// This finds the full path of the containing shared library
// This finds the full path of the containing shared library
static
string
find_my_pathname
()
static
string
find_my_pathname
()
{
{
#ifdef NGRAPH_STATIC_LIB_ENABLE
#ifdef NGRAPH_DYNAMIC_COMPONENTS_ENABLE
return
""
;
#else
#ifdef _WIN32
#ifdef _WIN32
HMODULE
hModule
=
GetModuleHandleW
(
L"ngraph.dll"
);
HMODULE
hModule
=
GetModuleHandleW
(
L"ngraph.dll"
);
WCHAR
wpath
[
MAX_PATH
];
WCHAR
wpath
[
MAX_PATH
];
...
@@ -55,6 +53,8 @@ static string find_my_pathname()
...
@@ -55,6 +53,8 @@ static string find_my_pathname()
dladdr
(
reinterpret_cast
<
void
*>
(
find_my_pathname
),
&
dl_info
);
dladdr
(
reinterpret_cast
<
void
*>
(
find_my_pathname
),
&
dl_info
);
return
dl_info
.
dli_fname
;
return
dl_info
.
dli_fname
;
#endif
#endif
#else
return
""
;
#endif
#endif
}
}
...
...
src/ngraph/runtime/backend_manager.cpp
View file @
c3b53e5d
...
@@ -32,9 +32,7 @@
...
@@ -32,9 +32,7 @@
using
namespace
std
;
using
namespace
std
;
using
namespace
ngraph
;
using
namespace
ngraph
;
#ifdef NGRAPH_STATIC_LIB_ENABLE
#ifdef NGRAPH_DYNAMIC_COMPONENTS_ENABLE
#define DLERROR() ""
#else
#ifdef _WIN32
#ifdef _WIN32
#define CLOSE_LIBRARY(a) FreeLibrary(a)
#define CLOSE_LIBRARY(a) FreeLibrary(a)
#define DLSYM(a, b) GetProcAddress(a, b)
#define DLSYM(a, b) GetProcAddress(a, b)
...
@@ -44,6 +42,8 @@ using namespace ngraph;
...
@@ -44,6 +42,8 @@ using namespace ngraph;
#define DLSYM(a, b) dlsym(a, b)
#define DLSYM(a, b) dlsym(a, b)
#define DLERROR() dlerror()
#define DLERROR() dlerror()
#endif
#endif
#else
#define DLERROR() ""
#endif
#endif
unordered_map
<
string
,
runtime
::
BackendConstructor
*>&
runtime
::
BackendManager
::
get_registry
()
unordered_map
<
string
,
runtime
::
BackendConstructor
*>&
runtime
::
BackendManager
::
get_registry
()
...
@@ -107,7 +107,7 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
...
@@ -107,7 +107,7 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
}
}
else
else
{
{
#if
ndef NGRAPH_STATIC_LIB
_ENABLE
#if
def NGRAPH_DYNAMIC_COMPONENTS
_ENABLE
DL_HANDLE
handle
=
open_shared_library
(
type
);
DL_HANDLE
handle
=
open_shared_library
(
type
);
if
(
!
handle
)
if
(
!
handle
)
{
{
...
@@ -153,7 +153,7 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
...
@@ -153,7 +153,7 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
string
lib_suffix
=
SHARED_LIB_SUFFIX
;
string
lib_suffix
=
SHARED_LIB_SUFFIX
;
DL_HANDLE
handle
=
nullptr
;
DL_HANDLE
handle
=
nullptr
;
#if
ndef NGRAPH_STATIC_LIB
_ENABLE
#if
def NGRAPH_DYNAMIC_COMPONENTS
_ENABLE
// strip off attributes, IE:CPU becomes IE
// strip off attributes, IE:CPU becomes IE
auto
colon
=
type
.
find
(
":"
);
auto
colon
=
type
.
find
(
":"
);
...
@@ -190,7 +190,7 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
...
@@ -190,7 +190,7 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
map
<
string
,
string
>
runtime
::
BackendManager
::
get_registered_device_map
()
map
<
string
,
string
>
runtime
::
BackendManager
::
get_registered_device_map
()
{
{
map
<
string
,
string
>
rc
;
map
<
string
,
string
>
rc
;
#if
ndef NGRAPH_STATIC_LIB
_ENABLE
#if
def NGRAPH_DYNAMIC_COMPONENTS
_ENABLE
string
my_directory
=
string
my_directory
=
file_util
::
get_directory
(
Backend
::
get_backend_shared_library_search_directory
());
file_util
::
get_directory
(
Backend
::
get_backend_shared_library_search_directory
());
vector
<
string
>
backend_list
;
vector
<
string
>
backend_list
;
...
...
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