summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x.jenkins/caffe2/build.sh1
-rw-r--r--cmake/Dependencies.cmake3
-rw-r--r--cmake/Modules/FindMKLDNN.cmake139
m---------third_party/ideep0
4 files changed, 61 insertions, 82 deletions
diff --git a/.jenkins/caffe2/build.sh b/.jenkins/caffe2/build.sh
index 8c42ee36ea..4beb22d905 100755
--- a/.jenkins/caffe2/build.sh
+++ b/.jenkins/caffe2/build.sh
@@ -132,6 +132,7 @@ CMAKE_ARGS+=("-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}")
if [[ $BUILD_ENVIRONMENT == *mkl* ]]; then
CMAKE_ARGS+=("-DBLAS=MKL")
+ CMAKE_ARGS+=("-DUSE_MKLDNN=ON")
fi
if [[ $BUILD_ENVIRONMENT == py2-cuda9.0-cudnn7-ubuntu16.04 ]]; then
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 697bddf0cd..b302d19415 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -1306,11 +1306,10 @@ if (NOT BUILD_ATEN_MOBILE)
SET(AT_MKLDNN_ENABLED 0)
SET(CAFFE2_USE_MKLDNN OFF)
IF (USE_MKLDNN)
- FIND_PACKAGE(MKLDNN)
INCLUDE(${CMAKE_CURRENT_LIST_DIR}/public/mkldnn.cmake)
IF(MKLDNN_FOUND)
SET(AT_MKLDNN_ENABLED 1)
- INCLUDE_DIRECTORIES(SYSTEM ${MKLDNN_INCLUDE_DIR})
+ INCLUDE_DIRECTORIES(BEFORE SYSTEM ${MKLDNN_INCLUDE_DIR})
IF(BUILD_CAFFE2_OPS)
SET(CAFFE2_USE_MKLDNN ON)
LIST(APPEND Caffe2_PUBLIC_DEPENDENCY_LIBS caffe2::mkldnn)
diff --git a/cmake/Modules/FindMKLDNN.cmake b/cmake/Modules/FindMKLDNN.cmake
index 3a1991349e..27a0ed3cd3 100644
--- a/cmake/Modules/FindMKLDNN.cmake
+++ b/cmake/Modules/FindMKLDNN.cmake
@@ -2,7 +2,6 @@
#
# The following variables are optionally searched for defaults
# MKL_FOUND : set to true if a library implementing the CBLAS interface is found
-# USE_MKLDNN
#
# The following are set after configuration is done:
# MKLDNN_FOUND : set to true if mkl-dnn is found.
@@ -14,10 +13,6 @@ IF (NOT MKLDNN_FOUND)
SET(MKLDNN_LIBRARIES)
SET(MKLDNN_INCLUDE_DIR)
-IF (NOT USE_MKLDNN)
- RETURN()
-ENDIF(NOT USE_MKLDNN)
-
IF(MSVC)
MESSAGE(STATUS "MKL-DNN needs omp 3+ which is not supported in MSVC so far")
RETURN()
@@ -41,28 +36,9 @@ ENDIF(NOT IDEEP_INCLUDE_DIR OR NOT MKLDNN_INCLUDE_DIR)
LIST(APPEND MKLDNN_INCLUDE_DIR ${IDEEP_INCLUDE_DIR})
IF(MKL_FOUND)
+ # Append to mkldnn dependencies
LIST(APPEND MKLDNN_LIBRARIES ${MKL_LIBRARIES})
LIST(APPEND MKLDNN_INCLUDE_DIR ${MKL_INCLUDE_DIR})
- # The OMP-related variables of MKL-DNN have to be overwritten here,
- # if MKL is used, and the OMP version is defined by MKL.
- # MKL_LIBRARIES_xxxx_LIBRARY is defined by MKL.
- # INTEL_MKL_DIR gives the MKL root path.
- IF (INTEL_MKL_DIR)
- SET(MKLROOT ${INTEL_MKL_DIR})
- IF(WIN32)
- SET(MKLIOMP5DLL ${MKL_LIBRARIES_libiomp5md_LIBRARY} CACHE STRING "Overwrite MKL-DNN omp dependency" FORCE)
- ELSE(WIN32)
- IF (MKL_LIBRARIES_gomp_LIBRARY)
- SET(MKLOMPLIB ${MKL_LIBRARIES_gomp_LIBRARY})
- ELSE(MKL_LIBRARIES_gomp_LIBRARY)
- SET(MKLOMPLIB ${MKL_LIBRARIES_iomp5_LIBRARY})
- ENDIF(MKL_LIBRARIES_gomp_LIBRARY)
- SET(MKLIOMP5LIB ${MKLOMPLIB} CACHE STRING "Overwrite MKL-DNN omp dependency" FORCE)
- ENDIF(WIN32)
- ELSE(INTEL_MKL_DIR)
- MESSAGE(STATUS "Warning: MKL is found, but INTEL_MKL_DIR is not set!")
- ENDIF(INTEL_MKL_DIR)
-
ELSE(MKL_FOUND)
# If we cannot find MKL, we will use the Intel MKL Small library
# comes with ${MKLDNN_ROOT}/external
@@ -75,62 +51,65 @@ ELSE(MKL_FOUND)
ENDIF(NOT IS_DIRECTORY ${MKLDNN_ROOT}/external)
FILE(GLOB_RECURSE MKLML_INNER_INCLUDE_DIR ${MKLDNN_ROOT}/external/*/mkl.h)
- IF(MKLML_INNER_INCLUDE_DIR)
- # if user has multiple version under external/ then guess last
- # one alphabetically is "latest" and warn
- LIST(LENGTH MKLML_INNER_INCLUDE_DIR MKLINCLEN)
- IF(MKLINCLEN GREATER 1)
- LIST(SORT MKLML_INNER_INCLUDE_DIR)
- LIST(REVERSE MKLML_INNER_INCLUDE_DIR)
- LIST(GET MKLML_INNER_INCLUDE_DIR 0 MKLINCLST)
- SET(MKLML_INNER_INCLUDE_DIR "${MKLINCLST}")
- ENDIF(MKLINCLEN GREATER 1)
- GET_FILENAME_COMPONENT(MKLML_INNER_INCLUDE_DIR ${MKLML_INNER_INCLUDE_DIR} DIRECTORY)
- LIST(APPEND MKLDNN_INCLUDE_DIR ${MKLML_INNER_INCLUDE_DIR})
-
- IF(APPLE)
- SET(__mklml_inner_libs mklml iomp5)
- ELSE(APPLE)
- SET(__mklml_inner_libs mklml_intel iomp5)
- ENDIF(APPLE)
-
- FOREACH(__mklml_inner_lib ${__mklml_inner_libs})
- STRING(TOUPPER ${__mklml_inner_lib} __mklml_inner_lib_upper)
- FIND_LIBRARY(${__mklml_inner_lib_upper}_LIBRARY
- NAMES ${__mklml_inner_lib}
- PATHS "${MKLML_INNER_INCLUDE_DIR}/../lib"
- DOC "The path to Intel(R) MKLML ${__mklml_inner_lib} library")
- MARK_AS_ADVANCED(${__mklml_inner_lib_upper}_LIBRARY)
- LIST(APPEND MKLDNN_LIBRARIES ${${__mklml_inner_lib_upper}_LIBRARY})
- ENDFOREACH(__mklml_inner_lib)
- ENDIF(MKLML_INNER_INCLUDE_DIR)
+ IF(NOT MKLML_INNER_INCLUDE_DIR)
+ MESSAGE(STATUS "MKL-DNN not found. Compiling without MKL-DNN support")
+ RETURN()
+ ENDIF(NOT MKLML_INNER_INCLUDE_DIR)
+ # if user has multiple version under external/ then guess last
+ # one alphabetically is "latest" and warn
+ LIST(LENGTH MKLML_INNER_INCLUDE_DIR MKLINCLEN)
+ IF(MKLINCLEN GREATER 1)
+ LIST(SORT MKLML_INNER_INCLUDE_DIR)
+ LIST(REVERSE MKLML_INNER_INCLUDE_DIR)
+ LIST(GET MKLML_INNER_INCLUDE_DIR 0 MKLINCLST)
+ SET(MKLML_INNER_INCLUDE_DIR "${MKLINCLST}")
+ ENDIF(MKLINCLEN GREATER 1)
+ GET_FILENAME_COMPONENT(MKLML_INNER_INCLUDE_DIR ${MKLML_INNER_INCLUDE_DIR} DIRECTORY)
+ LIST(APPEND MKLDNN_INCLUDE_DIR ${MKLML_INNER_INCLUDE_DIR})
+
+ IF(APPLE)
+ SET(__mklml_inner_libs mklml iomp5)
+ ELSE(APPLE)
+ SET(__mklml_inner_libs mklml_intel iomp5)
+ ENDIF(APPLE)
+ FOREACH(__mklml_inner_lib ${__mklml_inner_libs})
+ STRING(TOUPPER ${__mklml_inner_lib} __mklml_inner_lib_upper)
+ FIND_LIBRARY(${__mklml_inner_lib_upper}_LIBRARY
+ NAMES ${__mklml_inner_lib}
+ PATHS "${MKLML_INNER_INCLUDE_DIR}/../lib"
+ DOC "The path to Intel(R) MKLML ${__mklml_inner_lib} library")
+ MARK_AS_ADVANCED(${__mklml_inner_lib_upper}_LIBRARY)
+ IF(NOT ${__mklml_inner_lib_upper}_LIBRARY)
+ MESSAGE(STATUS "MKL-DNN not found. Compiling without MKL-DNN support")
+ RETURN()
+ ENDIF(NOT ${__mklml_inner_lib_upper}_LIBRARY)
+ LIST(APPEND MKLDNN_LIBRARIES ${${__mklml_inner_lib_upper}_LIBRARY})
+ ENDFOREACH(__mklml_inner_lib)
ENDIF(MKL_FOUND)
-LIST(APPEND __mkldnn_looked_for MKLDNN_LIBRARIES)
-LIST(APPEND __mkldnn_looked_for MKLDNN_INCLUDE_DIR)
-INCLUDE(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(MKLDNN DEFAULT_MSG ${__mkldnn_looked_for})
-
-IF(MKLDNN_FOUND)
- IF(NOT APPLE AND CMAKE_COMPILER_IS_GNUCC)
- ADD_COMPILE_OPTIONS(-Wno-maybe-uninitialized)
- ADD_COMPILE_OPTIONS(-Wno-strict-overflow)
- ADD_COMPILE_OPTIONS(-Wno-error=strict-overflow)
- ENDIF(NOT APPLE AND CMAKE_COMPILER_IS_GNUCC)
- SET(WITH_TEST FALSE CACHE BOOL "build with mkl-dnn test" FORCE)
- SET(WITH_EXAMPLE FALSE CACHE BOOL "build with mkl-dnn examples" FORCE)
- ADD_SUBDIRECTORY(${MKLDNN_ROOT})
- SET(MKLDNN_LIB "${CMAKE_SHARED_LIBRARY_PREFIX}mkldnn${CMAKE_SHARED_LIBRARY_SUFFIX}")
- IF(WIN32)
- LIST(APPEND MKLDNN_LIBRARIES "${PROJECT_BINARY_DIR}/bin/${MKLDNN_LIB}")
- ELSE(WIN32)
- LIST(APPEND MKLDNN_LIBRARIES "${PROJECT_BINARY_DIR}/lib/${MKLDNN_LIB}")
- ENDIF(WIN32)
-ELSE(MKLDNN_FOUND)
- MESSAGE(STATUS "MKLDNN source files not found!")
-ENDIF(MKLDNN_FOUND)
-
-UNSET(__mklml_inner_libs)
-UNSET(__mkldnn_looked_for)
+IF(MKL_FOUND)
+ SET(MKL_cmake_included TRUE)
+ SET(MKLDNN_THREADING "OMP:COMP" CACHE STRING "" FORCE)
+ENDIF(MKL_FOUND)
+SET(WITH_TEST FALSE CACHE BOOL "" FORCE)
+SET(WITH_EXAMPLE FALSE CACHE BOOL "" FORCE)
+SET(MKLDNN_LIBRARY_TYPE STATIC CACHE STRING "" FORCE)
+ADD_SUBDIRECTORY(${MKLDNN_ROOT})
+IF(NOT TARGET mkldnn)
+ MESSAGE("Failed to include MKL-DNN target")
+ RETURN()
+ENDIF(NOT TARGET mkldnn)
+IF(MKL_FOUND)
+ TARGET_COMPILE_DEFINITIONS(mkldnn PRIVATE -DUSE_MKL)
+ENDIF(MKL_FOUND)
+IF(NOT APPLE AND CMAKE_COMPILER_IS_GNUCC)
+ TARGET_COMPILE_OPTIONS(mkldnn PRIVATE -Wno-maybe-uninitialized)
+ TARGET_COMPILE_OPTIONS(mkldnn PRIVATE -Wno-strict-overflow)
+ TARGET_COMPILE_OPTIONS(mkldnn PRIVATE -Wno-error=strict-overflow)
+ENDIF(NOT APPLE AND CMAKE_COMPILER_IS_GNUCC)
+LIST(APPEND MKLDNN_LIBRARIES mkldnn)
+
+SET(MKLDNN_FOUND TRUE)
+MESSAGE(STATUS "Found MKL-DNN: TRUE")
ENDIF(NOT MKLDNN_FOUND)
diff --git a/third_party/ideep b/third_party/ideep
-Subproject dedff8fb8193fe3a1ea893d4bc852f8ea395b6b
+Subproject 7b8f9d025a675522305a1c5d1328d83f11f205e