Commit cf900aa4 authored by Robert Kimball's avatar Robert Kimball

interpreter works

parent af7b4c8e
...@@ -486,6 +486,34 @@ configure_file(version.in.hpp version.hpp) ...@@ -486,6 +486,34 @@ 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)
if (NGRAPH_CPU_ENABLE)
target_compile_definitions(ngraph PRIVATE CPU_BACKEND_STATIC)
endif()
if (NGRAPH_INTELGPU_ENABLE)
target_compile_definitions(ngraph PRIVATE INTELGPU_BACKEND_STATIC)
endif()
if (NGRAPH_GPU_ENABLE)
target_compile_definitions(ngraph PRIVATE GPU_BACKEND_STATIC)
endif()
if (NGRAPH_NOP_ENABLE)
target_compile_definitions(ngraph PRIVATE NOP_BACKEND_STATIC)
endif()
if (NGRAPH_GPUH_ENABLE)
target_compile_definitions(ngraph PRIVATE GPUH_BACKEND_STATIC)
endif()
if (NGRAPH_GENERIC_CPU_ENABLE)
target_compile_definitions(ngraph PRIVATE GENERIC_CPU_BACKEND_STATIC)
endif()
if (NGRAPH_PLAIDML_ENABLE)
target_compile_definitions(ngraph PRIVATE PLAIDML_BACKEND_STATIC)
endif()
else() else()
add_library(ngraph SHARED ${SRC}) add_library(ngraph SHARED ${SRC})
endif() endif()
......
...@@ -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/interpreter/static_initialize.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
using namespace std; using namespace std;
...@@ -41,6 +42,35 @@ using namespace ngraph; ...@@ -41,6 +42,35 @@ using namespace ngraph;
unordered_map<string, runtime::BackendConstructor*>& runtime::BackendManager::get_registry() unordered_map<string, runtime::BackendConstructor*>& runtime::BackendManager::get_registry()
{ {
static unordered_map<string, BackendConstructor*> s_registered_backend; static unordered_map<string, BackendConstructor*> s_registered_backend;
static bool s_static_initialization_called = false;
if (!s_static_initialization_called)
{
s_static_initialization_called = true;
#ifdef INTERPRETER_BACKEND_STATIC
runtime::interpreter::static_initialize();
#endif
// #ifdef CPU_BACKEND_STATIC
// runtime::cpu::static_initialize();
// #endif
// #ifdef INTELGPU_BACKEND_STATIC
// runtime::intelgpu::static_initialize();
// #endif
// #ifdef GPU_BACKEND_STATIC
// runtime::gpu::static_initialize();
// #endif
// #ifdef NOP_BACKEND_STATIC
// runtime::nop::static_initialize();
// #endif
// #ifdef GPUH_BACKEND_STATIC
// runtime::gpuh::static_initialize();
// #endif
// #ifdef GENERIC_CPU_BACKEND_STATIC
// runtime::cpu::static_initialize();
// #endif
// #ifdef PLAIDML_BACKEND_STATIC
// runtime::plaidml::static_initialize();
// #endif
}
return s_registered_backend; return s_registered_backend;
} }
...@@ -79,6 +109,11 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std:: ...@@ -79,6 +109,11 @@ shared_ptr<runtime::Backend> runtime::BackendManager::create_backend(const std::
} }
auto registry = get_registry(); auto registry = get_registry();
NGRAPH_INFO << type;
for (auto t : registry)
{
NGRAPH_INFO << t.first;
}
auto it = registry.find(type); auto it = registry.find(type);
if (it != registry.end()) if (it != registry.end())
{ {
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# ****************************************************************************** # ******************************************************************************
if (NGRAPH_INTERPRETER_ENABLE) if (NGRAPH_INTERPRETER_ENABLE)
add_library(interpreter_backend SHARED int_backend.cpp node_wrapper.cpp int_executable.cpp) add_library(interpreter_backend STATIC int_backend.cpp node_wrapper.cpp int_executable.cpp)
if(NGRAPH_LIB_VERSIONING_ENABLE) if(NGRAPH_LIB_VERSIONING_ENABLE)
set_target_properties(interpreter_backend PROPERTIES set_target_properties(interpreter_backend PROPERTIES
VERSION ${NGRAPH_VERSION} VERSION ${NGRAPH_VERSION}
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ngraph/runtime/backend_manager.hpp" #include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/interpreter/int_executable.hpp" #include "ngraph/runtime/interpreter/int_executable.hpp"
#include "ngraph/runtime/interpreter/static_initialize.hpp"
#include "ngraph/serializer.hpp" #include "ngraph/serializer.hpp"
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
...@@ -42,6 +43,17 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer() ...@@ -42,6 +43,17 @@ extern "C" runtime::BackendConstructor* get_backend_constructor_pointer()
return s_backend_constructor.get(); return s_backend_constructor.get();
} }
void runtime::interpreter::static_initialize()
{
static bool s_is_initialized = false;
if (!s_is_initialized)
{
NGRAPH_INFO << "INTERPRETER static initialize";
s_is_initialized = true;
BackendManager::register_backend("INTERPRETER", get_backend_constructor_pointer());
}
}
runtime::interpreter::INTBackend::INTBackend() runtime::interpreter::INTBackend::INTBackend()
{ {
} }
......
//*****************************************************************************
// 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 interpreter
{
void static_initialize();
}
}
}
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