Unverified Commit eef750df authored by Robert Kimball's avatar Robert Kimball Committed by GitHub

Modernize cmake usage (#1032)

* Update cmake files to more modern approach

* disable building libraries that are not required

* handle more build cases

* add versions to backend libs. add start of package target.

* add create_backend to backends

* temporary workaround to tbb not linking correctly with gcc

* install codegen lib

* force tbb to link to the cpu backend so that it is available for codegen

* fix clang build error

* fix warning for codegen build

* update cuda header paths

* change error message for opening backend shared library

* set lib path
parent b8e28555
......@@ -21,7 +21,11 @@ NGRAPH_GET_VERSION_LABEL()
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" NGRAPH_VERSION_SHORT "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "([0-9]+)\.([0-9]+)" NGRAPH_API_VERSION "${NGRAPH_VERSION_LABEL}")
set(NGRAPH_VERSION "${NGRAPH_VERSION_LABEL}")
string(REGEX MATCH "[^v](.*)" NGRAPH_VERSION "${NGRAPH_VERSION_LABEL}")
string(REPLACE "." ";" NGRAPH_VERSION_PARTS "${NGRAPH_VERSION_SHORT}")
list(GET NGRAPH_VERSION_PARTS 0 NGRAPH_VERSION_MAJOR)
list(GET NGRAPH_VERSION_PARTS 1 NGRAPH_VERSION_MINOR)
list(GET NGRAPH_VERSION_PARTS 2 NGRAPH_VERSION_PATCH)
configure_file(VERSION.in VERSION)
message(STATUS "NGRAPH_VERSION ${NGRAPH_VERSION}")
......@@ -81,6 +85,7 @@ option(NGRAPH_UNIT_TEST_ENABLE "Control the building of unit tests" TRUE)
option(NGRAPH_TOOLS_ENABLE "Control the building of tool" TRUE)
option(NGRAPH_CPU_ENABLE "Control the building of the CPU backend" TRUE)
option(NGRAPH_GPU_ENABLE "Control the building of the GPU backend" FALSE)
option(NGRAPH_INTERPRETER_ENABLE "Control the building of the INTERPRETER backend" TRUE)
option(NGRAPH_DISTRIBUTED_ENABLE "Add distributed mode to the CPU backend" FALSE)
option(NGRAPH_DEBUG_ENABLE "Enable output for NGRAPH_DEBUG statements" FALSE)
......@@ -108,6 +113,7 @@ message (STATUS "To Override use: cmake -DNGRAPH_INSTALL_PREFIX=/foo")
set(NGRAPH_INSTALL_LIB "${CMAKE_INSTALL_PREFIX}/lib")
set(NGRAPH_INSTALL_INCLUDE "${CMAKE_INSTALL_PREFIX}/include")
set(NGRAPH_INSTALL_DOC "${CMAKE_INSTALL_PREFIX}/doc")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
#-----------------------------------------------------------------------------------------------
# Compiler-specific logic...
......@@ -157,7 +163,10 @@ endif()
include(unit_test_control)
set(UNIT_TEST_CONFIG_LIST "" CACHE INTERNAL "")
unit_test_control(BACKEND INTERPRETER MANIFEST src/ngraph/runtime/interpreter/unit_test.manifest)
if (NGRAPH_INTERPRETER_ENABLE)
unit_test_control(BACKEND INTERPRETER MANIFEST src/ngraph/runtime/interpreter/unit_test.manifest)
endif()
# Set true if CPU backend is built by default
if (NGRAPH_CPU_ENABLE)
......@@ -165,31 +174,12 @@ if (NGRAPH_CPU_ENABLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNGRAPH_CPU_ENABLE")
endif()
if (NOT DEFINED NGRAPH_TBB_ENABLE)
set(NGRAPH_TBB_ENABLE ${NGRAPH_CPU_ENABLE})
if (NGRAPH_GPU_ENABLE)
unit_test_control(BACKEND GPU MANIFEST src/ngraph/runtime/gpu/unit_test.manifest)
endif()
#-----------------------------------------------------------------------------------------------
# GPU support
#-----------------------------------------------------------------------------------------------
# Setup CUDA and cuDNN if NGRAPH_GPU_ENABLE=TRUE
if(NGRAPH_GPU_ENABLE)
find_package(CUDA 8 REQUIRED)
message(STATUS "GPU Backend Enabled")
set(NGRAPH_GPU_ENABLE TRUE)
find_package(CUDNN 7 REQUIRED)
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIR} ${LLVM_INCLUDE_DIR})
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0 AND
CUDA_HOST_COMPILER STREQUAL CMAKE_C_COMPILER)
message(FATAL_ERROR
"CUDA 8.0 is not compatible with GCC version >= 6.\n"
"Please select a correct compiler version\n"
)
endif()
unit_test_control(BACKEND GPU MANIFEST src/ngraph/runtime/gpu/unit_test.manifest)
elseif(NGRAPH_GPU_ENABLE)
message(FATAL_ERROR "GPU was required but CUDA library was not found")
if (NOT DEFINED NGRAPH_TBB_ENABLE)
set(NGRAPH_TBB_ENABLE ${NGRAPH_CPU_ENABLE})
endif()
#-----------------------------------------------------------------------------------------------
......@@ -199,45 +189,26 @@ if(NGRAPH_DEBUG_ENABLE)
add_definitions(-DNGRAPH_DEBUG_ENABLE)
endif()
#-----------------------------------------------------------------------------------------------
# distributed support
#-----------------------------------------------------------------------------------------------
if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED)
endif()
#-----------------------------------------------------------------------------------------------
# External projects install directory
#-----------------------------------------------------------------------------------------------
# Root for external installs, when using `make`, e.g.
# ${EXTERNAL_PROJECTS_ROOT}
# ├── eigen
# │   ├── include
# │   │   └── eigen3 <-- ${EIGEN_INCLUDE_DIR}
# │   │   ├── Eigen
# │ ...
# │
# └── mkldnn
# ├── include <-- ${MKLDNN_INCLUDE_DIR}
# │   ├── mkldnn.h
# │ ...
# ├── lib <-- ${MKLDNN_LIB_DIR}
# │   ├── libiomp5.so
# ...
set(EXTERNAL_INSTALL_DIR ${CMAKE_BINARY_DIR}/external)
# The following 'add_subdirectory' call:
# - defines the 'libgtest' target.
# - defines the 'GTEST_INCLUDE_DIR' cmake variable.
add_subdirectory(third-party)
if(NOT DEFINED EXTERNAL_PROJECTS_ROOT)
set(EXTERNAL_PROJECTS_ROOT ${CMAKE_CURRENT_BINARY_DIR})
endif()
include(cmake/external_gtest.cmake)
include(cmake/external_json.cmake)
include(cmake/external_eigen.cmake)
include(cmake/external_mkldnn.cmake)
if (NGRAPH_USE_PREBUILT_LLVM OR DEFINED LLVM_TARBALL_URL)
include(cmake/external_llvm_prebuilt.cmake)
else()
include(cmake/external_llvm.cmake)
endif()
include(cmake/external_tbb.cmake)
# The following 'add_subdirectory' call:
# - defines the 'ngraph' library target.
# - defines the 'NGRAPH_INCLUDE_DIR' cmake variable.
# - defines the 'NGRAPH_VERSION' cmake variable.
# - install-related targets.
add_subdirectory(src)
if (NGRAPH_UNIT_TEST_ENABLE)
......
......@@ -20,14 +20,15 @@ include(ExternalProject)
set(EIGEN_GIT_TAG patched)
set(EIGEN_GIT_URL https://github.com/NervanaSystems/eigen)
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Download Eigen
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if (${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_eigen
PREFIX eigen
GIT_REPOSITORY ${EIGEN_GIT_URL}
GIT_TAG ${EIGEN_GIT_TAG}
UPDATE_COMMAND ""
......@@ -40,10 +41,12 @@ if (${CMAKE_VERSION} VERSION_LESS 3.2)
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen"
EXCLUDE_FROM_ALL TRUE
)
else()
ExternalProject_Add(
ext_eigen
PREFIX eigen
GIT_REPOSITORY ${EIGEN_GIT_URL}
GIT_TAG ${EIGEN_GIT_TAG}
UPDATE_COMMAND ""
......@@ -57,9 +60,13 @@ else()
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/eigen/src/Eigen/Core"
EXCLUDE_FROM_ALL TRUE
)
endif()
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
set(EIGEN_INCLUDE_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/src" PARENT_SCOPE)
ExternalProject_Get_Property(ext_eigen SOURCE_DIR)
add_library(libeigen INTERFACE)
target_include_directories(libeigen SYSTEM INTERFACE ${SOURCE_DIR})
add_dependencies(libeigen ext_eigen)
......@@ -17,9 +17,9 @@
# Enable ExternalProject CMake module
include(ExternalProject)
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Download and install GoogleTest ...
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
SET(GTEST_GIT_REPO_URL https://github.com/google/googletest.git)
SET(GTEST_GIT_LABEL release-1.8.0)
......@@ -28,28 +28,35 @@ SET(GTEST_GIT_LABEL release-1.8.0)
if (${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_gtest
PREFIX gtest
GIT_REPOSITORY ${GTEST_GIT_REPO_URL}
GIT_TAG ${GTEST_GIT_LABEL}
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS="-fPIC"
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS="-fPIC"
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest"
EXCLUDE_FROM_ALL TRUE
)
else()
ExternalProject_Add(
ext_gtest
PREFIX gtest
GIT_REPOSITORY ${GTEST_GIT_REPO_URL}
GIT_TAG ${GTEST_GIT_LABEL}
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_FLAGS="-fPIC"
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS="-fPIC"
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download"
......@@ -57,23 +64,15 @@ else()
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/gtest/build/googlemock/gtest/libgtest.a"
EXCLUDE_FROM_ALL TRUE
)
endif()
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
get_filename_component(
GTEST_INCLUDE_DIR
"${EXTERNAL_PROJECTS_ROOT}/gtest/src/googletest/include"
ABSOLUTE)
set(GTEST_INCLUDE_DIR "${GTEST_INCLUDE_DIR}" PARENT_SCOPE)
ExternalProject_Get_Property(ext_gtest SOURCE_DIR BINARY_DIR)
# Create a libgtest target to be used as a dependency by test programs
add_library(libgtest IMPORTED STATIC GLOBAL)
add_library(libgtest INTERFACE)
add_dependencies(libgtest ext_gtest)
# Set libgtest properties
set_target_properties(libgtest PROPERTIES
"IMPORTED_LOCATION" "${EXTERNAL_PROJECTS_ROOT}/gtest/build/googlemock/gtest/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
)
target_include_directories(libgtest SYSTEM INTERFACE ${SOURCE_DIR}/googletest/include)
target_link_libraries(libgtest INTERFACE ${BINARY_DIR}/googlemock/gtest/libgtest.a)
......@@ -28,6 +28,7 @@ SET(JSON_GIT_LABEL v3.1.1)
if (${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_json
PREFIX json
GIT_REPOSITORY ${JSON_GIT_REPO_URL}
GIT_TAG ${JSON_GIT_LABEL}
# Disable install step
......@@ -37,10 +38,12 @@ if (${CMAKE_VERSION} VERSION_LESS 3.2)
# cmake does not allow calling cmake functions so we call a cmake script in the Module
# directory.
PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/patch_json.cmake
EXCLUDE_FROM_ALL TRUE
)
else()
ExternalProject_Add(
ext_json
PREFIX json
GIT_REPOSITORY ${JSON_GIT_REPO_URL}
GIT_TAG ${JSON_GIT_LABEL}
# Disable install step
......@@ -50,13 +53,13 @@ else()
# cmake does not allow calling cmake functions so we call a cmake script in the Module
# directory.
PATCH_COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/patch_json.cmake
EXCLUDE_FROM_ALL TRUE
)
endif()
#------------------------------------------------------------------------------
get_filename_component(
JSON_INCLUDE_DIR
"${EXTERNAL_PROJECTS_ROOT}/ext_json-prefix/src/ext_json/include"
ABSOLUTE)
set(JSON_INCLUDE_DIR "${JSON_INCLUDE_DIR}" PARENT_SCOPE)
ExternalProject_Get_Property(ext_json SOURCE_DIR)
add_library(libjson INTERFACE)
target_include_directories(libjson SYSTEM INTERFACE ${SOURCE_DIR}/include)
add_dependencies(libjson ext_json)
This diff is collapsed.
......@@ -16,128 +16,126 @@
include(ExternalProject)
if (NGRAPH_CPU_ENABLE AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") OR (${CMAKE_SYSTEM_NAME} MATCHES "Windows"))
message(FATAL_ERROR "The NGRAPH_USE_PREBUILT_LLVM option is not supported on this platform.")
endif()
message(STATUS "Fetching LLVM from llvm.org")
if (NGRAPH_CPU_ENABLE)
message(STATUS "Fetching LLVM from llvm.org")
find_package(ZLIB REQUIRED)
# Override default LLVM binaries
if(NOT DEFINED LLVM_TARBALL_URL)
set(LLVM_TARBALL_URL http://releases.llvm.org/5.0.1/clang+llvm-5.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz)
endif()
# Override default LLVM binaries
if(NOT DEFINED LLVM_TARBALL_URL)
set(LLVM_TARBALL_URL http://releases.llvm.org/5.0.1/clang+llvm-5.0.1-x86_64-linux-gnu-ubuntu-16.04.tar.xz)
endif()
if(NOT DEFINED LLVM_SHA1_HASH)
set(LLVM_SHA1_HASH 2fddf9a90b182fa594786be6923e58f5ead71e9c)
endif()
if(NOT DEFINED LLVM_SHA1_HASH)
set(LLVM_SHA1_HASH 2fddf9a90b182fa594786be6923e58f5ead71e9c)
endif()
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if(${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
)
else()
ExternalProject_Add(
ext_llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/ext_llvm-prefix/src/ext_llvm/lib/libLLVMCore.a"
)
endif()
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if(${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
EXCLUDE_FROM_ALL TRUE
)
else()
ExternalProject_Add(
ext_llvm
URL ${LLVM_TARBALL_URL}
URL_HASH SHA1=${LLVM_SHA1_HASH}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/ext_llvm-prefix/src/ext_llvm/lib/libLLVMCore.a"
EXCLUDE_FROM_ALL TRUE
)
endif()
ExternalProject_Get_Property(ext_llvm source_dir)
set(LLVM_INCLUDE_DIR "${source_dir}/include" PARENT_SCOPE)
set(LLVM_INCLUDE_DIR "${source_dir}/include") # used by other external projects in current scope
set(LLVM_LIB_DIR "${source_dir}/lib" PARENT_SCOPE)
ExternalProject_Get_Property(ext_llvm SOURCE_DIR)
set(LLVM_LINK_LIBS
clangTooling
clangFrontendTool
clangFrontend
clangDriver
clangSerialization
clangCodeGen
clangParse
clangSema
clangStaticAnalyzerFrontend
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangAnalysis
clangARCMigrate
clangRewriteFrontend
clangEdit
clangAST
clangLex
clangBasic
LLVMLTO
LLVMPasses
LLVMObjCARCOpts
LLVMSymbolize
LLVMDebugInfoPDB
LLVMDebugInfoDWARF
LLVMMIRParser
LLVMCoverage
LLVMTableGen
LLVMDlltoolDriver
LLVMOrcJIT
LLVMObjectYAML
LLVMLibDriver
LLVMOption
LLVMX86Disassembler
LLVMX86AsmParser
LLVMX86CodeGen
LLVMGlobalISel
LLVMSelectionDAG
LLVMAsmPrinter
LLVMDebugInfoCodeView
LLVMDebugInfoMSF
LLVMX86Desc
LLVMMCDisassembler
LLVMX86Info
LLVMX86AsmPrinter
LLVMX86Utils
LLVMMCJIT
LLVMLineEditor
LLVMInterpreter
LLVMExecutionEngine
LLVMRuntimeDyld
LLVMCodeGen
LLVMTarget
LLVMCoroutines
LLVMipo
LLVMInstrumentation
LLVMVectorize
LLVMScalarOpts
LLVMLinker
LLVMIRReader
LLVMAsmParser
LLVMInstCombine
LLVMTransformUtils
LLVMBitWriter
LLVMAnalysis
LLVMProfileData
LLVMObject
LLVMMCParser
LLVMMC
LLVMBitReader
LLVMCore
LLVMBinaryFormat
LLVMSupport
LLVMDemangle
tinfo
z
m
PARENT_SCOPE)
set(LLVM_LINK_LIBS
${SOURCE_DIR}/lib/libclangTooling.a
${SOURCE_DIR}/lib/libclangFrontendTool.a
${SOURCE_DIR}/lib/libclangFrontend.a
${SOURCE_DIR}/lib/libclangDriver.a
${SOURCE_DIR}/lib/libclangSerialization.a
${SOURCE_DIR}/lib/libclangCodeGen.a
${SOURCE_DIR}/lib/libclangParse.a
${SOURCE_DIR}/lib/libclangSema.a
${SOURCE_DIR}/lib/libclangStaticAnalyzerFrontend.a
${SOURCE_DIR}/lib/libclangStaticAnalyzerCheckers.a
${SOURCE_DIR}/lib/libclangStaticAnalyzerCore.a
${SOURCE_DIR}/lib/libclangAnalysis.a
${SOURCE_DIR}/lib/libclangARCMigrate.a
${SOURCE_DIR}/lib/libclangRewriteFrontend.a
${SOURCE_DIR}/lib/libclangEdit.a
${SOURCE_DIR}/lib/libclangAST.a
${SOURCE_DIR}/lib/libclangLex.a
${SOURCE_DIR}/lib/libclangBasic.a
${SOURCE_DIR}/lib/libLLVMLTO.a
${SOURCE_DIR}/lib/libLLVMPasses.a
${SOURCE_DIR}/lib/libLLVMObjCARCOpts.a
${SOURCE_DIR}/lib/libLLVMSymbolize.a
${SOURCE_DIR}/lib/libLLVMDebugInfoPDB.a
${SOURCE_DIR}/lib/libLLVMDebugInfoDWARF.a
${SOURCE_DIR}/lib/libLLVMMIRParser.a
${SOURCE_DIR}/lib/libLLVMCoverage.a
${SOURCE_DIR}/lib/libLLVMTableGen.a
${SOURCE_DIR}/lib/libLLVMDlltoolDriver.a
${SOURCE_DIR}/lib/libLLVMOrcJIT.a
${SOURCE_DIR}/lib/libLLVMObjectYAML.a
${SOURCE_DIR}/lib/libLLVMLibDriver.a
${SOURCE_DIR}/lib/libLLVMOption.a
${SOURCE_DIR}/lib/libLLVMX86Disassembler.a
${SOURCE_DIR}/lib/libLLVMX86AsmParser.a
${SOURCE_DIR}/lib/libLLVMX86CodeGen.a
${SOURCE_DIR}/lib/libLLVMGlobalISel.a
${SOURCE_DIR}/lib/libLLVMSelectionDAG.a
${SOURCE_DIR}/lib/libLLVMAsmPrinter.a
${SOURCE_DIR}/lib/libLLVMDebugInfoCodeView.a
${SOURCE_DIR}/lib/libLLVMDebugInfoMSF.a
${SOURCE_DIR}/lib/libLLVMX86Desc.a
${SOURCE_DIR}/lib/libLLVMMCDisassembler.a
${SOURCE_DIR}/lib/libLLVMX86Info.a
${SOURCE_DIR}/lib/libLLVMX86AsmPrinter.a
${SOURCE_DIR}/lib/libLLVMX86Utils.a
${SOURCE_DIR}/lib/libLLVMMCJIT.a
${SOURCE_DIR}/lib/libLLVMLineEditor.a
${SOURCE_DIR}/lib/libLLVMInterpreter.a
${SOURCE_DIR}/lib/libLLVMExecutionEngine.a
${SOURCE_DIR}/lib/libLLVMRuntimeDyld.a
${SOURCE_DIR}/lib/libLLVMCodeGen.a
${SOURCE_DIR}/lib/libLLVMTarget.a
${SOURCE_DIR}/lib/libLLVMCoroutines.a
${SOURCE_DIR}/lib/libLLVMipo.a
${SOURCE_DIR}/lib/libLLVMInstrumentation.a
${SOURCE_DIR}/lib/libLLVMVectorize.a
${SOURCE_DIR}/lib/libLLVMScalarOpts.a
${SOURCE_DIR}/lib/libLLVMLinker.a
${SOURCE_DIR}/lib/libLLVMIRReader.a
${SOURCE_DIR}/lib/libLLVMAsmParser.a
${SOURCE_DIR}/lib/libLLVMInstCombine.a
${SOURCE_DIR}/lib/libLLVMTransformUtils.a
${SOURCE_DIR}/lib/libLLVMBitWriter.a
${SOURCE_DIR}/lib/libLLVMAnalysis.a
${SOURCE_DIR}/lib/libLLVMProfileData.a
${SOURCE_DIR}/lib/libLLVMObject.a
${SOURCE_DIR}/lib/libLLVMMCParser.a
${SOURCE_DIR}/lib/libLLVMMC.a
${SOURCE_DIR}/lib/libLLVMBitReader.a
${SOURCE_DIR}/lib/libLLVMCore.a
${SOURCE_DIR}/lib/libLLVMBinaryFormat.a
${SOURCE_DIR}/lib/libLLVMSupport.a
${SOURCE_DIR}/lib/libLLVMDemangle.a
tinfo
z
m
)
endif()
add_library(libllvm INTERFACE)
target_include_directories(libllvm SYSTEM INTERFACE ${SOURCE_DIR}/include)
target_link_libraries(libllvm INTERFACE ${LLVM_LINK_LIBS})
......@@ -16,83 +16,96 @@
include(ExternalProject)
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Fetch and install MKL-DNN
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
if(NGRAPH_CPU_ENABLE)
# User provided mkl-dnn
if(MKLDNN_INCLUDE_DIR AND MKLDNN_LIB_DIR)
ExternalProject_Add(
ext_mkldnn
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
return()
endif()
set(MKLDNN_GIT_REPO_URL https://github.com/intel/mkl-dnn)
set(MKLDNN_GIT_TAG "0e7ca73")
if(MKLDNN_INCLUDE_DIR AND MKLDNN_LIB_DIR)
ExternalProject_Add(
ext_mkldnn
DOWNLOAD_COMMAND ""
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
add_library(libmkldnn INTERFACE)
target_include_directories(libmkldnn SYSTEM INTERFACE ${MKLDNN_INCLUDE_DIR})
target_link_libraries(libmkldnn INTERFACE
${MKLDNN_LIB_DIR}/libmkldnn.so
${MKLDNN_LIB_DIR}/libmklml_intel.so
${MKLDNN_LIB_DIR}/libiomp5.so
)
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if(${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_mkldnn
GIT_REPOSITORY ${MKLDNN_GIT_REPO_URL}
GIT_TAG ${MKLDNN_GIT_TAG}
UPDATE_COMMAND ""
# Uncomment below with any in-flight MKL-DNN patches
# PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/third-party/patches/mkldnn-cmake-openmp.patch
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn"
)
else()
ExternalProject_Add(
ext_mkldnn
GIT_REPOSITORY ${MKLDNN_GIT_REPO_URL}
GIT_TAG ${MKLDNN_GIT_TAG}
UPDATE_COMMAND ""
# Uncomment below with any in-flight MKL-DNN patches
# PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/third-party/patches/mkldnn-cmake-openmp.patch
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/mkldnn/include/mkldnn.hpp"
)
endif()
install(DIRECTORY ${MKLDNN_LIB_DIR}/ DESTINATION ${NGRAPH_INSTALL_LIB})
return()
endif()
ExternalProject_Get_Property(ext_mkldnn source_dir binary_dir)
set(MKLDNN_GIT_REPO_URL https://github.com/intel/mkl-dnn)
set(MKLDNN_GIT_TAG "0e7ca73")
ExternalProject_Add_Step(
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if(${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_mkldnn
PrepareMKL
COMMAND ${source_dir}/scripts/prepare_mkl.sh
DEPENDEES download
DEPENDERS configure
GIT_REPOSITORY ${MKLDNN_GIT_REPO_URL}
GIT_TAG ${MKLDNN_GIT_TAG}
UPDATE_COMMAND ""
# Uncomment below with any in-flight MKL-DNN patches
# PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/third-party/patches/mkldnn-cmake-openmp.patch
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn"
EXCLUDE_FROM_ALL TRUE
)
else()
ExternalProject_Add(
ext_mkldnn
GIT_REPOSITORY ${MKLDNN_GIT_REPO_URL}
GIT_TAG ${MKLDNN_GIT_TAG}
UPDATE_COMMAND ""
# Uncomment below with any in-flight MKL-DNN patches
# PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/third-party/patches/mkldnn-cmake-openmp.patch
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/mkldnn/include/mkldnn.hpp"
EXCLUDE_FROM_ALL TRUE
)
endif()
ExternalProject_Get_Property(ext_mkldnn source_dir binary_dir)
set(MKLDNN_INCLUDE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/include" PARENT_SCOPE)
set(MKLDNN_LIB_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/lib" PARENT_SCOPE)
ExternalProject_Add_Step(
ext_mkldnn
PrepareMKL
COMMAND ${source_dir}/scripts/prepare_mkl.sh
DEPENDEES download
DEPENDERS configure
)
endif()
add_library(libmkldnn INTERFACE)
target_include_directories(libmkldnn SYSTEM INTERFACE ${EXTERNAL_PROJECTS_ROOT}/mkldnn/include)
target_link_libraries(libmkldnn INTERFACE
${EXTERNAL_PROJECTS_ROOT}/mkldnn/lib/libmkldnn.so
${EXTERNAL_PROJECTS_ROOT}/mkldnn/lib/libmklml_intel.so
${EXTERNAL_PROJECTS_ROOT}/mkldnn/lib/libiomp5.so
)
install(DIRECTORY ${EXTERNAL_PROJECTS_ROOT}/mkldnn/lib/ DESTINATION ${NGRAPH_INSTALL_LIB})
......@@ -14,9 +14,9 @@
# limitations under the License.
# ******************************************************************************
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Fetch and configure TBB
#----------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------
if(NGRAPH_TBB_ENABLE)
set(TBB_GIT_REPO_URL https://github.com/01org/tbb)
......@@ -28,5 +28,5 @@ if(NGRAPH_TBB_ENABLE)
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tbb")
set(TBB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/tbb/tbb-src PARENT_SCOPE)
set(TBB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/tbb/tbb-src)
endif()
......@@ -14,55 +14,9 @@
# limitations under the License.
# ******************************************************************************
if(MKLDNN_INCLUDE_DIR)
link_directories(${MKLDNN_LIB_DIR})
endif()
if (NGRAPH_CPU_ENABLE)
set(HEADER_SEARCH_DEFINES
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
)
# abc
set (ABC_SRC
${PROJECT_SOURCE_DIR}/doc/examples/abc.cpp
)
set_source_files_properties(${ABC_SRC} PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
add_executable(abc ${ABC_SRC})
add_dependencies(abc ngraph)
target_link_libraries(abc ngraph)
# abc_op
set (ABC_OP_SRC
${PROJECT_SOURCE_DIR}/doc/examples/abc_operator.cpp
)
set_source_files_properties(${ABC_OP_SRC} PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
add_executable(abc_op ${ABC_OP_SRC})
add_dependencies(abc_op ngraph)
target_link_libraries(abc_op ngraph)
# update
set (UPDATE_SRC
${PROJECT_SOURCE_DIR}/doc/examples/update.cpp
)
set_source_files_properties(${UPDATE_SRC} PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
add_executable(update ${UPDATE_SRC})
add_dependencies(update ngraph)
target_link_libraries(update ngraph)
# mnist_mlp
set(MNIST_SRC
${PROJECT_SOURCE_DIR}/doc/examples/mnist_loader.cpp
${PROJECT_SOURCE_DIR}/doc/examples/mnist_mlp.cpp
)
set_source_files_properties(${MNIST_SRC} PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
add_executable(mnist_mlp ${MNIST_SRC})
add_dependencies(mnist_mlp ngraph)
target_link_libraries(mnist_mlp ngraph)
add_subdirectory(abc)
add_subdirectory(abc_operator)
add_subdirectory(mnist_mlp)
add_subdirectory(update)
endif()
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
add_executable(abc abc.cpp)
add_dependencies(abc ngraph cpu_backend)
target_link_libraries(abc ngraph cpu_backend)
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
add_executable(abc_op abc_operator.cpp)
add_dependencies(abc_op ngraph cpu_backend)
target_link_libraries(abc_op ngraph cpu_backend)
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
add_executable(mnist_mlp mnist_loader.cpp mnist_mlp.cpp)
add_dependencies(mnist_mlp ngraph cpu_backend)
target_link_libraries(mnist_mlp ngraph cpu_backend)
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
add_executable(update update.cpp)
add_dependencies(update ngraph cpu_backend)
target_link_libraries(update ngraph cpu_backend)
......@@ -16,6 +16,8 @@
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DIN_NGRAPH_LIBRARY")
include_directories(ngraph)
add_subdirectory(resource)
add_subdirectory(ngraph)
......
This diff is collapsed.
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
set(SRC
code_writer.cpp
compiler.cpp
execution_engine.cpp
)
# LLVM binary builds are typically built without RTTI
# The built-in headers are in a version-specific directory
# This must be kept in sync with the LLVM + Clang version in use
set_source_files_properties(compiler.cpp PROPERTIES COMPILE_FLAGS "-fno-rtti")
get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(EIGEN_INCLUDE_DIR libeigen INTERFACE_INCLUDE_DIRECTORIES)
set(HEADER_SEARCH_DEFINES
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\""
"MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\""
"CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}/clang/5.0.1/include\""
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
"INSTALLED_HEADERS_PATH=\"${CMAKE_INSTALL_PREFIX}/include\""
)
if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
string(REPLACE ";" "\\;" MPI_C_INCLUDE_PATH "${MPI_C_INCLUDE_PATH}")
add_definitions("-DMPI_HEADER_PATH=\"${MPI_C_INCLUDE_PATH}\"")
add_definitions(-DNGRAPH_DISTRIBUTED)
endif()
if(NGRAPH_GPU_ENABLE)
find_package(CUDA 8 REQUIRED)
find_package(CUDNN 7 REQUIRED)
list(APPEND HEADER_SEARCH_DEFINES "CUDA_HEADER_PATHS=\"${CUDA_INCLUDE_DIRS}\"")
list(APPEND HEADER_SEARCH_DEFINES "CUDNN_HEADER_PATHS=\"${CUDNN_INCLUDE_DIRS}\"")
endif()
set_source_files_properties(compiler.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
# Generate the resource file containing all headers used by the codegen compiler
add_custom_target(header_resource
resource_generator --output ${CMAKE_BINARY_DIR}/header_resource.hpp --base codegen
DEPENDS resource_generator ext_eigen ext_llvm ext_mkldnn
BYPRODUCTS
)
# The conditional is a hack. I want to use EXCLUDE_FROM_ALL and OPTIONAL but that does not
# seem to be working for me.
if (NGRAPH_CPU_ENABLE OR NGRAPH_GPU_ENABLE)
add_library(codegen SHARED ${SRC})
set_target_properties(codegen PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION})
add_dependencies(codegen header_resource)
target_include_directories(codegen SYSTEM PUBLIC ${CMAKE_BINARY_DIR})
target_link_libraries(codegen PRIVATE libllvm)
target_link_libraries(codegen PUBLIC libmkldnn libeigen pthread dl)
install(TARGETS codegen DESTINATION ${NGRAPH_INSTALL_LIB})
endif()
......@@ -273,7 +273,6 @@ void codegen::StaticCompiler::add_header_search_path(const string& p)
}
}
}
std::unique_ptr<codegen::Module>
codegen::StaticCompiler::compile(std::unique_ptr<clang::CodeGenAction>& m_compiler_action,
const string& source)
......
......@@ -14,17 +14,12 @@
# limitations under the License.
# ******************************************************************************
if(NOT DEFINED EXTERNAL_PROJECTS_ROOT)
set(EXTERNAL_PROJECTS_ROOT ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(interpreter)
if (NGRAPH_CPU_ENABLE)
add_subdirectory(cpu)
endif()
include( ../cmake/external_gtest.cmake )
include( ../cmake/external_json.cmake )
include( ../cmake/external_eigen.cmake )
include( ../cmake/external_mkldnn.cmake )
if (NGRAPH_USE_PREBUILT_LLVM OR DEFINED LLVM_TARBALL_URL)
include( ../cmake/external_llvm_prebuilt.cmake )
else()
include( ../cmake/external_llvm.cmake )
if (NGRAPH_GPU_ENABLE)
add_subdirectory(gpu)
endif()
include( ../cmake/external_tbb.cmake )
......@@ -42,8 +42,11 @@ runtime::Backend::~Backend()
void* runtime::Backend::open_shared_library(const string& type)
{
string ext = SHARED_LIB_EXT;
string ver = LIBRARY_VERSION;
void* handle = nullptr;
string name = "lib" + to_lower(type) + "_backend.so";
string name = "lib" + to_lower(type) + "_backend" + ext;
handle = dlopen(name.c_str(), RTLD_NOW | RTLD_GLOBAL);
if (handle)
{
......@@ -60,7 +63,7 @@ void* runtime::Backend::open_shared_library(const string& type)
else
{
string err = dlerror();
throw runtime_error("Failed to find Backend library '" + name + "'\n" + err);
throw runtime_error("Library open for Backend '" + name + "' failed with error:\n" + err);
}
return handle;
}
......
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
set(SRC
cpu_backend.cpp
cpu_call_frame.cpp
cpu_emitter.cpp
cpu_external_function.cpp
cpu_kernel_emitters.cpp
cpu_kernel_utils.cpp
cpu_kernels.cpp
cpu_layout_descriptor.cpp
cpu_tensor_view_wrapper.cpp
cpu_tensor_view.cpp
cpu_tracing.cpp
kernel/eigen_thread_pool.cpp
kernel/pad.cpp
kernel/reduce_max.cpp
kernel/reduce_sum.cpp
kernel/reshape.cpp
mkldnn_emitter.cpp
mkldnn_invoke.cpp
mkldnn_utils.cpp
op/batch_norm_relu.cpp
op/conv_bias.cpp
op/conv_relu.cpp
op/convert_layout.cpp
op/lstm.cpp
op/matmul_bias.cpp
op/max_pool_with_indices.cpp
op/rnn.cpp
op/sigmoid_mul.cpp
op/sigmoid.cpp
pass/cpu_assignment.cpp
pass/cpu_concat_inputs.cpp
pass/cpu_fusion.cpp
pass/cpu_layout.cpp
pass/cpu_post_layout_optimizations.cpp
pass/cpu_rnn_fusion.cpp
pass/cpu_rnn_mat_fusion.cpp
pass/cpu_shuffle_folding.cpp
pass/cpu_workspace_insertion.cpp
)
if (NGRAPH_TBB_ENABLE)
include(${TBB_ROOT}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${TBB_ROOT} MAKE_ARGS tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_build
tbb_build_prefix=tbb CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb)
if (NOT TBB_FOUND)
message(FATAL_ERROR "TBB is needed by the CPU backend and was not found")
else()
message(STATUS "Found TBB and imported target ${TBB_IMPORTED_TARGETS}")
endif()
set_source_files_properties(cpu_external_function.cpp
PROPERTIES COMPILE_DEFINITIONS "NGRAPH_TBB_ENABLE")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb_build/tbb_release/
DESTINATION ${NGRAPH_INSTALL_LIB}
FILES_MATCHING REGEX "/libtbb${CMAKE_SHARED_LIBRARY_SUFFIX}(\\.[0-9]+)*$"
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb_build/tbb_debug/
DESTINATION ${NGRAPH_INSTALL_LIB}
FILES_MATCHING REGEX "/libtbb_debug${CMAKE_SHARED_LIBRARY_SUFFIX}(\\.[0-9]+)*$"
)
add_library(libtbb INTERFACE)
target_link_libraries(libtbb INTERFACE
${CMAKE_CURRENT_BINARY_DIR}/tbb_build/tbb_release/libtbb${CMAKE_SHARED_LIBRARY_SUFFIX}
)
target_include_directories(libtbb SYSTEM INTERFACE ${TBB_ROOT}/include)
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})
set_target_properties(cpu_backend PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION})
if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
target_link_libraries(cpu_backend PRIVATE ${MPI_CXX_LIBRARIES})
endif()
target_link_libraries(cpu_backend PUBLIC ngraph codegen libmkldnn libeigen libjson libtbb)
target_include_directories(cpu_backend SYSTEM PUBLIC libmkldnn)
install(TARGETS cpu_backend LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB})
endif()
......@@ -14,8 +14,10 @@
* limitations under the License.
*******************************************************************************/
#include "ngraph/runtime/cpu/cpu_backend.hpp"
#include <tbb/tbb_stddef.h>
#include "ngraph/graph_util.hpp"
#include "ngraph/runtime/cpu/cpu_backend.hpp"
#include "ngraph/runtime/cpu/cpu_call_frame.hpp"
#include "ngraph/runtime/cpu/cpu_external_function.hpp"
#include "ngraph/runtime/cpu/cpu_tensor_view.hpp"
......@@ -24,14 +26,13 @@
using namespace ngraph;
using namespace std;
static bool static_init()
extern "C" void create_backend()
{
// Force TBB to link to the backend
tbb::TBB_runtime_interface_version();
runtime::Backend::register_backend("CPU", make_shared<runtime::cpu::CPU_Backend>());
return true;
};
bool runtime::cpu::CPU_Backend::init = static_init();
shared_ptr<runtime::cpu::CPU_CallFrame> runtime::cpu::CPU_Backend::make_call_frame(
const shared_ptr<runtime::cpu::CPU_ExternalFunction>& external_function)
{
......
......@@ -66,7 +66,6 @@ namespace ngraph
};
std::map<std::shared_ptr<Function>, FunctionInstance> m_function_map;
static bool init;
};
}
}
......
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIRS})
# Add sources for the GPU backend
# and all its dependencies
set(SRC
cuda_emitter.cpp
cudnn_emitter.cpp
gpu_backend.cpp
gpu_call_frame.cpp
gpu_cuda_context_manager.cpp
gpu_cuda_function_builder.cpp
gpu_cuda_function_pool.cpp
gpu_cuda_kernel_builder.cpp
gpu_cuda_kernel_emitters.cpp
gpu_emitter.cpp
gpu_external_function.cpp
gpu_invoke.cpp
gpu_kernel_emitters.cpp
gpu_memory_manager.cpp
gpu_primitive_emitter.cpp
gpu_runtime_context.cpp
gpu_tensor_view_wrapper.cpp
gpu_tensor_view.cpp
gpu_util.cpp
type_info.cpp
)
if (NGRAPH_GPU_ENABLE)
add_library(gpu_backend SHARED ${SRC})
set_target_properties(gpu_backend PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION})
target_link_libraries(gpu_backend PUBLIC ngraph codegen)
find_library(CUDA_nvrtc_LIBRARY nvrtc /usr/local/cuda/lib64)
find_library(CUDA_cuda_LIBRARY cuda /usr/local/cuda/lib64/stubs)
find_package(CUDA 8 REQUIRED)
find_package(CUDNN 7 REQUIRED)
target_include_directories(gpu_backend SYSTEM PUBLIC ${CUDA_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIR})
target_link_libraries(gpu_backend PUBLIC
${CUDA_cuda_LIBRARY}
${CUDA_nvrtc_LIBRARY}
${CUDA_LIBRARIES}
${CUDA_CUBLAS_LIBRARIES}
${CUDNN_LIBRARIES})
install(TARGETS gpu_backend LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB})
endif()
......@@ -23,14 +23,11 @@
using namespace ngraph;
using namespace std;
static bool static_init()
extern "C" void create_backend()
{
runtime::Backend::register_backend("GPU", make_shared<runtime::gpu::GPU_Backend>());
return true;
};
bool runtime::gpu::GPU_Backend::init = static_init();
shared_ptr<runtime::gpu::GPU_CallFrame> runtime::gpu::GPU_Backend::make_call_frame(
const shared_ptr<GPU_ExternalFunction>& external_function)
{
......
......@@ -63,7 +63,6 @@ namespace ngraph
};
std::map<std::shared_ptr<Function>, FunctionInstance> m_function_map;
static bool init;
};
}
}
......
# ******************************************************************************
# Copyright 2017-2018 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.
# ******************************************************************************
if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
link_libraries(${MPI_CXX_LIBRARIES})
endif()
if (NGRAPH_INTERPRETER_ENABLE)
add_library(interpreter_backend SHARED int_backend.cpp)
set_target_properties(interpreter_backend PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION})
target_link_libraries(interpreter_backend PUBLIC ngraph)
install(TARGETS interpreter_backend LIBRARY DESTINATION ${NGRAPH_INSTALL_LIB})
endif()
......@@ -29,15 +29,12 @@ using namespace ngraph;
using descriptor::layout::DenseTensorViewLayout;
static bool static_init()
extern "C" void create_backend()
{
runtime::Backend::register_backend("INTERPRETER",
make_shared<runtime::interpreter::INTBackend>());
return true;
};
bool runtime::interpreter::INTBackend::init = static_init();
shared_ptr<runtime::TensorView>
runtime::interpreter::INTBackend::create_tensor(const element::Type& type, const Shape& shape)
{
......
......@@ -158,7 +158,6 @@ private:
std::unordered_map<const Node*, stopwatch> m_timer_map;
};
std::map<std::shared_ptr<Function>, FunctionInstance> m_function_map;
static bool init;
static void perform_nan_check(const std::vector<std::shared_ptr<HostTensorView>>&,
const Node* op = nullptr);
......
......@@ -14,28 +14,42 @@
# limitations under the License.
# ******************************************************************************
if (NGRAPH_CPU_ENABLE)
set (SRC
main.cpp
util.cpp
uncomment.cpp
header_rewrite.cpp
)
add_executable(resource_generator ${SRC})
add_dependencies(resource_generator ext_llvm ext_eigen ext_mkldnn)
set(HEADER_SEARCH_DEFINES
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\""
"MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\""
"CLANG_BUILTIN_HEADERS_PATH=\"${LLVM_LIB_DIR}/clang/5.0.1/include\""
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
)
if(NGRAPH_TBB_ENABLE)
list(APPEND HEADER_SEARCH_DEFINES "TBB_HEADERS_PATH=\"${TBB_ROOT}/include\"")
set(HEADER_SEARCH_DEFINES ${HEADER_SEARCH_DEFINES} "NGRAPH_TBB_ENABLE")
endif()
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
set (SRC
main.cpp
util.cpp
uncomment.cpp
header_rewrite.cpp
)
get_target_property(MKLDNN_INCLUDE_DIR libmkldnn INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(EIGEN_INCLUDE_DIR libeigen INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(LLVM_INCLUDE_DIR libllvm INTERFACE_INCLUDE_DIRECTORIES)
set(CLANG_INCLUDE_DIR ${LLVM_INCLUDE_DIR}/../lib/clang/5.0.1/include)
get_filename_component(CLANG_INCLUDE_DIR ${CLANG_INCLUDE_DIR} ABSOLUTE)
set(HEADER_SEARCH_DEFINES
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\""
"MKLDNN_HEADERS_PATH=\"${MKLDNN_INCLUDE_DIR}\""
"CLANG_BUILTIN_HEADERS_PATH=\"${CLANG_INCLUDE_DIR}\""
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
)
if(NGRAPH_TBB_ENABLE)
list(APPEND HEADER_SEARCH_DEFINES "TBB_HEADERS_PATH=\"${TBB_ROOT}/include\"")
list(APPEND HEADER_SEARCH_DEFINES "NGRAPH_TBB_ENABLE")
endif()
if (NGRAPH_GPU_ENABLE)
find_package(CUDA 8 REQUIRED)
find_package(CUDNN 7 REQUIRED)
set_property(SOURCE codegen/compiler.cpp APPEND_STRING PROPERTY COMPILE_DEFINITIONS
"CUDA_HEADER_PATHS=\"${CUDA_INCLUDE_DIRS}\";")
set_property(SOURCE codegen/compiler.cpp APPEND_STRING PROPERTY COMPILE_DEFINITIONS
"CUDNN_HEADER_PATHS=\"${CUDNN_INCLUDE_DIRS}\";")
endif()
add_executable(resource_generator EXCLUDE_FROM_ALL ${SRC})
add_dependencies(resource_generator ext_llvm ext_eigen ext_mkldnn)
set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
......@@ -14,25 +14,7 @@
# limitations under the License.
# ******************************************************************************
if(MKLDNN_INCLUDE_DIR)
link_directories(${MKLDNN_LIB_DIR})
endif()
if (NGRAPH_CPU_ENABLE)
set (SRC
compile_benchmark.cpp
${PROJECT_SOURCE_DIR}/test/util/benchmark.cpp
)
add_executable(compile_benchmark ${SRC})
add_dependencies(compile_benchmark ngraph)
set(HEADER_SEARCH_DEFINES
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
)
target_link_libraries(compile_benchmark ngraph)
include_directories("${PROJECT_SOURCE_DIR}/test")
set_source_files_properties(compile_benchmark.cpp PROPERTIES COMPILE_DEFINITIONS "${HEADER_SEARCH_DEFINES}")
add_executable(compile_benchmark compile_benchmark.cpp)
target_link_libraries(compile_benchmark ngraph cpu_backend)
endif()
......@@ -25,7 +25,7 @@ if (NGRAPH_CPU_ENABLE)
)
add_executable(nbench ${SRC})
add_dependencies(nbench ngraph)
add_dependencies(nbench ngraph cpu_backend)
set(HEADER_SEARCH_DEFINES
"NGRAPH_HEADERS_PATH=\"${NGRAPH_INCLUDE_PATH}\""
......
......@@ -14,17 +14,6 @@
# limitations under the License.
# ******************************************************************************
if(MKLDNN_INCLUDE_DIR)
link_directories(${MKLDNN_LIB_DIR})
endif()
if (NGRAPH_CPU_ENABLE)
set (SRC
reserialize.cpp
)
add_executable(reserialize ${SRC})
add_dependencies(reserialize ngraph)
target_link_libraries(reserialize ngraph)
endif()
add_executable(reserialize reserialize.cpp)
add_dependencies(reserialize ngraph)
target_link_libraries(reserialize ngraph)
......@@ -14,17 +14,8 @@
# limitations under the License.
# ******************************************************************************
include_directories(
SYSTEM
${GTEST_INCLUDE_DIR}
${EIGEN_INCLUDE_DIR}
)
set (SRC
backend_api.cpp
set(SRC
algebraic_simplification.cpp
backend_debug_api.cpp
builder.cpp
builder_autobroadcast.cpp
build_graph.cpp
copy.cpp
......@@ -54,53 +45,22 @@ set (SRC
zero_dim_tensor_elimination.cpp
)
if (NGRAPH_INTERPRETER_ENABLE)
set(SRC ${SRC} backend_debug_api.cpp builder.cpp backend_api.cpp)
endif()
add_subdirectory(models)
add_subdirectory(files)
add_subdirectory(util)
#================================================================================================
# To auto generate a suite of unit tests for a backend add a line like this
# set(BACKEND_NAMES ${BACKEND_NAMES} "BACKEND_NAME_GOES_HERE")
# and replace BACKEND_NAME_GOES_HERE with your backend name.
# The code for the unit test suite is in test/backend_test.in.cpp
#================================================================================================
# TODO add interpreter back to unit tests when it works
set(BACKEND_NAMES ${BACKEND_NAMES} "INTERPRETER")
if(MKLDNN_INCLUDE_DIR)
include_directories(SYSTEM ${MKLDNN_INCLUDE_DIR})
link_directories(${MKLDNN_LIB_DIR})
set(SRC ${SRC} mkldnn.cpp)
endif()
if(NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR)
include_directories(SYSTEM ${LLVM_INCLUDE_DIR})
link_directories(${LLVM_LIB_DIR})
if(NGRAPH_CPU_ENABLE)
set(SRC ${SRC} backend_performance.cpp codegen.cpp cpu_fusion.cpp cpu_test.cpp)
set(BACKEND_NAMES ${BACKEND_NAMES} "CPU")
endif()
if(NGRAPH_GPU_ENABLE AND LLVM_INCLUDE_DIR)
include_directories(SYSTEM ${LLVM_INCLUDE_DIR} ${CUDA_INCLUDE_DIRS} ${CUDNN_INCLUDE_DIR})
link_directories(${LLVM_LIB_DIR})
link_directories(${CUDA_LIBRARIES})
link_directories(${CUDA_CUBLAS_LIBRARIES})
link_directories(${CUDNN_LIBRARIES})
if(NGRAPH_GPU_ENABLE)
set(SRC ${SRC} cudnn.cpp gpu_test.cpp)
# Disabled for testing
set(BACKEND_NAMES ${BACKEND_NAMES} "GPU")
endif()
if(NGRAPH_DISTRIBUTED_ENABLE AND MPI_C_INCLUDE_PATH)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
foreach(BACKEND_NAME ${BACKEND_NAMES})
configure_file(distributed.cpp distributed_${BACKEND_NAME}.cpp)
set(SRC ${SRC} ${CMAKE_CURRENT_BINARY_DIR}/distributed_${BACKEND_NAME}.cpp)
endforeach()
endif()
foreach(TEST_CONFIG ${UNIT_TEST_CONFIG_LIST})
string(FIND ${TEST_CONFIG} "@" OFFSET)
string(SUBSTRING ${TEST_CONFIG} 0 ${OFFSET} BACKEND_NAME)
......@@ -111,6 +71,10 @@ foreach(TEST_CONFIG ${UNIT_TEST_CONFIG_LIST})
configure_file(convolution_test.in.cpp convolution_test_${BACKEND_NAME}.cpp)
set(SRC ${SRC} ${CMAKE_CURRENT_BINARY_DIR}/backend_test_${BACKEND_NAME}.cpp)
set(SRC ${SRC} ${CMAKE_CURRENT_BINARY_DIR}/convolution_test_${BACKEND_NAME}.cpp)
if(NGRAPH_DISTRIBUTED_ENABLE)
configure_file(distributed.cpp distributed_${BACKEND_NAME}.cpp)
set(SRC ${SRC} ${CMAKE_CURRENT_BINARY_DIR}/distributed_${BACKEND_NAME}.cpp)
endif()
# Some---but not all---autodiff tests go through multiple iterations with
# different random seeds. On the CPU backend this is currently very slow
......@@ -139,35 +103,37 @@ if(NGRAPH_ADDRESS_SANITIZER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -fsanitize=address -fno-omit-frame-pointer")
endif()
if(NGRAPH_DISTRIBUTED_ENABLE)
find_package(MPI REQUIRED)
add_definitions(-DNGRAPH_DISTRIBUTED)
include_directories(SYSTEM ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH})
link_directories(${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES})
link_libraries(${MPI_CXX_LIBRARIES})
endif()
add_executable(unit-test ${SRC})
target_link_libraries(unit-test ngraph_test_util)
add_dependencies(unit-test ngraph_test_util)
target_link_libraries(unit-test ngraph libgtest libjson pthread)
target_link_libraries(unit-test ${CMAKE_DL_LIBS})
if(MPI_C_INCLUDE_PATH)
target_link_libraries(unit-test ${MPI_CXX_LIBRARIES})
if (NGRAPH_CPU_ENABLE)
# The INTERPRETER backend is required for graph_partition, convolution, and backwards unit tests
target_link_libraries(unit-test cpu_backend interpreter_backend)
endif()
if(MKLDNN_INCLUDE_DIR)
target_link_libraries(unit-test mkldnn)
add_dependencies(unit-test ext_mkldnn)
if (NGRAPH_TBB_ENABLE)
add_definitions(-DNGRAPH_TBB_ENABLE)
endif()
if(LLVM_INCLUDE_DIR)
target_link_libraries(unit-test ${LLVM_LINK_LIBS})
add_dependencies(unit-test ext_llvm)
if (NGRAPH_INTERPRETER_ENABLE)
add_definitions(-DNGRAPH_INTERPRETER_ENABLE)
target_link_libraries(unit-test interpreter_backend)
endif()
if(CUDA_INCLUDE_DIRS)
find_library(CUDA_NVRTC_LIBRARY nvrtc /usr/local/cuda/lib64)
target_link_libraries(unit-test ${CUDA_NVRTC_LIBRARY} ${CUDA_LIBRARIES} ${CUDNN_LIBRARIES} ${CUDA_CUBLAS_LIBRARIES})
if (NGRAPH_GPU_ENABLE)
target_link_libraries(unit-test gpu_backend)
endif()
target_link_libraries(unit-test ngraph libgtest pthread)
target_link_libraries(unit-test ${CMAKE_DL_LIBS})
add_dependencies(unit-test ngraph libgtest ext_json)
include_directories(SYSTEM ${JSON_INCLUDE_DIR})
add_custom_target(style-check
COMMAND ${PROJECT_SOURCE_DIR}/maint/check-code-format.sh
)
......
......@@ -26,7 +26,6 @@
#include "ngraph/log.hpp"
#include "ngraph/op/concat.hpp"
#include "ngraph/runtime/backend.hpp"
#include "ngraph/runtime/cpu/cpu_call_frame.hpp"
#include "ngraph/serializer.hpp"
#include "ngraph/util.hpp"
#include "util/benchmark.hpp"
......
......@@ -4859,6 +4859,7 @@ NGRAPH_TEST(${BACKEND_NAME}, numeric_double_inf)
EXPECT_EQ((vector<char>{false, false, true, false, false}), read_vector<char>(result));
}
#ifdef NGRAPH_TBB_ENABLE
NGRAPH_TEST(${BACKEND_NAME}, abc_tbb)
{
// Force TBB flow graph generation in the CPU backend
......@@ -4904,6 +4905,7 @@ NGRAPH_TEST(${BACKEND_NAME}, abc_tbb)
unsetenv("NGRAPH_CPU_USE_TBB");
}
}
#endif // NGRAPH_TBB_ENABLE
//
// The unit tests for ReduceWindow follow exactly what we test for MaxPool---but they use ReduceWindow to do it.
......
/*******************************************************************************
* Copyright 2017-2018 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.
*******************************************************************************/
#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
......
......@@ -500,7 +500,6 @@ TEST(graph_partition, hybrid_multi_middle_nodes)
EXPECT_EQ(read_vector<float>(r),
(test::NDArray<float, 2>({{210, 288}, {378, 480}})).get_vector());
}
#endif
TEST(graph_partition, hybrid_no_split)
{
......@@ -526,3 +525,5 @@ TEST(graph_partition, hybrid_no_split)
backend->call(f, {c}, {a, b});
EXPECT_EQ(read_vector<float>(c), (test::NDArray<float, 2>({{6, 8}, {10, 12}})).get_vector());
}
#endif
......@@ -45,6 +45,7 @@ T get_or_default(nlohmann::json& j, const std::string& key, const T& default_val
return rc;
}
#if defined(NGRAPH_INTERPRETER_ENABLE)
TEST(serialize, main)
{
// First create "f(A,B,C) = (A+B)*C".
......@@ -102,6 +103,7 @@ TEST(serialize, main)
backend->call(sfunc, {result}, {x, z, y});
EXPECT_EQ((vector<float>{200, 288, 392, 512}), read_vector<float>(result));
}
#endif
TEST(serialize, existing_models)
{
......
......@@ -101,11 +101,13 @@ void test_read_write(const vector<T>& x)
ASSERT_EQ(result1, result2);
}
#if defined(NGRAPH_INTERPRETER_ENABLE)
TEST(tensor, read_write)
{
test_read_write<float>({1.0, 3.0, 5.0});
test_read_write<int64_t>({-1, 2, 4});
}
#endif
TEST(tensor, output_flag)
{
......
......@@ -143,6 +143,7 @@ TEST(util, contains)
EXPECT_FALSE(contains(v1, 8));
}
#if defined(NGRAPH_INTERPRETER_ENABLE)
TEST(util, all_close)
{
auto backend = runtime::Backend::create("INTERPRETER");
......@@ -165,6 +166,7 @@ TEST(util, all_close)
EXPECT_FALSE(ngraph::test::all_close<float>(c, a, .05f, 0));
EXPECT_TRUE(ngraph::test::all_close<float>(c, a, .11f, 0));
}
#endif
TEST(util, traverse_functions)
{
......
......@@ -30,6 +30,7 @@ include_directories(
)
add_library(ngraph_test_util SHARED ${SRC})
set_target_properties(ngraph_test_util PROPERTIES VERSION ${NGRAPH_VERSION} SOVERSION ${NGRAPH_API_VERSION})
target_link_libraries(ngraph_test_util ngraph libgtest)
add_dependencies(ngraph_test_util ngraph libgtest)
......
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