Unverified Commit 868ba1f8 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

[MLIR] Add option NGRAPH_EXPORT_TARGETS_ENABLE (#4079)

* Add option NGRAPH_EXPORT_TARGETS_ENABLE
Default value is TRUE
This option controls exporting and installing ngraph cmake config files.
Static library build only works with NGRAPH_EXPORT_TARGETS_ENABLE=OFF
for now.

* Turn off option for static nGraph lib.

* Register backends

* Add missing header files.
Co-authored-by: 's avatarScott Cyphers <diyessi@users.noreply.github.com>
parent 5498a997
......@@ -188,10 +188,17 @@ option(NGRAPH_CPU_STATIC_LIB_ENABLE "Enable build CPU backend as a static librar
option(NGRAPH_PLAIDML_STATIC_LIB_ENABLE "Enable build PlaidML backend as a static library" FALSE)
option(NGRAPH_DYNAMIC_COMPONENTS_ENABLE "Enable dynamic loading of components" TRUE)
option(NGRAPH_NATIVE_ARCH_ENABLE "Enable build for native archtecture" TRUE)
option(NGRAPH_EXPORT_TARGETS_ENABLE "Enable exporting nGraph cmake export targets" TRUE)
if (NGRAPH_CPU_ENABLE)
option(NGRAPH_TBB_ENABLE "Control usage of TBB for CPU backend" TRUE)
endif()
if (NGRAPH_STATIC_LIB_ENABLE)
message(WARNING "Workaround: "
"Turning off NGRAPH_EXPORT_TARGETS_ENABLE for nGraph static lib")
set(NGRAPH_EXPORT_TARGETS_ENABLE OFF)
endif()
if (NGRAPH_CPU_ENABLE
AND
(NOT NGRAPH_GENERIC_CPU_ENABLE)
......@@ -267,6 +274,7 @@ NORMALIZE_BOOL(NGRAPH_STATIC_LIB_ENABLE)
NORMALIZE_BOOL(NGRAPH_INTERPRETER_STATIC_LIB_ENABLE)
NORMALIZE_BOOL(NGRAPH_CPU_STATIC_LIB_ENABLE)
NORMALIZE_BOOL(NGRAPH_DYNAMIC_COMPONENTS_ENABLE)
NORMALIZE_BOOL(NGRAPH_EXPORT_TARGETS_ENABLE)
if (NGRAPH_CPU_ENABLE)
NORMALIZE_BOOL(NGRAPH_TBB_ENABLE)
endif()
......@@ -300,6 +308,7 @@ message(STATUS "NGRAPH_CPU_STATIC_LIB_ENABLE: ${NGRAPH_CPU_STATIC_LIB_EN
message(STATUS "NGRAPH_PLAIDML_STATIC_LIB_ENABLE: ${NGRAPH_PLAIDML_STATIC_LIB_ENABLE}")
message(STATUS "NGRAPH_DYNAMIC_COMPONENTS_ENABLE: ${NGRAPH_DYNAMIC_COMPONENTS_ENABLE}")
message(STATUS "NGRAPH_NATIVE_ARCH_ENABLE: ${NGRAPH_NATIVE_ARCH_ENABLE}")
message(STATUS "NGRAPH_EXPORT_TARGETS_ENABLE: ${NGRAPH_EXPORT_TARGETS_ENABLE}")
if (NGRAPH_CPU_ENABLE)
message(STATUS "NGRAPH_TBB_ENABLE: ${NGRAPH_TBB_ENABLE}")
endif()
......@@ -642,23 +651,30 @@ if (NGRAPH_PYTHON_BUILD_ENABLE)
add_subdirectory(python)
endif()
include(CMakePackageConfigHelpers)
if (NGRAPH_EXPORT_TARGETS_ENABLE)
include(CMakePackageConfigHelpers)
export(TARGETS ngraph NAMESPACE ngraph:: FILE "${CMAKE_CURRENT_BINARY_DIR}/ngraphTargets.cmake")
export(TARGETS ngraph NAMESPACE ngraph:: FILE "${CMAKE_CURRENT_BINARY_DIR}/ngraphTargets.cmake")
install(EXPORT ngraphTargets
FILE ngraphTargets.cmake
NAMESPACE ngraph::
DESTINATION cmake
COMPONENT ngraph)
install(EXPORT ngraphTargets
FILE ngraphTargets.cmake
NAMESPACE ngraph::
DESTINATION cmake
COMPONENT ngraph)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/share/ngraphConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ngraphConfig.cmake
INSTALL_DESTINATION cmake)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/share/ngraphConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/ngraphConfig.cmake
INSTALL_DESTINATION cmake)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/ngraphConfigVersion.cmake
VERSION ${NGRAPH_VERSION}
COMPATIBILITY SameMajorVersion)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/ngraphConfigVersion.cmake
VERSION ${NGRAPH_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ngraphConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ngraphConfigVersion.cmake
DESTINATION cmake
COMPONENT ngraph)
endif()
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/licenses
......@@ -667,8 +683,3 @@ install(DIRECTORY
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION "." COMPONENT ngraph)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/VERSION DESTINATION "." COMPONENT ngraph)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ngraphConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/ngraphConfigVersion.cmake
DESTINATION cmake
COMPONENT ngraph)
......@@ -30,6 +30,7 @@
#include "benchmark.hpp"
#include "benchmark_pipelined.hpp"
#include "ngraph/component_manager.hpp"
#include "ngraph/distributed.hpp"
#include "ngraph/except.hpp"
#include "ngraph/file_util.hpp"
......@@ -41,18 +42,27 @@
#include "ngraph/pass/visualize_tree.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/backend_manager.hpp"
#include "ngraph/runtime/interpreter/int_backend.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#ifdef NGRAPH_MLIR_ENABLE
#include "contrib/mlir/utils.hpp"
#endif
using namespace std;
using namespace ngraph;
static void configure_static_backends()
{
#ifdef NGRAPH_INTERPRETER_STATIC_LIB_ENABLE
ngraph::runtime::BackendManager::register_backend(
"INTERPRETER", ngraph::runtime::interpreter::get_backend_constructor_pointer());
#ifdef NGRAPH_CPU_ENABLE
ngraph_register_cpu_backend();
#endif
#ifdef NGRAPH_INTERPRETER_ENABLE
ngraph_register_interpreter_backend();
#endif
#ifdef NGRAPH_MLIR_ENABLE
// Initialize MLIR
ngraph::runtime::ngmlir::initializeNGraphMLIR();
#endif
}
......
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