diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e1807be..7aef5948 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,9 +71,9 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -if(NOT APPLE) +if(NOT APPLE) # FIXME: Doesn't work for Ubuntu - execute_process(COMMAND cat /etc/os-release + execute_process(COMMAND cat /etc/os-release OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE ) @@ -106,7 +106,7 @@ endif() # Therefore we are setting two entries in the RPATH: # 1. $ORIGIN/. # 2. $ORIGIN/../tensorflow/ -# +# set(CMAKE_MACOSX_RPATH 1) if(APPLE) set(CMAKE_INSTALL_RPATH "@loader_path/;@loader_path/../tensorflow;") @@ -120,19 +120,18 @@ endif() find_package(TensorFlow REQUIRED) add_library(tensorflow_framework_lib SHARED IMPORTED) -set_target_properties( - tensorflow_framework_lib - PROPERTIES IMPORTED_LOCATION +set_target_properties( + tensorflow_framework_lib + PROPERTIES IMPORTED_LOCATION ${TensorFlow_DIR}/libtensorflow_framework.so ) if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(NGRAPH_TF_CXX11_ABI "${TensorFlow_CXX_ABI}") message( STATUS "nGraph-TensorFlow using CXX11 ABI: ${NGRAPH_TF_CXX11_ABI}" ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_TF_CXX11_ABI}") endif() -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_TF_CXX11_ABI}") - if(APPLE) set(LIBNGRAPH_SO "libngraph.dylib") else() @@ -158,7 +157,7 @@ endif() if(USE_PRE_BUILT_NGRAPH) if(NOT NGRAPH_ARTIFACTS_DIR) message( - FATAL_ERROR + FATAL_ERROR "USE_PRE_BUILT_NGRAPH is ON but NGRAPH_ARTIFACTS_DIR is missing" ) endif() @@ -174,9 +173,9 @@ if(USE_PRE_BUILT_NGRAPH) ABSOLUTE ) if (NOT EXISTS ${NGRAPH_ARTIFACTS_DIR}) - message(FATAL_ERROR + message(FATAL_ERROR "nGraph artifacts directory doesn't exist: " ${NGRAPH_ARTIFACTS_DIR} ) - endif() + endif() else() set(NGRAPH_ARTIFACTS_DIR ${CMAKE_CURRENT_BINARY_DIR}/ngraph/ngraph_dist) endif() @@ -194,7 +193,7 @@ if(UNIT_TEST_TF_CC_DIR) ABSOLUTE ) if (NOT EXISTS ${TF_PRE_BUILT_LOCATION}) - message(FATAL_ERROR + message(FATAL_ERROR "TensorFlow pre-built directory doesn't exist: " ${TF_PRE_BUILT_LOCATION} ) endif() @@ -202,14 +201,14 @@ endif() # Enable build target CPU features set( - NGRAPH_TARGET_ARCH - native + NGRAPH_TARGET_ARCH + native CACHE STRING "Target CPU architecture to build for.") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${NGRAPH_TARGET_ARCH}") set( - NGRAPH_TUNE_ARCH - native + NGRAPH_TUNE_ARCH + native CACHE STRING "Target CPU architecture to tune for") message(STATUS "UNIT_TEST_ENABLE: ${UNIT_TEST_ENABLE}") @@ -228,14 +227,15 @@ if (NOT USE_PRE_BUILT_NGRAPH) ext_ngraph GIT_REPOSITORY https://github.com/NervanaSystems/ngraph GIT_TAG 90aa7336dfbf21d3ecab1b50aa8676c2fe1bd75d - CMAKE_ARGS + CMAKE_ARGS -DNGRAPH_DISTRIBUTED_ENABLE=${NGRAPH_DISTRIBUTED_ENABLE} - -DNGRAPH_INSTALL_PREFIX=${NGRAPH_ARTIFACTS_DIR} + -DNGRAPH_INSTALL_PREFIX=${NGRAPH_ARTIFACTS_DIR} -DNGRAPH_USE_CXX_ABI=${TensorFlow_CXX_ABI} -DNGRAPH_UNIT_TEST_ENABLE=FALSE -DNGRAPH_TOOLS_ENABLE=${NGRAPH_TOOLS_ENABLE} - -DNGRAPH_DEX_ONLY=TRUE + -DNGRAPH_DEX_ONLY=TRUE -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DNGRAPH_GPU_ENABLE=${NGRAPH_GPU_ENABLE} -DNGRAPH_DEBUG_ENABLE=${NGRAPH_DEBUG_ENABLE} -DNGRAPH_PLAIDML_ENABLE=${NGRAPH_PLAIDML_ENABLE} @@ -251,7 +251,7 @@ if (NOT USE_PRE_BUILT_NGRAPH) UPDATE_COMMAND "" INSTALL_DIR "${CMAKE_INSTALL_PREFIX}" ) -endif() +endif() set(NGRAPH_INSTALL_DIR ${NGRAPH_ARTIFACTS_DIR}) @@ -262,9 +262,9 @@ else() endif() add_library(ngraph_lib SHARED IMPORTED) -set_target_properties( - ngraph_lib - PROPERTIES IMPORTED_LOCATION +set_target_properties( + ngraph_lib + PROPERTIES IMPORTED_LOCATION ${NGRAPH_IMPORTED_LOCATION} ) diff --git a/cmake/external_gtest.cmake b/cmake/external_gtest.cmake index d7007b24..4da4f001 100644 --- a/cmake/external_gtest.cmake +++ b/cmake/external_gtest.cmake @@ -25,6 +25,11 @@ SET(GTEST_GIT_REPO_URL https://github.com/google/googletest.git) SET(GTEST_GIT_LABEL release-1.8.0) set(CXX_FLAGS "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} -fPIC") +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (DEFINED NGRAPH_USE_CXX_ABI) + set(CXX_FLAGS "${CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI}") + endif() +endif() # The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2. if (${CMAKE_VERSION} VERSION_LESS 3.2) @@ -36,6 +41,7 @@ if (${CMAKE_VERSION} VERSION_LESS 3.2) INSTALL_COMMAND "" UPDATE_COMMAND "" CMAKE_ARGS ${CXX_FLAGS} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp" STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp" DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download" @@ -52,6 +58,7 @@ else() INSTALL_COMMAND "" UPDATE_COMMAND "" CMAKE_ARGS ${CXX_FLAGS} + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp" STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp" DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download" diff --git a/python/CreatePipWhl.cmake b/python/CreatePipWhl.cmake index 48f074f6..9b8dd676 100644 --- a/python/CreatePipWhl.cmake +++ b/python/CreatePipWhl.cmake @@ -45,58 +45,58 @@ if (PYTHON) endif() message(STATUS "LIB_SUFFIX: ${NGTF_INSTALL_DIR}/${LIB_SUFFIX}") file(GLOB NGRAPH_LIB_FILES "${NGTF_INSTALL_DIR}/${LIB_SUFFIX}/lib*") - + # Copy the ngraph_bridge libraries from install foreach(DEP_FILE ${NGRAPH_LIB_FILES}) get_filename_component(lib_file_real_path ${DEP_FILE} ABSOLUTE) get_filename_component(lib_file_name ${DEP_FILE} NAME) set(ngraph_libraries "${ngraph_libraries}\"${lib_file_name}\",\n\t") - file(COPY ${lib_file_real_path} - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge") - endforeach() + file(COPY ${lib_file_real_path} + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge") + endforeach() + + # Get the list of license files + file(GLOB NGRAPH_TF_LICENSE_FILES "${NGTF_SRC_DIR}/third-party/licenses/*") - # Get the list of license files - file(GLOB NGRAPH_TF_LICENCE_FILES "${NGTF_SRC_DIR}/third-party/licenses/*") - # Copy the licenses for ngraph-tf - foreach(DEP_FILE ${NGRAPH_TF_LICENCE_FILES}) + foreach(DEP_FILE ${NGRAPH_TF_LICENSE_FILES}) get_filename_component(lic_file_real_path ${DEP_FILE} ABSOLUTE) get_filename_component(lic_file_name ${DEP_FILE} NAME) set( - license_files + license_files "${license_files}\"licenses/${lic_file_name}\",\n\t") - file(COPY ${lic_file_real_path} - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses") - endforeach() + file(COPY ${lic_file_real_path} + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses") + endforeach() # Get the list of license files for ngraph - file(GLOB NGRAPH_LICENCE_FILES "${NGRAPH_INSTALL_DIR}/licenses/*") - + file(GLOB NGRAPH_LICENSE_FILES "${NGRAPH_INSTALL_DIR}/licenses/*") + # Copy the licenses for ngraph-tf - foreach(DEP_FILE ${NGRAPH_LICENCE_FILES}) + foreach(DEP_FILE ${NGRAPH_LICENSE_FILES}) get_filename_component(lic_file_real_path ${DEP_FILE} ABSOLUTE) get_filename_component(lic_file_name ${DEP_FILE} NAME) set( - license_files + license_files "${license_files}\"licenses/${lic_file_name}\",\n\t") - file(COPY ${lic_file_real_path} - DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses") - endforeach() + file(COPY ${lic_file_real_path} + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/licenses") + endforeach() - # Copy the LICENSE at the toplevel - file(COPY ${CMAKE_SOURCE_DIR}/../LICENSE - DESTINATION "${CMAKE_CURRENT_LIST_DIR}/python/ngraph_bridge") + # Copy the LICENSE at the top level + file(COPY ${CMAKE_CURRENT_LIST_DIR}/../LICENSE + DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge") set( - licence_top_level + licence_top_level "\"LICENSE\"") configure_file(${SETUP_PY_IN} ${SETUP_PY}) configure_file(${INIT_PY_IN} ${INIT_PY}) if (APPLE) - execute_process(COMMAND - install_name_tool -change - libngraph.dylib - @loader_path/libngraph.dylib + execute_process(COMMAND + install_name_tool -change + libngraph.dylib + @loader_path/libngraph.dylib ${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/libngraph_bridge.dylib RESULT_VARIABLE result ERROR_VARIABLE ERR @@ -106,10 +106,10 @@ if (PYTHON) message(FATAL_ERROR "Cannot update @loader_path") endif() - execute_process(COMMAND - install_name_tool -change - libngraph.dylib - @loader_path/libngraph.dylib + execute_process(COMMAND + install_name_tool -change + libngraph.dylib + @loader_path/libngraph.dylib ${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/libcpu_backend.dylib RESULT_VARIABLE result ERROR_VARIABLE ERR @@ -128,10 +128,10 @@ if (PYTHON) FOREACH(lib_file ${cpu_lib_list}) message("Library: " ${lib_file}) - execute_process(COMMAND - install_name_tool -change - @rpath/${lib_file} - @loader_path/${lib_file} + execute_process(COMMAND + install_name_tool -change + @rpath/${lib_file} + @loader_path/${lib_file} ${CMAKE_CURRENT_BINARY_DIR}/python/ngraph_bridge/libcpu_backend.dylib RESULT_VARIABLE result ERROR_VARIABLE ERR @@ -190,5 +190,5 @@ if (PYTHON) COMMAND ${PYTHON} "setup.py" "bdist_wheel" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/python/ ) - + endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4db48216..1599d43b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,7 +21,7 @@ include_directories(${TensorFlow_INCLUDE_DIR}/external/nsync/public) # Get this location from the CMAKE variables passed during the cmake time if (NOT DEFINED TF_SRC_DIR) message( - FATAL_ERROR + FATAL_ERROR "TensorFlow source directory.Use -DTF_SRC_DIR=" ) endif() @@ -33,9 +33,9 @@ include_directories(${TensorFlow_SRC_DIR}) include_directories(${TensorFlow_SRC_DIR}/bazel-genfiles) add_library(tensorflow_cc_lib SHARED IMPORTED) -set_target_properties( - tensorflow_cc_lib - PROPERTIES IMPORTED_LOCATION +set_target_properties( + tensorflow_cc_lib + PROPERTIES IMPORTED_LOCATION ${TensorFlow_SRC_DIR}/bazel-bin/tensorflow/libtensorflow_cc.so ) @@ -63,16 +63,16 @@ message(STATUS "Shared Link Flags: ${CMAKE_SHARED_LINKER_FLAGS}") add_executable(gtest_ngtf ${SRC}) message(STATUS "TensorFlow_SRC_DIR: ${TensorFlow_SRC_DIR}") -# The following custom commands are used to create symlinks for various +# The following custom commands are used to create symlinks for various # input files needed by the unit test -add_custom_command( +add_custom_command( TARGET gtest_ngtf PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E create_symlink - ${CMAKE_CURRENT_SOURCE_DIR}/test_axpy.pbtxt + COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_CURRENT_SOURCE_DIR}/test_axpy.pbtxt ${CMAKE_CURRENT_BINARY_DIR}/test_axpy.pbtxt - COMMAND ${CMAKE_COMMAND} -E create_symlink - ${CMAKE_CURRENT_SOURCE_DIR}/test_axpy_launchop.pbtxt + COMMAND ${CMAKE_COMMAND} -E create_symlink + ${CMAKE_CURRENT_SOURCE_DIR}/test_axpy_launchop.pbtxt ${CMAKE_CURRENT_BINARY_DIR}/test_axpy_launchop.pbtxt ) @@ -81,12 +81,12 @@ if (APPLE) endif() if (NOT UNIT_TEST_TF_CC_DIR) - add_custom_target( + add_custom_target( build_tf_cc COMMENT "Building TensorFlow C++ library" - COMMAND - ${CMAKE_CURRENT_SOURCE_DIR}/build_tf_cc.sh - ${TensorFlow_SRC_DIR} + COMMAND + ${CMAKE_CURRENT_SOURCE_DIR}/build_tf_cc.sh + ${TensorFlow_SRC_DIR} ${NGRAPH_TF_CXX11_ABI} ) @@ -94,11 +94,11 @@ if (NOT UNIT_TEST_TF_CC_DIR) endif() target_link_libraries( - gtest_ngtf - ngraph_bridge + gtest_ngtf + ngraph_bridge ngraph_lib - libgtest - pthread + libgtest + pthread tensorflow_framework_lib tensorflow_cc_lib ) diff --git a/test/ci/docker/docker-scripts/run-ngraph-tf-build.sh b/test/ci/docker/docker-scripts/run-ngraph-tf-build.sh index 38d36f70..04f4a63c 100755 --- a/test/ci/docker/docker-scripts/run-ngraph-tf-build.sh +++ b/test/ci/docker/docker-scripts/run-ngraph-tf-build.sh @@ -278,7 +278,7 @@ cd "${bridge_dir}" if [ ! -d "${ngraph_dist_dir}" ] ; then ( >&2 echo '***** Error: *****' ) - ( >&2 echo "ngraph_dist directory does not exist -- this likely indicatesa build failure: ${ngraph_dist_dir}" ) + ( >&2 echo "ngraph_dist directory does not exist -- this likely indicates a build failure: ${ngraph_dist_dir}" ) exit 1 fi diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 65e1c6f0..2262bc4a 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -22,8 +22,9 @@ ExternalProject_Add( ext_abseil GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git GIT_TAG f21d187b80e3b7f08fb279775ea9c8b48c636030 - CMAKE_ARGS + CMAKE_ARGS -DBUILD_TESTING=OFF + -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/abseil/src" BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/abseil/build" INSTALL_COMMAND ""