Skip to content

Commit

Permalink
[Mac] support mkldnn for macOS (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
fs-eire authored and pranavsharma committed Nov 29, 2018
1 parent 7523e76 commit 846044e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion cmake/external/mkldnn.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ if(WIN32)
endif()
set(MKLDNN_PATCH_COMMAND2 "")
else()
set(MKLDNN_SHARED_LIB libmkldnn.so.0)
if (APPLE)
set(MKLDNN_SHARED_LIB libmkldnn.0.dylib)
else()
set(MKLDNN_SHARED_LIB libmkldnn.so.0)
endif()
if(onnxruntime_USE_MKLML)
set(DOWNLOAD_MKLML ${MKLDNN_SOURCE}/scripts/prepare_mkl.sh)
set(MKLML_SHARED_LIB libmklml_intel.so)
Expand Down
5 changes: 4 additions & 1 deletion cmake/onnxruntime_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ if (MSVC)
elseif (APPLE)
set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${ONNXRUNTIME_SO_LINK_FLAG})
set_target_properties(onnxruntime_pybind11_state PROPERTIES INSTALL_RPATH "@loader_path")
set_target_properties(onnxruntime_pybind11_state PROPERTIES
INSTALL_RPATH "@loader_path"
BUILD_WITH_INSTALL_RPATH TRUE
INSTALL_RPATH_USE_LINK_PATH FALSE)
else()
target_link_libraries(onnxruntime_pybind11_state ${onnxruntime_pybind11_state_libs} ${onnxruntime_EXTERNAL_LIBRARIES} ${PYTHON_LIBRARY} ${ONNXRUNTIME_SO_LINK_FLAG})
set_target_properties(onnxruntime_pybind11_state PROPERTIES LINK_FLAGS "-Xlinker -rpath=\$ORIGIN")
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ def finalize_options(self):
bdist_wheel = None

# Additional binaries
if platform.system() == 'Linux' or platform.system() == 'Darwin':
if platform.system() == 'Linux':
libs = ['onnxruntime_pybind11_state.so', 'libmkldnn.so.0', 'libmklml_intel.so', 'libiomp5.so']
elif platform.system() == "Darwin":
libs = ['onnxruntime_pybind11_state.so', 'libmkldnn.0.dylib'] # TODO add libmklml and libiomp5 later.
else:
libs = ['onnxruntime_pybind11_state.pyd', 'mkldnn.dll', 'mklml.dll', 'libiomp5md.dll']

Expand Down

0 comments on commit 846044e

Please sign in to comment.