Upgrade MKL-DNN to version 0.17 (#14308)
authorGu, Jinghui <jinghui.gu@intel.com>
Sat, 8 Dec 2018 00:42:39 +0000 (16:42 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 8 Dec 2018 00:44:50 +0000 (16:44 -0800)
Summary:
upgrade MKL-DNN to version 0.17
update mkldnn bridge to latest.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14308

Differential Revision: D13383102

Pulled By: yinghai

fbshipit-source-id: c434f0e0ddff2ee2c86db2d6c44a37298fd005a3

.jenkins/caffe2/build.sh
caffe2/ideep/operators/utility_ops.cc
cmake/Modules/FindMKLDNN.cmake
third_party/ideep

index 50e73b1..643dc7e 100755 (executable)
@@ -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
index 98dc335..7b5f6d8 100644 (file)
@@ -1,6 +1,4 @@
-#include "caffe2/operators/utility_ops.h"
-#include "caffe2/core/operator.h"
-#include "caffe2/ideep/ideep_utils.h"
+#include <caffe2/ideep/ideep_utils.h>
 
 namespace caffe2 {
 
index a2cea43..b4ae4de 100644 (file)
@@ -41,27 +41,28 @@ ENDIF(NOT IDEEP_INCLUDE_DIR OR NOT MKLDNN_INCLUDE_DIR)
 LIST(APPEND MKLDNN_INCLUDE_DIR ${IDEEP_INCLUDE_DIR})
 
 IF(MKL_FOUND)
+  # Configure MKL-DNN
+  ADD_DEFINITIONS(-DUSE_MKL)
+  SET(MKLDNN_USE_MKL "FULL")
+  INCLUDE_DIRECTORIES(AFTER ${MKL_INCLUDE_DIR})
+  LIST(APPEND mkldnn_LINKER_LIBS ${MKL_LIBRARIES})
+
   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.
+
+  # The OMP-related variables of MKL-DNN have to be overrode here
+  # if MKL is used. Then, the OMP version can be 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)
+  IF (EXISTS "${MKL_LIBRARIES_gomp_LIBRARY}")
+    SET(MKLIOMP5LIB ${MKL_LIBRARIES_gomp_LIBRARY} CACHE STRING "Override MKL-DNN omp dependency" FORCE)
+  ELSEIF(EXISTS "${MKL_LIBRARIES_iomp5_LIBRARY}")
+    SET(MKLIOMP5LIB ${MKL_LIBRARIES_iomp5_LIBRARY} CACHE STRING "Override MKL-DNN omp dependency" FORCE)
+  ELSEIF(EXISTS "${MKL_LIBRARIES_libiomp5md_LIBRARY}")
+    SET(MKLIOMP5DLL ${MKL_LIBRARIES_libiomp5md_LIBRARY} CACHE STRING "Override MKL-DNN omp dependency" FORCE)
+  ELSE(EXISTS "${MKL_LIBRARIES_gomp_LIBRARY}")
+    SET(MKLIOMP5LIB "" CACHE STRING "Override MKL-DNN omp dependency" FORCE)
+    SET(MKLIOMP5DLL "" CACHE STRING "Override MKL-DNN omp dependency" FORCE)
+  ENDIF(EXISTS "${MKL_LIBRARIES_gomp_LIBRARY}")
 
 ELSE(MKL_FOUND)
   # If we cannot find MKL, we will use the Intel MKL Small library
@@ -115,6 +116,7 @@ IF(MKLDNN_FOUND)
   IF(NOT APPLE AND CMAKE_COMPILER_IS_GNUCC)
     ADD_COMPILE_OPTIONS(-Wno-maybe-uninitialized)
   ENDIF(NOT APPLE AND CMAKE_COMPILER_IS_GNUCC)
+  SET(MKLDNN_THREADING "OMP:COMP")
   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})
index dedff8f..d06f361 160000 (submodule)
@@ -1 +1 @@
-Subproject commit dedff8fb8193fe3a1ea893d4bc852f8ea395b6b3
+Subproject commit d06f361c530dda79f49192953b2e896861e84602