Skip to content

Commit 840151e

Browse files
committed
update usage
1 parent 0042ef6 commit 840151e

File tree

8 files changed

+23
-109
lines changed

8 files changed

+23
-109
lines changed

CMakeLists.txt

-2
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,6 @@ if(EXECUTORCH_BUILD_PYBIND)
811811

812812
if(EXECUTORCH_BUILD_COREML)
813813
list(APPEND _dep_libs coremldelegate)
814-
list(APPEND _dep_libs coreml_inmemoryfs_pybinding)
815814
endif()
816815

817816
if(EXECUTORCH_BUILD_MPS)
@@ -936,7 +935,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
936935

937936
if(EXECUTORCH_BUILD_COREML)
938937
list(APPEND _executor_runner_libs coremldelegate)
939-
list(APPEND _executor_runner_libs coreml_inmemoryfs_pybinding)
940938
endif()
941939

942940
add_executable(executor_runner ${_executor_runner__srcs})

backends/apple/coreml/compiler/coreml_preprocess.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import coremltools as ct
1818
import coremltools.optimize as cto
19-
import executorchcoreml
2019

20+
from executorch.backends.apple.coreml import executorchcoreml
2121
from executorch.exir.backend.backend_details import (
2222
BackendDetails,
2323
ExportedProgram,

backends/apple/coreml/runtime/inmemoryfs/setup.py

-52
This file was deleted.

backends/apple/coreml/scripts/install_inmemoryfs.sh

-25
This file was deleted.

backends/apple/coreml/scripts/install_requirements.sh

-11
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,6 @@ mkdir "$COREMLTOOLS_DIR_PATH/build"
4545
cmake -S "$COREMLTOOLS_DIR_PATH" -B "$COREMLTOOLS_DIR_PATH/build"
4646
cmake --build "$COREMLTOOLS_DIR_PATH/build" --parallel
4747

48-
echo "${green}ExecuTorch: Installing coremltools."
49-
pip install "$COREMLTOOLS_DIR_PATH"
50-
51-
STATUS=$?
52-
if [ $STATUS -ne 0 ]; then
53-
echo "${red}ExecuTorch: Failed to install coremltools."
54-
exit 1
55-
fi
56-
5748
echo "${green}ExecuTorch: Cloning nlohmann."
5849
git clone https://github.com/nlohmann/json.git "$COREML_DIR_PATH/third-party/nlohmann_json"
5950
STATUS=$?
@@ -62,8 +53,6 @@ if [ $STATUS -ne 0 ]; then
6253
exit 1
6354
fi
6455

65-
sh "$COREML_DIR_PATH/scripts/install_inmemoryfs.sh"
66-
6756
echo "${green}ExecuTorch: Copying protobuf files."
6857
mkdir -p "$COREML_DIR_PATH/runtime/sdk/format/"
6958
cp -rf "$PROTOBUF_FILES_DIR_PATH" "$COREML_DIR_PATH/runtime/sdk/format/"

examples/apple/coreml/scripts/extract_coreml_models.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@
1010

1111
from typing import List, Optional
1212

13-
import executorchcoreml
14-
13+
from executorch.backends.apple.coreml import executorchcoreml
1514
from executorch.backends.apple.coreml.compiler import CoreMLBackend
16-
1715
from executorch.exir._serialize._program import deserialize_pte_binary
18-
1916
from executorch.exir.schema import (
2017
BackendDelegate,
2118
BackendDelegateDataReference,

pyproject.toml

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ dependencies=[
6767
"sympy",
6868
"tabulate",
6969
"typing-extensions",
70+
# macOS Only
71+
"coremltools==8.1; platform_system == 'Darwin'",
7072
]
7173

7274
[project.urls]

setup.py

+19-14
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ def _cmake_args_defines() -> Dict[str, str]:
8484
return result
8585

8686

87+
def _is_macos() -> bool:
88+
return sys.platform == "darwin"
89+
90+
8791
class ShouldBuild:
8892
"""Indicates whether to build various components."""
8993

@@ -125,7 +129,7 @@ def pybindings(cls) -> bool:
125129

126130
@classmethod
127131
def coreml(cls) -> bool:
128-
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_COREML", default=False)
132+
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_COREML", default=_is_macos())
129133

130134
@classmethod
131135
def mps(cls) -> bool:
@@ -135,10 +139,6 @@ def mps(cls) -> bool:
135139
def xnnpack(cls) -> bool:
136140
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_XNNPACK", default=False)
137141

138-
@classmethod
139-
def coreml(cls) -> bool:
140-
return cls._is_env_enabled("EXECUTORCH_BUILD_COREML", default=False)
141-
142142
@classmethod
143143
def training(cls) -> bool:
144144
return cls._is_cmake_arg_enabled(
@@ -724,8 +724,14 @@ def run(self):
724724
"-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON", # add quantized ops to pybindings.
725725
"-DEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON",
726726
]
727+
727728
if ShouldBuild.training():
728729
build_args += ["--target", "_training_lib"]
730+
731+
if ShouldBuild.coreml():
732+
cmake_args += ["-DEXECUTORCH_BUILD_COREML=ON"]
733+
build_args += ["--target", "executorchcoreml"]
734+
729735
build_args += ["--target", "portable_lib"]
730736
# To link backends into the portable_lib target, callers should
731737
# add entries like `-DEXECUTORCH_BUILD_XNNPACK=ON` to the CMAKE_ARGS
@@ -837,15 +843,6 @@ def get_ext_modules() -> List[Extension]:
837843
]
838844
)
839845

840-
if ShouldBuild.pybindings() or ShouldBuild.coreml():
841-
ext_modules.append(
842-
BuiltExtension(
843-
src="coreml_inmemoryfs_pybinding.*",
844-
src_dir="backends/apple/coreml",
845-
modpath="executorch.backends.apple.coreml.inmemoryfs",
846-
)
847-
)
848-
849846
if ShouldBuild.pybindings():
850847
ext_modules.append(
851848
# Install the prebuilt pybindings extension wrapper for the runtime,
@@ -868,6 +865,14 @@ def get_ext_modules() -> List[Extension]:
868865
"executorch.extension.training.pybindings._training_lib",
869866
)
870867
)
868+
if ShouldBuild.coreml():
869+
ext_modules.append(
870+
BuiltExtension(
871+
src="executorchcoreml.*",
872+
src_dir="backends/apple/coreml",
873+
modpath="executorch.backends.apple.coreml.executorchcoreml",
874+
)
875+
)
871876
if ShouldBuild.llama_custom_ops():
872877
ext_modules.append(
873878
BuiltFile(

0 commit comments

Comments
 (0)