From 9665d9f9d9d4557048205852fcddf27c86d56742 Mon Sep 17 00:00:00 2001 From: jathu Date: Fri, 21 Mar 2025 07:49:57 -0700 Subject: [PATCH 1/7] address comments --- backends/apple/coreml/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index 06807279978..a04c6e7d2bb 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -25,8 +25,6 @@ endif() option(COREML_BUILD_EXECUTOR_RUNNER "Build CoreML executor runner." OFF) -set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) - # inmemoryfs sources set(INMEMORYFS_SOURCES runtime/inmemoryfs/inmemory_filesystem.cpp From b1d24e1d997911111dc412d0978ef3779420bda0 Mon Sep 17 00:00:00 2001 From: jathu Date: Fri, 21 Mar 2025 08:18:37 -0700 Subject: [PATCH 2/7] address comments --- backends/apple/coreml/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index a04c6e7d2bb..06807279978 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -25,6 +25,8 @@ endif() option(COREML_BUILD_EXECUTOR_RUNNER "Build CoreML executor runner." OFF) +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15) + # inmemoryfs sources set(INMEMORYFS_SOURCES runtime/inmemoryfs/inmemory_filesystem.cpp From bc0d6033d0afdba2325d9a4f5c7c190f01f6ead5 Mon Sep 17 00:00:00 2001 From: jathu Date: Thu, 20 Mar 2025 17:39:19 -0700 Subject: [PATCH 3/7] split targets --- backends/apple/coreml/CMakeLists.txt | 45 +++++++++++----------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index 06807279978..f94ca5021eb 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -118,31 +118,20 @@ set(PROTOBUF_SOURCES runtime/sdk/format/WordTagger.pb.cc ) -find_library(FOUNDATION_FRAMEWORK Foundation) - # CoreML util -add_library(coreml_util ${UTIL_SOURCES}) -target_include_directories(coreml_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util) -target_link_libraries(coreml_util PRIVATE ${FOUNDATION_FRAMEWORK}) - -install( - TARGETS coreml_util - DESTINATION lib - INCLUDES - DESTINATION ${_common_include_directories} +add_library(coreml_util) +target_sources(coreml_util PRIVATE ${UTIL_SOURCES}) +target_include_directories(coreml_util + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util ) # CoreML inmemoryfs -add_library(coreml_inmemoryfs ${INMEMORYFS_SOURCES}) -target_include_directories(coreml_inmemoryfs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs) -target_link_libraries(coreml_inmemoryfs PRIVATE coreml_util ${FOUNDATION_FRAMEWORK}) - -install( - TARGETS coreml_inmemoryfs - DESTINATION lib - INCLUDES - DESTINATION ${_common_include_directories} +add_library(coreml_inmemoryfs) +target_sources(coreml_inmemoryfs PRIVATE ${INMEMORYFS_SOURCES}) +target_include_directories(coreml_inmemoryfs + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs ) +target_link_libraries(coreml_inmemoryfs PRIVATE coreml_util) # Define the delegate library add_library(coremldelegate) @@ -160,6 +149,9 @@ target_include_directories( target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/..) target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) target_compile_definitions(coremldelegate PRIVATE C10_USING_CUSTOM_GENERATED_MACROS) +target_link_libraries(coremldelegate PRIVATE coreml_util) +target_link_libraries(coremldelegate PRIVATE coreml_inmemoryfs) +target_link_libraries(coremldelegate PRIVATE executorch_core) if(EXECUTORCH_BUILD_DEVTOOLS) target_sources(coremldelegate PRIVATE ${SDK_SOURCES} ${PROTOBUF_SOURCES}) @@ -179,17 +171,13 @@ endif() find_library(ACCELERATE_FRAMEWORK Accelerate) find_library(COREML_FRAMEWORK CoreML) +find_library(FOUNDATION_FRAMEWORK Foundation) find_library(SQLITE_LIBRARY sqlite3) target_link_libraries( coremldelegate - PUBLIC coreml_util - coreml_inmemoryfs - PRIVATE executorch_core - ${ACCELERATE_FRAMEWORK} - ${COREML_FRAMEWORK} - ${FOUNDATION_FRAMEWORK} - ${SQLITE_LIBRARY} + PRIVATE executorch_core ${ACCELERATE_FRAMEWORK} ${COREML_FRAMEWORK} + ${FOUNDATION_FRAMEWORK} ${SQLITE_LIBRARY} ) target_link_options_shared_lib(coremldelegate) @@ -244,5 +232,6 @@ if(EXECUTORCH_BUILD_COREML AND EXECUTORCH_BUILD_PYBIND) if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") target_compile_options(executorchcoreml PRIVATE -g) endif() - target_link_libraries(executorchcoreml PRIVATE coreml_util coreml_inmemoryfs) + target_link_libraries(executorchcoreml PRIVATE coreml_util) + target_link_libraries(executorchcoreml PRIVATE coreml_inmemoryfs) endif() From 822eb7a09fc7219b168fece9a04071c186b33b3b Mon Sep 17 00:00:00 2001 From: jathu Date: Fri, 21 Mar 2025 07:49:57 -0700 Subject: [PATCH 4/7] address comments --- backends/apple/coreml/CMakeLists.txt | 45 +++++++++++++++++----------- 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/backends/apple/coreml/CMakeLists.txt b/backends/apple/coreml/CMakeLists.txt index f94ca5021eb..06807279978 100644 --- a/backends/apple/coreml/CMakeLists.txt +++ b/backends/apple/coreml/CMakeLists.txt @@ -118,20 +118,31 @@ set(PROTOBUF_SOURCES runtime/sdk/format/WordTagger.pb.cc ) +find_library(FOUNDATION_FRAMEWORK Foundation) + # CoreML util -add_library(coreml_util) -target_sources(coreml_util PRIVATE ${UTIL_SOURCES}) -target_include_directories(coreml_util - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util +add_library(coreml_util ${UTIL_SOURCES}) +target_include_directories(coreml_util PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/util) +target_link_libraries(coreml_util PRIVATE ${FOUNDATION_FRAMEWORK}) + +install( + TARGETS coreml_util + DESTINATION lib + INCLUDES + DESTINATION ${_common_include_directories} ) # CoreML inmemoryfs -add_library(coreml_inmemoryfs) -target_sources(coreml_inmemoryfs PRIVATE ${INMEMORYFS_SOURCES}) -target_include_directories(coreml_inmemoryfs - PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs +add_library(coreml_inmemoryfs ${INMEMORYFS_SOURCES}) +target_include_directories(coreml_inmemoryfs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/runtime/inmemoryfs) +target_link_libraries(coreml_inmemoryfs PRIVATE coreml_util ${FOUNDATION_FRAMEWORK}) + +install( + TARGETS coreml_inmemoryfs + DESTINATION lib + INCLUDES + DESTINATION ${_common_include_directories} ) -target_link_libraries(coreml_inmemoryfs PRIVATE coreml_util) # Define the delegate library add_library(coremldelegate) @@ -149,9 +160,6 @@ target_include_directories( target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/..) target_include_directories(coremldelegate PRIVATE ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10) target_compile_definitions(coremldelegate PRIVATE C10_USING_CUSTOM_GENERATED_MACROS) -target_link_libraries(coremldelegate PRIVATE coreml_util) -target_link_libraries(coremldelegate PRIVATE coreml_inmemoryfs) -target_link_libraries(coremldelegate PRIVATE executorch_core) if(EXECUTORCH_BUILD_DEVTOOLS) target_sources(coremldelegate PRIVATE ${SDK_SOURCES} ${PROTOBUF_SOURCES}) @@ -171,13 +179,17 @@ endif() find_library(ACCELERATE_FRAMEWORK Accelerate) find_library(COREML_FRAMEWORK CoreML) -find_library(FOUNDATION_FRAMEWORK Foundation) find_library(SQLITE_LIBRARY sqlite3) target_link_libraries( coremldelegate - PRIVATE executorch_core ${ACCELERATE_FRAMEWORK} ${COREML_FRAMEWORK} - ${FOUNDATION_FRAMEWORK} ${SQLITE_LIBRARY} + PUBLIC coreml_util + coreml_inmemoryfs + PRIVATE executorch_core + ${ACCELERATE_FRAMEWORK} + ${COREML_FRAMEWORK} + ${FOUNDATION_FRAMEWORK} + ${SQLITE_LIBRARY} ) target_link_options_shared_lib(coremldelegate) @@ -232,6 +244,5 @@ if(EXECUTORCH_BUILD_COREML AND EXECUTORCH_BUILD_PYBIND) if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") target_compile_options(executorchcoreml PRIVATE -g) endif() - target_link_libraries(executorchcoreml PRIVATE coreml_util) - target_link_libraries(executorchcoreml PRIVATE coreml_inmemoryfs) + target_link_libraries(executorchcoreml PRIVATE coreml_util coreml_inmemoryfs) endif() From c45b196fd3d87d556ae4ced64aafaef441feff25 Mon Sep 17 00:00:00 2001 From: jathu Date: Thu, 20 Mar 2025 19:36:32 -0700 Subject: [PATCH 5/7] build inmemoryfs when coreml or pybindings enabled --- CMakeLists.txt | 2 ++ setup.py | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6509d4adeef..e83e4046529 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -811,6 +811,7 @@ if(EXECUTORCH_BUILD_PYBIND) if(EXECUTORCH_BUILD_COREML) list(APPEND _dep_libs coremldelegate) + list(APPEND _dep_libs coreml_inmemoryfs_pybinding) endif() if(EXECUTORCH_BUILD_MPS) @@ -935,6 +936,7 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) if(EXECUTORCH_BUILD_COREML) list(APPEND _executor_runner_libs coremldelegate) + list(APPEND _executor_runner_libs coreml_inmemoryfs_pybinding) endif() add_executable(executor_runner ${_executor_runner__srcs}) diff --git a/setup.py b/setup.py index a1c94aee4e9..ae1e0618dae 100644 --- a/setup.py +++ b/setup.py @@ -135,6 +135,10 @@ def mps(cls) -> bool: def xnnpack(cls) -> bool: return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_XNNPACK", default=False) + @classmethod + def coreml(cls) -> bool: + return cls._is_env_enabled("EXECUTORCH_BUILD_COREML", default=False) + @classmethod def training(cls) -> bool: return cls._is_cmake_arg_enabled( @@ -833,6 +837,15 @@ def get_ext_modules() -> List[Extension]: ] ) + if ShouldBuild.pybindings() or ShouldBuild.coreml(): + ext_modules.append( + BuiltExtension( + src="coreml_inmemoryfs_pybinding.*", + src_dir="backends/apple/coreml", + modpath="executorch.backends.apple.coreml.inmemoryfs", + ) + ) + if ShouldBuild.pybindings(): ext_modules.append( # Install the prebuilt pybindings extension wrapper for the runtime, From 1f235f5fd3cc10116beb4eabbdf91676cd618ff2 Mon Sep 17 00:00:00 2001 From: jathu Date: Thu, 20 Mar 2025 19:39:13 -0700 Subject: [PATCH 6/7] update usage --- CMakeLists.txt | 2 - .../coreml/compiler/coreml_preprocess.py | 2 +- .../apple/coreml/runtime/inmemoryfs/setup.py | 52 ------------------- .../coreml/scripts/install_inmemoryfs.sh | 25 --------- .../coreml/scripts/install_requirements.sh | 11 ---- .../coreml/scripts/extract_coreml_models.py | 5 +- pyproject.toml | 2 + setup.py | 33 +++++++----- 8 files changed, 23 insertions(+), 109 deletions(-) delete mode 100644 backends/apple/coreml/runtime/inmemoryfs/setup.py delete mode 100644 backends/apple/coreml/scripts/install_inmemoryfs.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index e83e4046529..6509d4adeef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -811,7 +811,6 @@ if(EXECUTORCH_BUILD_PYBIND) if(EXECUTORCH_BUILD_COREML) list(APPEND _dep_libs coremldelegate) - list(APPEND _dep_libs coreml_inmemoryfs_pybinding) endif() if(EXECUTORCH_BUILD_MPS) @@ -936,7 +935,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER) if(EXECUTORCH_BUILD_COREML) list(APPEND _executor_runner_libs coremldelegate) - list(APPEND _executor_runner_libs coreml_inmemoryfs_pybinding) endif() add_executable(executor_runner ${_executor_runner__srcs}) diff --git a/backends/apple/coreml/compiler/coreml_preprocess.py b/backends/apple/coreml/compiler/coreml_preprocess.py index c7828888ee5..e9afd819d94 100644 --- a/backends/apple/coreml/compiler/coreml_preprocess.py +++ b/backends/apple/coreml/compiler/coreml_preprocess.py @@ -16,8 +16,8 @@ import coremltools as ct import coremltools.optimize as cto -import executorchcoreml +from executorch.backends.apple.coreml import executorchcoreml from executorch.exir.backend.backend_details import ( BackendDetails, ExportedProgram, diff --git a/backends/apple/coreml/runtime/inmemoryfs/setup.py b/backends/apple/coreml/runtime/inmemoryfs/setup.py deleted file mode 100644 index c93022ed341..00000000000 --- a/backends/apple/coreml/runtime/inmemoryfs/setup.py +++ /dev/null @@ -1,52 +0,0 @@ -import os - -import pathlib -import sys - -REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent.parent.parent.parent.parent -PYBIND11_DIR_PATH = REPO_ROOT / "third-party" / "pybind11" -sys.path.append(str(PYBIND11_DIR_PATH.absolute())) - -from pybind11.setup_helpers import build_ext, Pybind11Extension -from setuptools import setup - -__version__ = "0.0.1" - -cxx_std = int(os.environ.get("CMAKE_CXX_STANDARD", "17")) - -ext_modules = [ - Pybind11Extension( - "executorchcoreml", - [ - "../util/json_util.cpp", - "inmemory_filesystem.cpp", - "inmemory_filesystem_py.cpp", - "inmemory_filesystem_utils.cpp", - "memory_buffer.cpp", - "memory_stream.cpp", - "reversed_memory_stream.cpp", - ], - define_macros=[("VERSION_INFO", __version__)], - cxx_std=cxx_std, - extra_compile_args=["-mmacosx-version-min=10.15", "-g"], - include_dirs=[ - "../../third-party/nlohmann_json/single_include", - ".", - "../util", - ], - ), -] - -setup( - name="executorchcoreml", - version=__version__, - description="CoreML extension for executorch", - long_description="", - author="Apple Inc.", - ext_modules=ext_modules, - extras_require={"test": "pytest"}, - cmdclass={"build_ext": build_ext}, - include_package_data=True, - zip_safe=False, - python_requires=">=3.9", -) diff --git a/backends/apple/coreml/scripts/install_inmemoryfs.sh b/backends/apple/coreml/scripts/install_inmemoryfs.sh deleted file mode 100644 index 1fb9dd1c4d5..00000000000 --- a/backends/apple/coreml/scripts/install_inmemoryfs.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# -# Copyright © 2023 Apple Inc. All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. - -SCRIPT_DIR_PATH="$( - cd -- "$(dirname "$0")" >/dev/null 2>&1 - pwd -P -)" - -EXECUTORCH_ROOT_PATH=$(realpath "$SCRIPT_DIR_PATH/../../../../") -COREML_DIR_PATH="$EXECUTORCH_ROOT_PATH/backends/apple/coreml" - -red=`tput setaf 1` -green=`tput setaf 2` - -echo "${green}ExecuTorch: Installing inmemoryfs extension." -pip install "$COREML_DIR_PATH/runtime/inmemoryfs" -STATUS=$? -if [ $STATUS -ne 0 ]; then - echo "${red}ExecuTorch: Failed to install inmemoryfs extension." - exit 1 -fi \ No newline at end of file diff --git a/backends/apple/coreml/scripts/install_requirements.sh b/backends/apple/coreml/scripts/install_requirements.sh index 140ba09c702..d32911e3b3b 100755 --- a/backends/apple/coreml/scripts/install_requirements.sh +++ b/backends/apple/coreml/scripts/install_requirements.sh @@ -45,15 +45,6 @@ mkdir "$COREMLTOOLS_DIR_PATH/build" cmake -S "$COREMLTOOLS_DIR_PATH" -B "$COREMLTOOLS_DIR_PATH/build" cmake --build "$COREMLTOOLS_DIR_PATH/build" --parallel -echo "${green}ExecuTorch: Installing coremltools." -pip install "$COREMLTOOLS_DIR_PATH" - -STATUS=$? -if [ $STATUS -ne 0 ]; then - echo "${red}ExecuTorch: Failed to install coremltools." - exit 1 -fi - echo "${green}ExecuTorch: Cloning nlohmann." git clone https://github.com/nlohmann/json.git "$COREML_DIR_PATH/third-party/nlohmann_json" STATUS=$? @@ -62,8 +53,6 @@ if [ $STATUS -ne 0 ]; then exit 1 fi -sh "$COREML_DIR_PATH/scripts/install_inmemoryfs.sh" - echo "${green}ExecuTorch: Copying protobuf files." mkdir -p "$COREML_DIR_PATH/runtime/sdk/format/" cp -rf "$PROTOBUF_FILES_DIR_PATH" "$COREML_DIR_PATH/runtime/sdk/format/" diff --git a/examples/apple/coreml/scripts/extract_coreml_models.py b/examples/apple/coreml/scripts/extract_coreml_models.py index d2812d37ab0..b3778a22625 100644 --- a/examples/apple/coreml/scripts/extract_coreml_models.py +++ b/examples/apple/coreml/scripts/extract_coreml_models.py @@ -10,12 +10,9 @@ from typing import List, Optional -import executorchcoreml - +from executorch.backends.apple.coreml import executorchcoreml from executorch.backends.apple.coreml.compiler import CoreMLBackend - from executorch.exir._serialize._program import deserialize_pte_binary - from executorch.exir.schema import ( BackendDelegate, BackendDelegateDataReference, diff --git a/pyproject.toml b/pyproject.toml index 90640c8dbdd..d4d09dfa8e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,8 @@ dependencies=[ "sympy", "tabulate", "typing-extensions", + # macOS Only + "coremltools==8.1; platform_system == 'Darwin'", ] [project.urls] diff --git a/setup.py b/setup.py index ae1e0618dae..871fdf329c2 100644 --- a/setup.py +++ b/setup.py @@ -84,6 +84,10 @@ def _cmake_args_defines() -> Dict[str, str]: return result +def _is_macos() -> bool: + return sys.platform == "darwin" + + class ShouldBuild: """Indicates whether to build various components.""" @@ -125,7 +129,7 @@ def pybindings(cls) -> bool: @classmethod def coreml(cls) -> bool: - return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_COREML", default=False) + return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_COREML", default=_is_macos()) @classmethod def mps(cls) -> bool: @@ -135,10 +139,6 @@ def mps(cls) -> bool: def xnnpack(cls) -> bool: return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_XNNPACK", default=False) - @classmethod - def coreml(cls) -> bool: - return cls._is_env_enabled("EXECUTORCH_BUILD_COREML", default=False) - @classmethod def training(cls) -> bool: return cls._is_cmake_arg_enabled( @@ -724,8 +724,14 @@ def run(self): "-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON", # add quantized ops to pybindings. "-DEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON", ] + if ShouldBuild.training(): build_args += ["--target", "_training_lib"] + + if ShouldBuild.coreml(): + cmake_args += ["-DEXECUTORCH_BUILD_COREML=ON"] + build_args += ["--target", "executorchcoreml"] + build_args += ["--target", "portable_lib"] # To link backends into the portable_lib target, callers should # add entries like `-DEXECUTORCH_BUILD_XNNPACK=ON` to the CMAKE_ARGS @@ -837,15 +843,6 @@ def get_ext_modules() -> List[Extension]: ] ) - if ShouldBuild.pybindings() or ShouldBuild.coreml(): - ext_modules.append( - BuiltExtension( - src="coreml_inmemoryfs_pybinding.*", - src_dir="backends/apple/coreml", - modpath="executorch.backends.apple.coreml.inmemoryfs", - ) - ) - if ShouldBuild.pybindings(): ext_modules.append( # Install the prebuilt pybindings extension wrapper for the runtime, @@ -868,6 +865,14 @@ def get_ext_modules() -> List[Extension]: "executorch.extension.training.pybindings._training_lib", ) ) + if ShouldBuild.coreml(): + ext_modules.append( + BuiltExtension( + src="executorchcoreml.*", + src_dir="backends/apple/coreml", + modpath="executorch.backends.apple.coreml.executorchcoreml", + ) + ) if ShouldBuild.llama_custom_ops(): ext_modules.append( BuiltFile( From 6488b4455c14454be8d11d4765495df15feed740 Mon Sep 17 00:00:00 2001 From: jathu Date: Tue, 25 Mar 2025 21:13:10 -0700 Subject: [PATCH 7/7] clean up coreml install_requirements --- backends/apple/coreml/scripts/install_requirements.sh | 8 ++++++-- pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backends/apple/coreml/scripts/install_requirements.sh b/backends/apple/coreml/scripts/install_requirements.sh index d32911e3b3b..5b3f4e3f31a 100755 --- a/backends/apple/coreml/scripts/install_requirements.sh +++ b/backends/apple/coreml/scripts/install_requirements.sh @@ -10,6 +10,10 @@ SCRIPT_DIR_PATH="$( pwd -P )" +# TODO(jathu): remove the need to fetch coremltools to build deps for coreml_executor_runner. +# Keep this version in sync with: pyproject.toml +COREMLTOOLS_VERSION="8.1" + red=`tput setaf 1` green=`tput setaf 2` @@ -24,7 +28,7 @@ rm -rf "$COREML_DIR_PATH/third-party" mkdir "$COREML_DIR_PATH/third-party" echo "${green}ExecuTorch: Cloning coremltools." -git clone --depth 1 --branch 8.1 "https://github.com/apple/coremltools.git" $COREMLTOOLS_DIR_PATH +git clone --depth 1 --branch "${COREMLTOOLS_VERSION}" "https://github.com/apple/coremltools.git" $COREMLTOOLS_DIR_PATH cd $COREMLTOOLS_DIR_PATH STATUS=$? @@ -43,7 +47,7 @@ fi mkdir "$COREMLTOOLS_DIR_PATH/build" cmake -S "$COREMLTOOLS_DIR_PATH" -B "$COREMLTOOLS_DIR_PATH/build" -cmake --build "$COREMLTOOLS_DIR_PATH/build" --parallel +cmake --build "$COREMLTOOLS_DIR_PATH/build" --parallel --target mlmodel echo "${green}ExecuTorch: Cloning nlohmann." git clone https://github.com/nlohmann/json.git "$COREML_DIR_PATH/third-party/nlohmann_json" diff --git a/pyproject.toml b/pyproject.toml index d4d09dfa8e7..b2bd5c06944 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ dependencies=[ "sympy", "tabulate", "typing-extensions", - # macOS Only + # Keep this version in sync with: ./backends/apple/coreml/scripts/install_requirements.sh "coremltools==8.1; platform_system == 'Darwin'", ]