Unverified Commit 29bfcf02 authored by Scott Cyphers's avatar Scott Cyphers Committed by GitHub

Merge pull request #3400 from NervanaSystems/cyphers/25tomaster

Cyphers/25tomaster
parents 84c3881d a4d03bdf
...@@ -398,6 +398,10 @@ if (NGRAPH_MLIR_ENABLE) ...@@ -398,6 +398,10 @@ if (NGRAPH_MLIR_ENABLE)
set(NGRAPH_MLIR_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/contrib/mlir) set(NGRAPH_MLIR_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/contrib/mlir)
endif() endif()
if (NGRAPH_STATIC_LIB_ENABLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNGRAPH_STATIC_LIB_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)
......
...@@ -519,6 +519,14 @@ if(NOT NGRAPH_JSON_ENABLE) ...@@ -519,6 +519,14 @@ if(NOT NGRAPH_JSON_ENABLE)
target_compile_definitions(ngraph PUBLIC NGRAPH_JSON_DISABLE) target_compile_definitions(ngraph PUBLIC NGRAPH_JSON_DISABLE)
endif() endif()
if(NGRAPH_INTERPRETER_STATIC_LIB_ENABLE)
target_compile_definitions(ngraph PUBLIC NGRAPH_INTERPRETER_STATIC_LIB_ENABLE)
endif()
if(NGRAPH_CPU_STATIC_LIB_ENABLE)
target_compile_definitions(ngraph PUBLIC NGRAPH_CPU_STATIC_LIB_ENABLE)
endif()
if(NGRAPH_DISTRIBUTED_ENABLE) if(NGRAPH_DISTRIBUTED_ENABLE)
if(NGRAPH_DISTRIBUTED_MLSL_ENABLE) if(NGRAPH_DISTRIBUTED_MLSL_ENABLE)
target_include_directories(ngraph SYSTEM PRIVATE libmlsl) target_include_directories(ngraph SYSTEM PRIVATE libmlsl)
......
...@@ -37,6 +37,9 @@ std::string runtime::Backend::s_backend_shared_library_search_directory; ...@@ -37,6 +37,9 @@ 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
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];
...@@ -52,6 +55,7 @@ static string find_my_pathname() ...@@ -52,6 +55,7 @@ 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
#endif
} }
runtime::Backend::~Backend() runtime::Backend::~Backend()
......
...@@ -32,12 +32,18 @@ ...@@ -32,12 +32,18 @@
using namespace std; using namespace std;
using namespace ngraph; using namespace ngraph;
#ifdef NGRAPH_STATIC_LIB_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)
#define DLERROR() ""
#else #else
#define CLOSE_LIBRARY(a) dlclose(a) #define CLOSE_LIBRARY(a) dlclose(a)
#define DLSYM(a, b) dlsym(a, b) #define DLSYM(a, b) dlsym(a, b)
#define DLERROR() dlerror()
#endif
#endif #endif
unordered_map<string, runtime::BackendConstructor*>& runtime::BackendManager::get_registry() unordered_map<string, runtime::BackendConstructor*>& runtime::BackendManager::get_registry()
...@@ -101,19 +107,19 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std:: ...@@ -101,19 +107,19 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
} }
else else
{ {
#ifndef NGRAPH_STATIC_LIB_ENABLE
DL_HANDLE handle = open_shared_library(type); DL_HANDLE handle = open_shared_library(type);
if (!handle) if (!handle)
{ {
stringstream ss; stringstream ss;
ss << "Backend '" << type << "' not registered. Error:"; ss << "Backend '" << type << "' not registered. Error:";
#ifndef _WIN32 #ifndef _WIN32
ss << dlerror(); ss << DLERROR();
#endif #endif
throw runtime_error(ss.str()); throw runtime_error(ss.str());
} }
#ifndef _WIN32 #ifndef _WIN32
dlerror(); // Clear any pending errors DLERROR(); // Clear any pending errors
#endif #endif
function<runtime::BackendConstructor*()> get_backend_constructor_pointer = function<runtime::BackendConstructor*()> get_backend_constructor_pointer =
reinterpret_cast<runtime::BackendConstructor* (*)()>( reinterpret_cast<runtime::BackendConstructor* (*)()>(
...@@ -127,7 +133,7 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std:: ...@@ -127,7 +133,7 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
{ {
string error; string error;
#ifndef _WIN32 #ifndef _WIN32
const char* err = dlerror(); const char* err = DLERROR();
error = (err ? err : ""); error = (err ? err : "");
#endif #endif
CLOSE_LIBRARY(handle); CLOSE_LIBRARY(handle);
...@@ -136,6 +142,7 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std:: ...@@ -136,6 +142,7 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
"library.\nError='" + "library.\nError='" +
error + "'"); error + "'");
} }
#endif
} }
return backend; return backend;
} }
...@@ -146,6 +153,7 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type) ...@@ -146,6 +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;
#ifndef NGRAPH_STATIC_LIB_ENABLE
// strip off attributes, IE:CPU becomes IE // strip off attributes, IE:CPU becomes IE
auto colon = type.find(":"); auto colon = type.find(":");
...@@ -163,9 +171,9 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type) ...@@ -163,9 +171,9 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
SetDllDirectory((LPCSTR)my_directory.c_str()); SetDllDirectory((LPCSTR)my_directory.c_str());
handle = LoadLibrary(library_path.c_str()); handle = LoadLibrary(library_path.c_str());
#else #else
dlerror(); // Clear any pending errors DLERROR(); // Clear any pending errors
handle = dlopen(library_path.c_str(), RTLD_NOW | RTLD_GLOBAL); handle = dlopen(library_path.c_str(), RTLD_NOW | RTLD_GLOBAL);
const char* err = dlerror(); const char* err = DLERROR();
error = (err ? err : ""); error = (err ? err : "");
#endif #endif
if (!handle) if (!handle)
...@@ -175,12 +183,14 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type) ...@@ -175,12 +183,14 @@ DL_HANDLE runtime::BackendManager::open_shared_library(string type)
ss << "\nOpen error message '" << error << "'"; ss << "\nOpen error message '" << error << "'";
throw runtime_error(ss.str()); throw runtime_error(ss.str());
} }
#endif
return handle; return handle;
} }
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;
#ifndef NGRAPH_STATIC_LIB_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;
...@@ -197,6 +207,7 @@ map<string, string> runtime::BackendManager::get_registered_device_map() ...@@ -197,6 +207,7 @@ map<string, string> runtime::BackendManager::get_registered_device_map()
} }
}; };
file_util::iterate_files(my_directory, f, false, true); file_util::iterate_files(my_directory, f, false, true);
#endif
return rc; return rc;
} }
......
...@@ -95,6 +95,9 @@ namespace ngraph ...@@ -95,6 +95,9 @@ namespace ngraph
} }
} }
REGISTER_OP_BUILDER(QuantizedConcat); REGISTER_OP_BUILDER(QuantizedConcat);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void register_builders_quantized_concat_cpp() {}
#endif
} }
} }
} }
...@@ -69,6 +69,9 @@ namespace ngraph ...@@ -69,6 +69,9 @@ namespace ngraph
} }
} }
REGISTER_OP_BUILDER(QuantizedMaxPool); REGISTER_OP_BUILDER(QuantizedMaxPool);
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
void register_builders_quantized_max_pool_cpp() {}
#endif
} }
} }
} }
...@@ -77,6 +77,8 @@ namespace ngraph ...@@ -77,6 +77,8 @@ namespace ngraph
register_builders_tile_cpp(); register_builders_tile_cpp();
register_builders_topk_cpp(); register_builders_topk_cpp();
register_builders_update_slice_cpp(); register_builders_update_slice_cpp();
register_builders_quantized_concat_cpp();
register_builders_quantized_max_pool_cpp();
} }
} }
} }
......
...@@ -76,6 +76,8 @@ namespace ngraph ...@@ -76,6 +76,8 @@ namespace ngraph
void register_builders_tile_cpp(); void register_builders_tile_cpp();
void register_builders_topk_cpp(); void register_builders_topk_cpp();
void register_builders_update_slice_cpp(); void register_builders_update_slice_cpp();
void register_builders_quantized_concat_cpp();
void register_builders_quantized_max_pool_cpp();
} }
} }
} }
......
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