diff --git a/cmake/external/mkldnn.cmake b/cmake/external/mkldnn.cmake index d58ac991ab39d6634da89e51411009b6ff9e2bd4..04e603e787d6e0932188c02fbc67a8861a5bd17b 100644 --- a/cmake/external/mkldnn.cmake +++ b/cmake/external/mkldnn.cmake @@ -19,7 +19,14 @@ SET(MKLDNN_PREFIX_DIR ${THIRD_PARTY_PATH}/mkldnn) SET(MKLDNN_INSTALL_DIR ${THIRD_PARTY_PATH}/install/mkldnn) SET(MKLDNN_INC_DIR "${MKLDNN_INSTALL_DIR}/include" CACHE PATH "mkldnn include directory." FORCE) SET(MKLDNN_REPOSITORY https://github.com/intel/mkl-dnn.git) -SET(MKLDNN_TAG 518a316a8cd6deb82dc7866bc04bd0355a25c3a4) + +if(WIN32) + # For Windows use 1.0 version of MKL-DNN + SET(MKLDNN_TAG 518a316a8cd6deb82dc7866bc04bd0355a25c3a4) +else(WIN32) + SET(MKLDNN_TAG 52c3052df8ec1d5b8b45cb6c350a952840eabd42) +endif(WIN32) + # Introduce variables: # * CMAKE_INSTALL_LIBDIR @@ -71,13 +78,13 @@ ExternalProject_Add( -DMKLROOT=${MKLML_ROOT} -DCMAKE_C_FLAGS=${MKLDNN_CFLAG} -DCMAKE_CXX_FLAGS=${MKLDNN_CXXFLAG} - -DMKLDNN_BUILD_TESTS=OFF -DMKLDNN_BUILD_EXAMPLES=OFF + -DDNNL_BUILD_TESTS=OFF -DDNNL_BUILD_EXAMPLES=OFF CMAKE_CACHE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${MKLDNN_INSTALL_DIR} ) if(WIN32) SET(MKLDNN_LIB "${MKLDNN_INSTALL_DIR}/${LIBDIR}/mkldnn.lib" CACHE FILEPATH "mkldnn library." FORCE) else(WIN32) - SET(MKLDNN_LIB "${MKLDNN_INSTALL_DIR}/${LIBDIR}/libmkldnn.so" CACHE FILEPATH "mkldnn library." FORCE) + SET(MKLDNN_LIB "${MKLDNN_INSTALL_DIR}/${LIBDIR}/libdnnl.so" CACHE FILEPATH "mkldnn library." FORCE) endif(WIN32) ADD_LIBRARY(shared_mkldnn SHARED IMPORTED GLOBAL) @@ -100,7 +107,7 @@ if(WIN32) SET(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/bin/mkldnn.dll) else(WIN32) SET(MKLDNN_SHARED_LIB ${MKLDNN_INSTALL_DIR}/libmkldnn.so.0) - SET(MKLDNN_SHARED_LIB_1 ${MKLDNN_INSTALL_DIR}/libmkldnn.so.1) + SET(MKLDNN_SHARED_LIB_1 ${MKLDNN_INSTALL_DIR}/libdnnl.so.1) ADD_CUSTOM_COMMAND(TARGET ${MKLDNN_PROJECT} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${MKLDNN_LIB} ${MKLDNN_SHARED_LIB}) ADD_CUSTOM_COMMAND(TARGET ${MKLDNN_PROJECT} POST_BUILD diff --git a/python/setup.py.in b/python/setup.py.in index 74e38d20ec288f26cf67987a49fef8a935b5039a..99d1ac6a7eb9cfefa71cd1ddc63d4dbb8385bccb 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -203,16 +203,19 @@ if '${WITH_MKLDNN}' == 'ON': # TODO(typhoonzero): use install_name_tool to patch mkl libs once # we can support mkl on mac. # - # change rpath of libmkldnn.so.1, add $ORIGIN/ to it. + # change rpath of libdnnl.so.1, add $ORIGIN/ to it. # The reason is that all thirdparty libraries in the same directory, - # thus, libmkldnn.so.1 will find libmklml_intel.so and libiomp5.so. + # thus, libdnnl.so.1 will find libmklml_intel.so and libiomp5.so. command = "patchelf --set-rpath '$ORIGIN/' ${MKLDNN_SHARED_LIB}" if os.system(command) != 0: - raise Exception("patch libmkldnn.so failed, command: %s" % command) - package_data['paddle.libs']+=['libmkldnn.so.0','libmkldnn.so.1' if os.name != 'nt' else ('mkldnn' + ext_name)] + raise Exception("patch libdnnl.so failed, command: %s" % command) shutil.copy('${MKLDNN_SHARED_LIB}', libs_path) if os.name != 'nt': shutil.copy('${MKLDNN_SHARED_LIB_1}', libs_path) + package_data['paddle.libs']+=['libmkldnn.so.0', 'libdnnl.so.1'] + else: + package_data['paddle.libs']+=['mkldnn.dll'] + if '${WITH_NGRAPH}' == 'ON': # only change rpath in Release mode, # since in Debug mode, nGraph lib may be too large to be changed?