Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit d746bed

Browse files
silee2diyessi
authored andcommitted
Silee2/fix prebuilt mkldnn on r0.15 (#2574)
* mkl-dnn prebuilt: Use IMPORTED_LINK_INTERFACE_LIBRARIES to ask to link mklml and omp runtime. * mkl-dnn prebuilt: fix IMPORTED libraries related issues. * Setup target libmkl for prebuilt mkl-dnn.
1 parent 524f57b commit d746bed

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

cmake/external_mkldnn.cmake

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,30 @@ if(MKLDNN_INCLUDE_DIR AND MKLDNN_LIB_DIR)
4848
set(MKLML_LIB_DIR ${MKLDNN_LIB_DIR})
4949
endif()
5050

51+
if(WIN32)
52+
add_library(libmkl STATIC IMPORTED)
53+
set_property(TARGET libmkl PROPERTY IMPORTED_LOCATION ${MKLML_LIB_DIR}/${MKLML_IMPLIB})
54+
set_target_properties(libmkl PROPERTIES
55+
IMPORTED_LINK_INTERFACE_LIBRARIES ${MKLML_LIB_DIR}/${OMP_IMPLIB})
56+
else()
57+
add_library(libmkl SHARED IMPORTED)
58+
set_property(TARGET libmkl PROPERTY IMPORTED_LOCATION ${MKLML_LIB_DIR}/${MKLML_LIB})
59+
set_target_properties(libmkl PROPERTIES
60+
IMPORTED_LINK_INTERFACE_LIBRARIES ${MKLML_LIB_DIR}/${OMP_LIB})
61+
endif()
62+
5163
if(WIN32)
5264
add_library(libmkldnn STATIC IMPORTED)
53-
set_property(TARGET libmkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB_DIR}/${MKLDNN_IMPORT_LIB})
65+
set_property(TARGET libmkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB_DIR}/${MKLDNN_IMPLIB})
66+
set_target_properties(libmkldnn PROPERTIES
67+
IMPORTED_LINK_INTERFACE_LIBRARIES "${MKLML_LIB_DIR}/${MKLML_IMPLIB};${MKLML_LIB_DIR}/${OMP_IMPLIB}")
5468
else()
5569
add_library(libmkldnn SHARED IMPORTED)
5670
set_property(TARGET libmkldnn PROPERTY IMPORTED_LOCATION ${MKLDNN_LIB_DIR}/${MKLDNN_LIB})
71+
set_target_properties(libmkldnn PROPERTIES
72+
IMPORTED_LINK_INTERFACE_LIBRARIES "${MKLML_LIB_DIR}/${MKLML_LIB};${MKLML_LIB_DIR}/${OMP_LIB}")
5773
endif()
58-
target_include_directories(libmkldnn SYSTEM INTERFACE ${MKLDNN_INCLUDE_DIR})
74+
set_target_properties(libmkldnn PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${MKLDNN_INCLUDE_DIR})
5975

6076
install(FILES ${MKLDNN_LIB_DIR}/${MKLDNN_LIB} ${MKLML_LIB_DIR}/${MKLML_LIB} ${MKLML_LIB_DIR}/${OMP_LIB} DESTINATION ${NGRAPH_INSTALL_LIB})
6177
return()

python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ add_custom_command(
4343

4444
add_custom_target(python_wheel DEPENDS ngraph ${CMAKE_BINARY_DIR}/python/dist/)
4545
if (NGRAPH_CPU_ENABLE)
46-
add_dependencies(python_wheel ext_mkldnn)
46+
add_dependencies(python_wheel libmkldnn)
4747
endif()
4848

src/ngraph/codegen/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ add_custom_target(header_resource
8282
BYPRODUCTS
8383
)
8484
if (NGRAPH_CPU_ENABLE)
85-
add_dependencies(header_resource ext_eigen ext_mkldnn)
85+
add_dependencies(header_resource ext_eigen libmkldnn)
8686
endif()
8787

8888
if(NGRAPH_LIB_VERSIONING_ENABLE)

src/ngraph/runtime/cpu/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ if (NGRAPH_CPU_ENABLE)
191191
endif()
192192
endif()
193193

194-
add_dependencies(cpu_backend ext_mkldnn ext_eigen)
194+
add_dependencies(cpu_backend libmkldnn ext_eigen)
195195
target_link_libraries(cpu_backend PUBLIC ngraph libmkldnn libmkl libeigen libjson libtbb)
196196
if (NOT NGRAPH_DEX_ONLY)
197197
target_link_libraries(cpu_backend PUBLIC codegen)

0 commit comments

Comments
 (0)