Skip to content

Commit 3b2a8ca

Browse files
authored
Create a CoreML inmemoryfs pybinding target (#9482)
### Summary Context: #9481 We now create the pybinding target for inmemoryfs. Note that the build recipe is from the wheel builder: https://github.com/pytorch/executorch/blob/5fdfa511966208c7e237a9e920a7c63f513b4fb7/backends/apple/coreml/runtime/inmemoryfs/setup.py#L17-L38 ### Test plan ``` $ cmake -B cmake-out -S . -DEXECUTORCH_BUILD_PYBIND=ON -DEXECUTORCH_BUILD_COREML=ON $ cmake --build cmake-out -j$(sysctl -n hw.ncpu) --target executorchcoreml $ ./install_executorch.sh --pybind coreml ``` cc @larryliu0820 @lucylq
1 parent 12f4431 commit 3b2a8ca

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

backends/apple/coreml/CMakeLists.txt

+17
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ endif()
2525

2626
option(COREML_BUILD_EXECUTOR_RUNNER "Build CoreML executor runner." OFF)
2727

28+
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15)
29+
2830
# inmemoryfs sources
2931
set(INMEMORYFS_SOURCES
3032
runtime/inmemoryfs/inmemory_filesystem.cpp
@@ -229,3 +231,18 @@ install(
229231
INCLUDES
230232
DESTINATION ${_common_include_directories}
231233
)
234+
235+
# We only care about building the pybinding when building for macOS wheels.
236+
if(EXECUTORCH_BUILD_COREML AND EXECUTORCH_BUILD_PYBIND)
237+
if(NOT TARGET pybind11::pybind11)
238+
add_subdirectory(${EXECUTORCH_ROOT}/third-party/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/pybind11)
239+
endif()
240+
241+
pybind11_add_module(executorchcoreml SHARED runtime/inmemoryfs/inmemory_filesystem_py.cpp)
242+
243+
target_compile_options(executorchcoreml PRIVATE -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
244+
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
245+
target_compile_options(executorchcoreml PRIVATE -g)
246+
endif()
247+
target_link_libraries(executorchcoreml PRIVATE coreml_util coreml_inmemoryfs)
248+
endif()

0 commit comments

Comments
 (0)