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

wip

parent 45b7eb4c
......@@ -486,33 +486,33 @@ configure_file(version.in.hpp version.hpp)
if (NGRAPH_STATIC_LIB_ENABLE)
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)
target_compile_definitions(ngraph PRIVATE CPU_BACKEND_STATIC)
target_compile_definitions(ngraph PUBLIC CPU_BACKEND_STATIC)
endif()
if (NGRAPH_INTELGPU_ENABLE)
target_compile_definitions(ngraph PRIVATE INTELGPU_BACKEND_STATIC)
target_compile_definitions(ngraph PUBLIC INTELGPU_BACKEND_STATIC)
endif()
if (NGRAPH_GPU_ENABLE)
target_compile_definitions(ngraph PRIVATE GPU_BACKEND_STATIC)
target_compile_definitions(ngraph PUBLIC GPU_BACKEND_STATIC)
endif()
if (NGRAPH_NOP_ENABLE)
target_compile_definitions(ngraph PRIVATE NOP_BACKEND_STATIC)
target_compile_definitions(ngraph PUBLIC NOP_BACKEND_STATIC)
endif()
if (NGRAPH_GPUH_ENABLE)
target_compile_definitions(ngraph PRIVATE GPUH_BACKEND_STATIC)
target_compile_definitions(ngraph PUBLIC GPUH_BACKEND_STATIC)
endif()
if (NGRAPH_GENERIC_CPU_ENABLE)
target_compile_definitions(ngraph PRIVATE GENERIC_CPU_BACKEND_STATIC)
target_compile_definitions(ngraph PUBLIC GENERIC_CPU_BACKEND_STATIC)
endif()
if (NGRAPH_PLAIDML_ENABLE)
target_compile_definitions(ngraph PRIVATE PLAIDML_BACKEND_STATIC)
target_compile_definitions(ngraph PUBLIC PLAIDML_BACKEND_STATIC)
endif()
else()
add_library(ngraph SHARED ${SRC})
......
......@@ -25,6 +25,7 @@
#include "ngraph/file_util.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/cpu/static_initialize.hpp"
#include "ngraph/runtime/interpreter/static_initialize.hpp"
#include "ngraph/util.hpp"
......@@ -50,25 +51,25 @@ unordered_map<string, runtime::BackendConstructor*>& runtime::BackendManager::ge
runtime::interpreter::static_initialize();
#endif
// #ifdef CPU_BACKEND_STATIC
// runtime::cpu::static_initialize();
// runtime::cpu::static_initialize();
// #endif
// #ifdef INTELGPU_BACKEND_STATIC
// runtime::intelgpu::static_initialize();
// runtime::intelgpu::static_initialize();
// #endif
// #ifdef GPU_BACKEND_STATIC
// runtime::gpu::static_initialize();
// runtime::gpu::static_initialize();
// #endif
// #ifdef NOP_BACKEND_STATIC
// runtime::nop::static_initialize();
// runtime::nop::static_initialize();
// #endif
// #ifdef GPUH_BACKEND_STATIC
// runtime::gpuh::static_initialize();
// runtime::gpuh::static_initialize();
// #endif
// #ifdef GENERIC_CPU_BACKEND_STATIC
// runtime::cpu::static_initialize();
// runtime::cpu::static_initialize();
// #endif
// #ifdef PLAIDML_BACKEND_STATIC
// runtime::plaidml::static_initialize();
// runtime::plaidml::static_initialize();
// #endif
}
return s_registered_backend;
......@@ -110,6 +111,10 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
auto registry = get_registry();
auto it = registry.find(type);
for (auto x : registry)
{
NGRAPH_INFO << x.first;
}
if (it != registry.end())
{
BackendConstructor* new_backend = it->second;
......
......@@ -150,7 +150,11 @@ endif()
if (NGRAPH_CPU_ENABLE)
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)
set_target_properties(cpu_backend PROPERTIES
VERSION ${NGRAPH_VERSION}
......
......@@ -23,12 +23,13 @@
#include "ngraph/runtime/cpu/cpu_call_frame.hpp"
#include "ngraph/runtime/cpu/cpu_external_function.hpp"
#include "ngraph/runtime/cpu/cpu_tensor_view.hpp"
#include "ngraph/runtime/cpu/static_initialize.hpp"
#include "ngraph/util.hpp"
using namespace ngraph;
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
{
......@@ -36,6 +37,7 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
std::shared_ptr<runtime::Backend> create(const std::string& config) override
{
// Force TBB to link to the backend
NGRAPH_INFO;
tbb::TBB_runtime_interface_version();
return make_shared<runtime::cpu::CPU_Backend>();
}
......@@ -46,17 +48,22 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
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:
CPUStaticInit()
{
runtime::BackendManager::register_backend("CPU", get_backend_constructor_pointer());
}
~CPUStaticInit() {}
} s_cpu_static_init;
s_is_initialized = true;
runtime::BackendManager::register_backend("CPU", cpu_get_backend_constructor_pointer());
}
}
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 @@
using namespace std;
using namespace ngraph;
extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
static runtime::BackendConstructor*
interpreter_get_backend_constructor_pointer()
{
class INTBackendConstructor : public runtime::BackendConstructor
{
......@@ -43,6 +44,14 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
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()
{
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