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
c2cb1146
Commit
c2cb1146
authored
Nov 07, 2017
by
Yixing Lao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
throw error if dlopen failed, add close_plugins method
parent
ff87e2e4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
4 deletions
+21
-4
manager.cpp
src/ngraph/runtime/manager.cpp
+16
-4
manager.hpp
src/ngraph/runtime/manager.hpp
+5
-0
No files found.
src/ngraph/runtime/manager.cpp
View file @
c2cb1146
...
...
@@ -17,12 +17,15 @@
#include <sstream>
#include <string>
#include "ngraph/except.hpp"
#include "ngraph/runtime/manager.hpp"
#include "ngraph/util.hpp"
using
namespace
ngraph
::
runtime
;
bool
Manager
::
m_is_factory_map_initialized
=
false
;
std
::
shared_ptr
<
std
::
vector
<
void
*>>
Manager
::
m_plugin_lib_handles
=
std
::
make_shared
<
std
::
vector
<
void
*>>
(
std
::
vector
<
void
*>
());
void
Manager
::
load_plugins
(
const
std
::
string
&
runtime_plugin_libs
)
{
...
...
@@ -33,19 +36,28 @@ void Manager::load_plugins(const std::string& runtime_plugin_libs)
if
(
plugin_lib_path
.
size
()
>
0
)
{
void
*
lib_handle
=
dlopen
(
plugin_lib_path
.
c_str
(),
RTLD_NOW
);
if
(
!
lib_handle
)
if
(
lib_handle
)
{
std
::
cerr
<<
"Cannot open library: "
<<
plugin_lib_path
<<
", "
<<
dlerror
()
<<
std
::
endl
;
Manager
::
m_plugin_lib_handles
->
push_back
(
lib_handle
);
}
else
{
std
::
cerr
<<
"Loaded runtime at "
<<
lib_handle
<<
std
::
endl
;
throw
ngraph_error
(
"Cannot open library "
+
plugin_lib_path
)
;
}
}
}
}
// TODO: Should call this function after plugin is not needed anymore.
void
Manager
::
close_plugins
()
{
for
(
auto
lib_handle
:
*
Manager
::
m_plugin_lib_handles
)
{
dlclose
(
lib_handle
);
}
Manager
::
m_plugin_lib_handles
->
clear
();
}
Manager
::
FactoryMap
&
Manager
::
get_factory_map
()
{
// Stores Manager Factories
...
...
src/ngraph/runtime/manager.hpp
View file @
c2cb1146
...
...
@@ -18,6 +18,7 @@
#include <map>
#include <memory>
#include <string>
#include <vector>
namespace
ngraph
{
...
...
@@ -54,6 +55,10 @@ namespace ngraph
private
:
static
void
load_plugins
(
const
std
::
string
&
runtime_plugin_libs
);
static
void
close_plugins
();
static
std
::
shared_ptr
<
std
::
vector
<
void
*>>
m_plugin_lib_handles
;
static
bool
m_is_factory_map_initialized
;
using
FactoryMap
=
std
::
map
<
std
::
string
,
Factory
>
;
...
...
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