ngraph.cmake 3.0 KB
Newer Older
S
Sang Ik Lee 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
#
# 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.

S
Sang Ik Lee 已提交
15 16
INCLUDE(GNUInstallDirs)

S
Sang Ik Lee 已提交
17 18 19
INCLUDE(ExternalProject)

SET(NGRAPH_PROJECT         "extern_ngraph")
20
SET(NGRAPH_GIT_TAG         "e26d602a756f5f83e6c8220f910b61d7089fa951")
S
Sang Ik Lee 已提交
21 22 23
SET(NGRAPH_SOURCES_DIR     ${THIRD_PARTY_PATH}/ngraph)
SET(NGRAPH_INSTALL_DIR     ${THIRD_PARTY_PATH}/install/ngraph)
SET(NGRAPH_INC_DIR         ${NGRAPH_INSTALL_DIR}/include)
S
Sang Ik Lee 已提交
24
SET(NGRAPH_LIB_DIR         ${NGRAPH_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})
25
SET(NGRAPH_SHARED_LIB_NAME libngraph.so)
S
Sang Ik Lee 已提交
26
SET(NGRAPH_CPU_LIB_NAME    libcpu_backend.so)
27 28 29 30 31
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    SET(NGRAPH_TBB_LIB_NAME    libtbb_debug.so.2)
else()
    SET(NGRAPH_TBB_LIB_NAME    libtbb.so.2)
endif()
S
Sang Ik Lee 已提交
32
SET(NGRAPH_GIT_REPO        "https://github.com/NervanaSystems/ngraph.git")
S
Sang Ik Lee 已提交
33 34 35
SET(NGRAPH_SHARED_LIB      ${NGRAPH_LIB_DIR}/${NGRAPH_SHARED_LIB_NAME})
SET(NGRAPH_CPU_LIB         ${NGRAPH_LIB_DIR}/${NGRAPH_CPU_LIB_NAME})
SET(NGRAPH_TBB_LIB         ${NGRAPH_LIB_DIR}/${NGRAPH_TBB_LIB_NAME})
S
Sang Ik Lee 已提交
36 37 38 39

ExternalProject_Add(
    ${NGRAPH_PROJECT}
    ${EXTERNAL_PROJECT_LOG_ARGS}
B
baojun 已提交
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    DEPENDS                  ${MKLDNN_PROJECT} ${MKLML_PROJECT}
    GIT_REPOSITORY           ${NGRAPH_GIT_REPO}
    GIT_TAG                  ${NGRAPH_GIT_TAG}
    PREFIX                   ${NGRAPH_SOURCES_DIR}
    UPDATE_COMMAND           ""
    CMAKE_GENERATOR          ${CMAKE_GENERATOR}
    CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
    CMAKE_GENERATOR_TOOLSET  ${CMAKE_GENERATOR_TOOLSET}
    CMAKE_ARGS               -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
    CMAKE_ARGS               -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
    CMAKE_ARGS               -DCMAKE_INSTALL_PREFIX=${NGRAPH_INSTALL_DIR}
    CMAKE_ARGS               -DNGRAPH_UNIT_TEST_ENABLE=FALSE
    CMAKE_ARGS               -DNGRAPH_TOOLS_ENABLE=FALSE
    CMAKE_ARGS               -DNGRAPH_INTERPRETER_ENABLE=FALSE
    CMAKE_ARGS               -DNGRAPH_DEX_ONLY=TRUE
    CMAKE_ARGS               -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
    CMAKE_ARGS               -DMKLDNN_INCLUDE_DIR=${MKLDNN_INC_DIR}
    CMAKE_ARGS               -DMKLDNN_LIB_DIR=${MKLDNN_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}
    CMAKE_ARGS               -DMKLML_LIB_DIR=${MKLML_INSTALL_DIR}/lib
59
    CMAKE_ARGS               -NGRAPH_USE_LEGACY_MKLDNN=TRUE
S
Sang Ik Lee 已提交
60 61
)

62
add_library(ngraph INTERFACE)
S
Sang Ik Lee 已提交
63 64 65 66
add_dependencies(ngraph ${NGRAPH_PROJECT})
target_compile_definitions(ngraph INTERFACE -DPADDLE_WITH_NGRAPH)
target_include_directories(ngraph INTERFACE ${NGRAPH_INC_DIR})
target_link_libraries(ngraph INTERFACE ${NGRAPH_SHARED_LIB})