Commit 99ea4a4b authored by Adam Straw's avatar Adam Straw Committed by Robert Kimball

strip off attributes from backend type prior to shared lib dlopen (#1080)

* strip off attributes from backend type prior to shared lib dlopen
parent 7fef9aa9
......@@ -40,20 +40,28 @@ runtime::Backend::~Backend()
{
}
void* runtime::Backend::open_shared_library(const string& type)
void* runtime::Backend::open_shared_library(string type)
{
string ext = SHARED_LIB_EXT;
string ver = LIBRARY_VERSION;
void* handle = nullptr;
// strip off attributes, IE:CPU becomes IE
auto colon = type.find(":");
if (colon != type.npos)
{
type = type.substr(0, colon);
}
string name = "lib" + to_lower(type) + "_backend" + ext;
handle = dlopen(name.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (handle)
{
function<void()> create = reinterpret_cast<void (*)()>(dlsym(handle, "create_backend"));
if (create)
function<void()> create_backend =
reinterpret_cast<void (*)()>(dlsym(handle, "create_backend"));
if (create_backend)
{
create();
create_backend();
}
else
{
......
......@@ -83,7 +83,7 @@ namespace ngraph
const std::vector<std::shared_ptr<runtime::TensorView>>& inputs);
private:
static void* open_shared_library(const std::string& name);
static void* open_shared_library(std::string type);
static std::unordered_map<std::string, std::shared_ptr<Backend>>& get_backend_map();
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment