Skip to content

Commit 899aaa9

Browse files
committed
update usage
1 parent b033414 commit 899aaa9

File tree

8 files changed

+14
-91
lines changed

8 files changed

+14
-91
lines changed

backends/apple/coreml/TARGETS

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ runtime.python_library(
2323
],
2424
deps = [
2525
"fbsource//third-party/pypi/coremltools:coremltools",
26-
":executorchcoreml",
26+
":inmemoryfs_pybinding",
2727
"//executorch/exir/backend:backend_details",
2828
"//executorch/exir/backend:compile_spec_schema",
2929
],
@@ -59,7 +59,7 @@ runtime.python_library(
5959
)
6060

6161
runtime.cxx_python_extension(
62-
name = "executorchcoreml",
62+
name = "inmemoryfs_pybinding",
6363
srcs = [
6464
"runtime/inmemoryfs/inmemory_filesystem.cpp",
6565
"runtime/inmemoryfs/inmemory_filesystem_py.cpp",
@@ -80,7 +80,7 @@ runtime.cxx_python_extension(
8080
"-Iexecutorch/backends/apple/coreml/runtime/util",
8181
],
8282
types = [
83-
"executorchcoreml.pyi",
83+
"inmemoryfs.pyi",
8484
],
8585
visibility = [
8686
"//executorch/examples/apple/coreml/...",

backends/apple/coreml/compiler/coreml_preprocess.py

+2-3
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 inmemoryfs
2121
from executorch.exir.backend.backend_details import (
2222
BackendDetails,
2323
ExportedProgram,
@@ -385,8 +385,7 @@ def preprocess_model(
385385
)
386386

387387
processed_bytes: bytes = (
388-
executorchcoreml.flatten_directory_contents(str(model_dir_path.resolve()))
389-
or b""
388+
inmemoryfs.flatten_directory_contents(str(model_dir_path.resolve())) or b""
390389
)
391390

392391
debug_handle_map: Optional[Dict[str, Tuple[int]]] = None

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

-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ if [ $STATUS -ne 0 ]; then
6262
exit 1
6363
fi
6464

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

examples/apple/coreml/scripts/extract_coreml_models.py

+2-5
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 inmemoryfs
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,
@@ -50,7 +47,7 @@ def extract_coreml_models(pte_data: bytes):
5047
shutil.rmtree(model_path.absolute())
5148
os.makedirs(model_path.absolute())
5249

53-
if executorchcoreml.unflatten_directory_contents(
50+
if inmemoryfs.unflatten_directory_contents(
5451
coreml_processed_bytes, str(model_path.absolute())
5552
):
5653
print(f"Core ML models are extracted and saved to path = {model_path}")

setup.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,12 @@ def run(self):
680680
# add entries like `-DEXECUTORCH_BUILD_XNNPACK=ON` to the CMAKE_ARGS
681681
# environment variable.
682682

683+
if ShouldBuild.coreml():
684+
cmake_args += [
685+
"-DEXECUTORCH_BUILD_COREML=ON",
686+
]
687+
build_args += ["--target", "coreml_inmemoryfs_pybinding"]
688+
683689
if ShouldBuild.llama_custom_ops():
684690
cmake_args += [
685691
"-DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON", # add llama sdpa ops to pybindings.
@@ -786,7 +792,7 @@ def get_ext_modules() -> List[Extension]:
786792
]
787793
)
788794

789-
if ShouldBuild.pybindings() or ShouldBuild.coreml():
795+
if ShouldBuild.coreml():
790796
ext_modules.append(
791797
BuiltExtension(
792798
src="coreml_inmemoryfs_pybinding.*",

0 commit comments

Comments
 (0)