Commit 5e637637 authored by pruthvi's avatar pruthvi

- call static_initlize from the backend_manager

- use gaurds to coditionally compile the code
parent f95d7167
...@@ -261,6 +261,7 @@ NORMALIZE_BOOL(NGRAPH_PLAIDML_ENABLE) ...@@ -261,6 +261,7 @@ NORMALIZE_BOOL(NGRAPH_PLAIDML_ENABLE)
NORMALIZE_BOOL(NGRAPH_JSON_ENABLE) 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)
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}")
...@@ -286,6 +287,7 @@ message(STATUS "NGRAPH_DISTRIBUTED_ENABLE: ${NGRAPH_DISTRIBUTED_ENABL ...@@ -286,6 +287,7 @@ message(STATUS "NGRAPH_DISTRIBUTED_ENABLE: ${NGRAPH_DISTRIBUTED_ENABL
message(STATUS "NGRAPH_JSON_ENABLE: ${NGRAPH_JSON_ENABLE}") 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}")
#----------------------------------------------------------------------------------------------- #-----------------------------------------------------------------------------------------------
# Installation logic... # Installation logic...
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "ngraph/file_util.hpp" #include "ngraph/file_util.hpp"
#include "ngraph/runtime/backend.hpp" #include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp" #include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/cpu/static_initialize.hpp"
#include "ngraph/runtime/interpreter/static_initialize.hpp" #include "ngraph/runtime/interpreter/static_initialize.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
...@@ -69,6 +70,14 @@ vector<string> runtime::BackendManager::get_registered_backends() ...@@ -69,6 +70,14 @@ vector<string> runtime::BackendManager::get_registered_backends()
shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::string& config) shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::string& config)
{ {
#ifdef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
runtime::interpreter::static_initialize();
#endif
#ifdef NGRAPH_CPU_STATIC_LIB_ENABLE
runtime::cpu::static_initialize();
#endif
shared_ptr<runtime::Backend> backend; shared_ptr<runtime::Backend> backend;
string type = config; string type = config;
......
...@@ -51,7 +51,7 @@ runtime::BackendConstructor* runtime::cpu::get_backend_constructor_pointer() ...@@ -51,7 +51,7 @@ runtime::BackendConstructor* runtime::cpu::get_backend_constructor_pointer()
return s_backend_constructor.get(); return s_backend_constructor.get();
} }
#ifndef CPU_BACKEND_STATIC #ifndef NGRAPH_CPU_STATIC_LIB_ENABLE
extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
{ {
return runtime::cpu::get_backend_constructor_pointer(); return runtime::cpu::get_backend_constructor_pointer();
...@@ -70,6 +70,7 @@ void runtime::cpu::static_initialize() ...@@ -70,6 +70,7 @@ void runtime::cpu::static_initialize()
namespace namespace
{ {
#ifndef NGRAPH_CPU_STATIC_LIB_ENABLE
static class CPUStaticInit static class CPUStaticInit
{ {
public: public:
...@@ -79,6 +80,7 @@ namespace ...@@ -79,6 +80,7 @@ namespace
} }
~CPUStaticInit() {} ~CPUStaticInit() {}
} s_cpu_static_init; } s_cpu_static_init;
#endif
} }
runtime::cpu::CPU_Backend::~CPU_Backend() runtime::cpu::CPU_Backend::~CPU_Backend()
......
...@@ -34,7 +34,7 @@ namespace ngraph ...@@ -34,7 +34,7 @@ namespace ngraph
{ {
class CPU_ExternalFunction; class CPU_ExternalFunction;
class CPU_CallFrame; class CPU_CallFrame;
ngraph::runtime::BackendConstructor* get_backend_constructor_pointer(); BackendConstructor* get_backend_constructor_pointer();
class CPU_BACKEND_API CPU_Backend : public runtime::Backend class CPU_BACKEND_API CPU_Backend : public runtime::Backend
{ {
public: public:
......
...@@ -43,7 +43,7 @@ runtime::BackendConstructor* runtime::interpreter::get_backend_constructor_point ...@@ -43,7 +43,7 @@ runtime::BackendConstructor* runtime::interpreter::get_backend_constructor_point
return s_backend_constructor.get(); return s_backend_constructor.get();
} }
#ifndef INTERPRETER_BACKEND_STATIC #ifndef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
{ {
return runtime::interpreter::get_backend_constructor_pointer(); return runtime::interpreter::get_backend_constructor_pointer();
......
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