Commit 2204a054 authored by Robert Kimball's avatar Robert Kimball

wip

parent 45b7eb4c
...@@ -486,33 +486,33 @@ configure_file(version.in.hpp version.hpp) ...@@ -486,33 +486,33 @@ configure_file(version.in.hpp version.hpp)
if (NGRAPH_STATIC_LIB_ENABLE) if (NGRAPH_STATIC_LIB_ENABLE)
add_library(ngraph STATIC ${SRC}) add_library(ngraph STATIC ${SRC})
target_compile_definitions(ngraph PRIVATE INTERPRETER_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC INTERPRETER_BACKEND_STATIC)
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
target_compile_definitions(ngraph PRIVATE CPU_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC CPU_BACKEND_STATIC)
endif() endif()
if (NGRAPH_INTELGPU_ENABLE) if (NGRAPH_INTELGPU_ENABLE)
target_compile_definitions(ngraph PRIVATE INTELGPU_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC INTELGPU_BACKEND_STATIC)
endif() endif()
if (NGRAPH_GPU_ENABLE) if (NGRAPH_GPU_ENABLE)
target_compile_definitions(ngraph PRIVATE GPU_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC GPU_BACKEND_STATIC)
endif() endif()
if (NGRAPH_NOP_ENABLE) if (NGRAPH_NOP_ENABLE)
target_compile_definitions(ngraph PRIVATE NOP_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC NOP_BACKEND_STATIC)
endif() endif()
if (NGRAPH_GPUH_ENABLE) if (NGRAPH_GPUH_ENABLE)
target_compile_definitions(ngraph PRIVATE GPUH_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC GPUH_BACKEND_STATIC)
endif() endif()
if (NGRAPH_GENERIC_CPU_ENABLE) if (NGRAPH_GENERIC_CPU_ENABLE)
target_compile_definitions(ngraph PRIVATE GENERIC_CPU_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC GENERIC_CPU_BACKEND_STATIC)
endif() endif()
if (NGRAPH_PLAIDML_ENABLE) if (NGRAPH_PLAIDML_ENABLE)
target_compile_definitions(ngraph PRIVATE PLAIDML_BACKEND_STATIC) target_compile_definitions(ngraph PUBLIC PLAIDML_BACKEND_STATIC)
endif() endif()
else() else()
add_library(ngraph SHARED ${SRC}) add_library(ngraph SHARED ${SRC})
......
...@@ -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"
...@@ -50,25 +51,25 @@ unordered_map<string, runtime::BackendConstructor*>& runtime::BackendManager::ge ...@@ -50,25 +51,25 @@ unordered_map<string, runtime::BackendConstructor*>& runtime::BackendManager::ge
runtime::interpreter::static_initialize(); runtime::interpreter::static_initialize();
#endif #endif
// #ifdef CPU_BACKEND_STATIC // #ifdef CPU_BACKEND_STATIC
// runtime::cpu::static_initialize(); // runtime::cpu::static_initialize();
// #endif // #endif
// #ifdef INTELGPU_BACKEND_STATIC // #ifdef INTELGPU_BACKEND_STATIC
// runtime::intelgpu::static_initialize(); // runtime::intelgpu::static_initialize();
// #endif // #endif
// #ifdef GPU_BACKEND_STATIC // #ifdef GPU_BACKEND_STATIC
// runtime::gpu::static_initialize(); // runtime::gpu::static_initialize();
// #endif // #endif
// #ifdef NOP_BACKEND_STATIC // #ifdef NOP_BACKEND_STATIC
// runtime::nop::static_initialize(); // runtime::nop::static_initialize();
// #endif // #endif
// #ifdef GPUH_BACKEND_STATIC // #ifdef GPUH_BACKEND_STATIC
// runtime::gpuh::static_initialize(); // runtime::gpuh::static_initialize();
// #endif // #endif
// #ifdef GENERIC_CPU_BACKEND_STATIC // #ifdef GENERIC_CPU_BACKEND_STATIC
// runtime::cpu::static_initialize(); // runtime::cpu::static_initialize();
// #endif // #endif
// #ifdef PLAIDML_BACKEND_STATIC // #ifdef PLAIDML_BACKEND_STATIC
// runtime::plaidml::static_initialize(); // runtime::plaidml::static_initialize();
// #endif // #endif
} }
return s_registered_backend; return s_registered_backend;
...@@ -110,6 +111,10 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std:: ...@@ -110,6 +111,10 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
auto registry = get_registry(); auto registry = get_registry();
auto it = registry.find(type); auto it = registry.find(type);
for (auto x : registry)
{
NGRAPH_INFO << x.first;
}
if (it != registry.end()) if (it != registry.end())
{ {
BackendConstructor* new_backend = it->second; BackendConstructor* new_backend = it->second;
......
...@@ -150,7 +150,11 @@ endif() ...@@ -150,7 +150,11 @@ endif()
if (NGRAPH_CPU_ENABLE) if (NGRAPH_CPU_ENABLE)
set(NGRAPH_CPU_DEBUGINFO_ENABLE 0 CACHE STRING "Enable debuginfo in the CPU backend") set(NGRAPH_CPU_DEBUGINFO_ENABLE 0 CACHE STRING "Enable debuginfo in the CPU backend")
add_library(cpu_backend SHARED ${SRC}) # if (NGRAPH_STATIC_LIB_ENABLE)
# add_library(cpu_backend STATIC ${SRC})
# else()
add_library(cpu_backend SHARED ${SRC})
# endif()
if(NGRAPH_LIB_VERSIONING_ENABLE) if(NGRAPH_LIB_VERSIONING_ENABLE)
set_target_properties(cpu_backend PROPERTIES set_target_properties(cpu_backend PROPERTIES
VERSION ${NGRAPH_VERSION} VERSION ${NGRAPH_VERSION}
......
...@@ -23,12 +23,13 @@ ...@@ -23,12 +23,13 @@
#include "ngraph/runtime/cpu/cpu_call_frame.hpp" #include "ngraph/runtime/cpu/cpu_call_frame.hpp"
#include "ngraph/runtime/cpu/cpu_external_function.hpp" #include "ngraph/runtime/cpu/cpu_external_function.hpp"
#include "ngraph/runtime/cpu/cpu_tensor_view.hpp" #include "ngraph/runtime/cpu/cpu_tensor_view.hpp"
#include "ngraph/runtime/cpu/static_initialize.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
using namespace ngraph; using namespace ngraph;
using namespace std; using namespace std;
extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() static runtime::BackendConstructor* cpu_get_backend_constructor_pointer()
{ {
class CPU_BackendConstructor : public runtime::BackendConstructor class CPU_BackendConstructor : public runtime::BackendConstructor
{ {
...@@ -36,6 +37,7 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() ...@@ -36,6 +37,7 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
std::shared_ptr<runtime::Backend> create(const std::string& config) override std::shared_ptr<runtime::Backend> create(const std::string& config) override
{ {
// Force TBB to link to the backend // Force TBB to link to the backend
NGRAPH_INFO;
tbb::TBB_runtime_interface_version(); tbb::TBB_runtime_interface_version();
return make_shared<runtime::cpu::CPU_Backend>(); return make_shared<runtime::cpu::CPU_Backend>();
} }
...@@ -46,17 +48,22 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() ...@@ -46,17 +48,22 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
return s_backend_constructor.get(); return s_backend_constructor.get();
} }
namespace #ifndef CPU_BACKEND_STATIC
extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
{
return cpu_get_backend_constructor_pointer();
}
#endif
void runtime::cpu::static_initialize()
{ {
static class CPUStaticInit NGRAPH_INFO;
static bool s_is_initialized = false;
if (!s_is_initialized)
{ {
public: s_is_initialized = true;
CPUStaticInit() runtime::BackendManager::register_backend("CPU", cpu_get_backend_constructor_pointer());
{ }
runtime::BackendManager::register_backend("CPU", get_backend_constructor_pointer());
}
~CPUStaticInit() {}
} s_cpu_static_init;
} }
shared_ptr<runtime::cpu::CPU_CallFrame> runtime::cpu::CPU_Backend::make_call_frame( shared_ptr<runtime::cpu::CPU_CallFrame> runtime::cpu::CPU_Backend::make_call_frame(
......
//*****************************************************************************
// Copyright 2017-2019 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
namespace ngraph
{
namespace runtime
{
namespace cpu
{
void static_initialize();
}
}
}
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
using namespace std; using namespace std;
using namespace ngraph; using namespace ngraph;
extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() static runtime::BackendConstructor*
interpreter_get_backend_constructor_pointer()
{ {
class INTBackendConstructor : public runtime::BackendConstructor class INTBackendConstructor : public runtime::BackendConstructor
{ {
...@@ -43,6 +44,14 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() ...@@ -43,6 +44,14 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
return s_backend_constructor.get(); return s_backend_constructor.get();
} }
#ifdef INTERPRETER_BACKEND_STATIC
extern "C" runtime::BackendConstructor*
get_backend_constructor_pointer()
{
return interpreter_get_backend_constructor_pointer();
}
#endif
void runtime::interpreter::static_initialize() void runtime::interpreter::static_initialize()
{ {
static bool s_is_initialized = false; static bool s_is_initialized = false;
......
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