Skip to content

Commit 9f1119a

Browse files
committed
update usage
1 parent 0042ef6 commit 9f1119a

File tree

8 files changed

+23
-109
lines changed

8 files changed

+23
-109
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ if(EXECUTORCH_BUILD_PYBIND)
811811

812812
if(EXECUTORCH_BUILD_COREML)
813813
list(APPEND _dep_libs coremldelegate)
814-
list(APPEND _dep_libs coreml_inmemoryfs_pybinding)
814+
list(APPEND _dep_libs executorchcoreml)
815815
endif()
816816

817817
if(EXECUTORCH_BUILD_MPS)
@@ -936,7 +936,6 @@ if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
936936

937937
if(EXECUTORCH_BUILD_COREML)
938938
list(APPEND _executor_runner_libs coremldelegate)
939-
list(APPEND _executor_runner_libs coreml_inmemoryfs_pybinding)
940939
endif()
941940

942941
add_executable(executor_runner ${_executor_runner__srcs})

backends/apple/coreml/compiler/coreml_preprocess.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 52 deletions
This file was deleted.

backends/apple/coreml/scripts/install_inmemoryfs.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

backends/apple/coreml/scripts/install_requirements.sh

Lines changed: 0 additions & 11 deletions
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

Lines changed: 1 addition & 4 deletions
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,10 @@ def pybindings(cls) -> bool:
125125

126126
@classmethod
127127
def coreml(cls) -> bool:
128-
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_COREML", default=False)
128+
return cls._is_cmake_arg_enabled(
129+
"EXECUTORCH_BUILD_COREML",
130+
default=sys.platform == "darwin",
131+
)
129132

130133
@classmethod
131134
def mps(cls) -> bool:
@@ -135,10 +138,6 @@ def mps(cls) -> bool:
135138
def xnnpack(cls) -> bool:
136139
return cls._is_cmake_arg_enabled("EXECUTORCH_BUILD_XNNPACK", default=False)
137140

138-
@classmethod
139-
def coreml(cls) -> bool:
140-
return cls._is_env_enabled("EXECUTORCH_BUILD_COREML", default=False)
141-
142141
@classmethod
143142
def training(cls) -> bool:
144143
return cls._is_cmake_arg_enabled(
@@ -724,8 +723,14 @@ def run(self):
724723
"-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON", # add quantized ops to pybindings.
725724
"-DEXECUTORCH_BUILD_KERNELS_QUANTIZED_AOT=ON",
726725
]
726+
727727
if ShouldBuild.training():
728728
build_args += ["--target", "_training_lib"]
729+
730+
if ShouldBuild.coreml():
731+
cmake_args += ["-DEXECUTORCH_BUILD_COREML=ON"]
732+
build_args += ["--target", "executorchcoreml"]
733+
729734
build_args += ["--target", "portable_lib"]
730735
# To link backends into the portable_lib target, callers should
731736
# add entries like `-DEXECUTORCH_BUILD_XNNPACK=ON` to the CMAKE_ARGS
@@ -837,15 +842,6 @@ def get_ext_modules() -> List[Extension]:
837842
]
838843
)
839844

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-
849845
if ShouldBuild.pybindings():
850846
ext_modules.append(
851847
# Install the prebuilt pybindings extension wrapper for the runtime,
@@ -868,6 +864,14 @@ def get_ext_modules() -> List[Extension]:
868864
"executorch.extension.training.pybindings._training_lib",
869865
)
870866
)
867+
if ShouldBuild.coreml():
868+
ext_modules.append(
869+
BuiltExtension(
870+
src="executorchcoreml.*",
871+
src_dir="backends/apple/coreml",
872+
modpath="executorch.backends.apple.coreml.executorchcoreml",
873+
)
874+
)
871875
if ShouldBuild.llama_custom_ops():
872876
ext_modules.append(
873877
BuiltFile(

0 commit comments

Comments
 (0)