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
ff87e2e4
Commit
ff87e2e4
authored
Nov 07, 2017
by
Yixing Lao
Committed by
Yixing Lao
Nov 08, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
addresses review issues
parent
6fe8f8e5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
21 deletions
+18
-21
CMakeLists.txt
src/ngraph/CMakeLists.txt
+6
-4
manager.cpp
src/ngraph/runtime/manager.cpp
+10
-15
manager.hpp
src/ngraph/runtime/manager.hpp
+2
-2
No files found.
src/ngraph/CMakeLists.txt
View file @
ff87e2e4
...
...
@@ -135,7 +135,7 @@ add_library(ngraph SHARED ${SRC})
# plugin is specified at compile time but the corresponding library could not be resolved at run-
# time, an error will be generated.
# E.g. assume compiling with Argon and Xpu, then -DRUNTIME_PLUGIN_LIBS="libargon.so:libxpu.so".
if
(
RUNTIME_PLUGIN_LIBS
)
if
(
DEFINED
RUNTIME_PLUGIN_LIBS
)
target_compile_definitions
(
ngraph PRIVATE RUNTIME_PLUGIN_LIBS=
${
RUNTIME_PLUGIN_LIBS
}
)
else
()
target_compile_definitions
(
ngraph PRIVATE RUNTIME_PLUGIN_LIBS=
""
)
...
...
@@ -143,13 +143,15 @@ endif()
# This is used to ensure that libngraph.so and libargon.so are in the same directory for dlopen.
# Effective at build time. Does not affect `make install` logics.
if
(
COMMON_LIBRARY_OUTPUT_DIRECTORY
)
if
(
DEFINED
COMMON_LIBRARY_OUTPUT_DIRECTORY
)
set_target_properties
(
ngraph PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
${
COMMON_LIBRARY_OUTPUT_DIRECTORY
}
)
message
(
STATUS
"LIBRARY_OUTPUT_DIRECTORY set to:
${
COMMON_LIBRARY_OUTPUT_DIRECTORY
}
"
)
else
()
message
(
STATUS
"LIBRARY_OUTPUT_DIRECTORY not set, will use the defualt value"
)
set_target_properties
(
ngraph PROPERTIES
LIBRARY_OUTPUT_DIRECTORY
${
CMAKE_CURRENT_BINARY_DIR
}
)
endif
()
message
(
STATUS
"LIBRARY_OUTPUT_DIRECTORY set to:
${
COMMON_LIBRARY_OUTPUT_DIRECTORY
}
"
)
target_include_directories
(
ngraph PUBLIC
"
${
NGRAPH_INCLUDE_PATH
}
"
)
...
...
src/ngraph/runtime/manager.cpp
View file @
ff87e2e4
...
...
@@ -12,20 +12,23 @@
// See the License for the specific language governing permissions and
// ----------------------------------------------------------------------------
#include "ngraph/runtime/manager.hpp"
#include <dlfcn.h>
#include <iostream>
#include <sstream>
#include <string>
#include "ngraph/runtime/manager.hpp"
#include "ngraph/util.hpp"
using
namespace
ngraph
::
runtime
;
bool
Manager
::
load_plugins
(
const
std
::
string
&
runtime_plugin_libs
)
bool
Manager
::
m_is_factory_map_initialized
=
false
;
void
Manager
::
load_plugins
(
const
std
::
string
&
runtime_plugin_libs
)
{
std
::
istringstream
ss
(
runtime_plugin_libs
);
std
::
string
plugin_lib_path
;
std
::
vector
<
std
::
string
>
plugin_lib_paths
=
ngraph
::
split
(
runtime_plugin_libs
,
':'
,
false
);
while
(
std
::
getline
(
ss
,
plugin_lib_path
,
':'
)
)
for
(
auto
plugin_lib_path
:
plugin_lib_paths
)
{
if
(
plugin_lib_path
.
size
()
>
0
)
{
...
...
@@ -34,7 +37,6 @@ bool Manager::load_plugins(const std::string& runtime_plugin_libs)
{
std
::
cerr
<<
"Cannot open library: "
<<
plugin_lib_path
<<
", "
<<
dlerror
()
<<
std
::
endl
;
return
false
;
}
else
{
...
...
@@ -42,7 +44,6 @@ bool Manager::load_plugins(const std::string& runtime_plugin_libs)
}
}
}
return
true
;
}
Manager
::
FactoryMap
&
Manager
::
get_factory_map
()
...
...
@@ -53,11 +54,7 @@ Manager::FactoryMap& Manager::get_factory_map()
// Try to load runtime plugins
if
(
!
Manager
::
m_is_factory_map_initialized
)
{
if
(
!
Manager
::
load_plugins
(
RUNTIME_PLUGIN_LIBS
))
{
std
::
cerr
<<
"Failed to load at least one of the following libraries: "
<<
RUNTIME_PLUGIN_LIBS
<<
std
::
endl
;
}
Manager
::
load_plugins
(
RUNTIME_PLUGIN_LIBS
);
Manager
::
m_is_factory_map_initialized
=
true
;
}
return
factory_map
;
...
...
@@ -68,10 +65,8 @@ std::shared_ptr<Manager> Manager::get(const std::string& name)
return
get_factory_map
().
at
(
name
)(
name
);
}
Manager
::
Factory
Manager
::
register_factory
(
std
::
string
name
,
Factory
factory
)
Manager
::
Factory
Manager
::
register_factory
(
const
std
::
string
&
name
,
Factory
factory
)
{
get_factory_map
()[
name
]
=
factory
;
return
factory
;
}
bool
Manager
::
m_is_factory_map_initialized
=
false
;
src/ngraph/runtime/manager.hpp
View file @
ff87e2e4
...
...
@@ -49,10 +49,10 @@ namespace ngraph
static
std
::
shared_ptr
<
Manager
>
get
(
const
std
::
string
&
name
);
static
Factory
register_factory
(
std
::
string
name
,
Factory
factory
);
static
Factory
register_factory
(
const
std
::
string
&
name
,
Factory
factory
);
private
:
static
bool
load_plugins
(
const
std
::
string
&
runtime_plugin_libs
);
static
void
load_plugins
(
const
std
::
string
&
runtime_plugin_libs
);
static
bool
m_is_factory_map_initialized
;
...
...
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