Skip to content

Commit ea8aa03

Browse files
cymbalrushfacebook-github-bot
authored andcommitted
CoreML delegate scripts cleanup (#1025)
Summary: - Removed `install_requirements_internal script`. The script was cloning a private coremltools repo, executorch changes are now in the public coremltools repo. - Xcode projects were referring to the parent directory of executorch, the `include` path becomes invalid if the directory name is not executorch. Updated the scripts to copy the required executorch headers. - Updated coreml-delegate-test to use the build_all script. The script builds and runs the tests and the executor. Pull Request resolved: #1025 Reviewed By: cccclai Differential Revision: D50479135 Pulled By: shoumikhin fbshipit-source-id: f9908e58bcd9ae8882c051afb8adabca61642fef
1 parent 9c29c1a commit ea8aa03

File tree

12 files changed

+39
-240
lines changed

12 files changed

+39
-240
lines changed

.github/workflows/pull.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ jobs:
117117
test-coreml-delegate:
118118
name: test-coreml-delegate
119119
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
120-
secrets: inherit
121120
strategy:
122121
matrix:
123122
include:
@@ -128,7 +127,6 @@ jobs:
128127
submodules: 'true'
129128
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
130129
timeout: 60
131-
secrets-env: TOKEN_COREML_PRIVATE_REPO
132130
script: |
133131
WORKSPACE=$(pwd)
134132
pushd "${WORKSPACE}/pytorch/executorch"
@@ -137,9 +135,7 @@ jobs:
137135
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-macos.sh "${BUILD_TOOL}"
138136
139137
# Build and test coreml delegate
140-
PYTHON_EXECUTABLE=python sh backends/apple/coreml/scripts/install_requirements_internal.sh
141-
PYTHON_EXECUTABLE=python sh backends/apple/coreml/scripts/build_tests.sh
142-
PYTHON_EXECUTABLE=python sh backends/apple/coreml/scripts/run_tests.sh
138+
PYTHON_EXECUTABLE=python bash backends/apple/coreml/scripts/build_all.sh
143139
popd
144140
145141
unittest:

backends/apple/coreml/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ runtime/runner/build/
1818
runtime/libraries/
1919
runtime/inmemoryfs/build/
2020
runtime/test/models/
21+
runtime/include/executorch/
2122
third-party/
2223

2324
xcode-build/

backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/project.pbxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@
529529
DEVELOPMENT_TEAM = "";
530530
GENERATE_INFOPLIST_FILE = YES;
531531
HEADER_SEARCH_PATHS = (
532-
"$(SRCROOT)/../../../../../../",
533532
"$(SRCROOT)/../delegate",
534533
"$(SRCROOT)/../kvstore",
535534
"$(SRCROOT)/../inmemoryfs",
@@ -558,7 +557,6 @@
558557
DEVELOPMENT_TEAM = "";
559558
GENERATE_INFOPLIST_FILE = YES;
560559
HEADER_SEARCH_PATHS = (
561-
"$(SRCROOT)/../../../../../../",
562560
"$(SRCROOT)/../delegate",
563561
"$(SRCROOT)/../kvstore",
564562
"$(SRCROOT)/../inmemoryfs",

backends/apple/coreml/runtime/workspace/executorchcoreml.xcodeproj/xcshareddata/xcschemes/executorchcoreml_runner.xcscheme

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

backends/apple/coreml/scripts/build_all.sh

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,53 +12,18 @@ SCRIPT_DIR_PATH="$(
1212
pwd -P
1313
)"
1414

15-
EXECUTORCH_ROOT_PATH="$SCRIPT_DIR_PATH/../../../../"
15+
EXECUTORCH_ROOT_PATH=$(realpath "$SCRIPT_DIR_PATH/../../../../")
1616
COREML_DIR_PATH="$EXECUTORCH_ROOT_PATH/backends/apple/coreml"
1717
COREML_EXAMPLES_DIR_PATH="$EXECUTORCH_ROOT_PATH/examples/apple/coreml"
18-
TEST_ENV_NAME=".coreml-test-env"
1918
TEST_MODEL_PATH="$COREML_DIR_PATH/runtime/test/models/mv3_coreml_all.pte"
2019

2120
red=`tput setaf 1`
2221
green=`tput setaf 2`
2322

2423
cd "$EXECUTORCH_ROOT_PATH"
2524

26-
echo "${green}ExecuTorch: Updating git submmodules"
27-
git submodule sync
28-
git submodule update --init
29-
30-
STATUS=$?
31-
if [ $STATUS -ne 0 ]; then
32-
echo "${red}ExecuTorch: Failed to update git submodules."
33-
exit 1
34-
fi
35-
36-
echo "${green}ExecuTorch: Creating virtual environment."
37-
38-
function cleanup {
39-
echo "${green}ExecuTorch: Deactivating virtual environment"
40-
deactivate
41-
rm -rf "$TEST_ENV_NAME"
42-
}
43-
44-
python3 -m venv "$TEST_ENV_NAME"
45-
source "$TEST_ENV_NAME/bin/activate"
46-
trap cleanup EXIT
47-
48-
STATUS=$?
49-
if [ ${STATUS} -ne 0 ]; then
50-
echo "${red}ExecuTorch: Failed to create virtual environment."
51-
exit 1
52-
fi
53-
54-
FLATBUFFERS_PATH="$EXECUTORCH_ROOT_PATH/third-party/flatbuffers/cmake-out"
55-
export PATH="${FLATBUFFERS_PATH}:${PATH}"
56-
57-
echo "${green}ExecuTorch: Installing ExecuTorch requirements"
58-
source "$EXECUTORCH_ROOT_PATH/install_requirements.sh"
59-
6025
echo "${green}ExecuTorch: Installing CoreML requirements"
61-
source "$COREML_DIR_PATH/scripts/install_requirements_internal.sh"
26+
source "$COREML_DIR_PATH/scripts/install_requirements.sh"
6227
STATUS=$?
6328
if [ ${STATUS} -ne 0 ]; then
6429
echo "${red}ExecuTorch: Failed to install dependencies required by CoreML backend."

backends/apple/coreml/scripts/build_tests.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ SCRIPT_DIR_PATH="$(
1010
pwd -P
1111
)"
1212

13-
EXECUTORCH_ROOT_PATH="$SCRIPT_DIR_PATH/../../../../"
13+
EXECUTORCH_ROOT_PATH=$(realpath "$SCRIPT_DIR_PATH/../../../../")
1414
COREML_DIR_PATH="$EXECUTORCH_ROOT_PATH/backends/apple/coreml"
1515
IOS_TOOLCHAIN_PATH="$COREML_DIR_PATH/third-party/ios-cmake/ios.toolchain.cmake"
1616
CMAKE_BUILD_DIR_PATH="$COREML_DIR_PATH/cmake-out"
1717
LIBRARIES_DIR_PATH="$COREML_DIR_PATH/runtime/libraries"
18+
EXECUTORCH_INCLUDE_DIR_PATH="$COREML_DIR_PATH/runtime/include/executorch"
19+
20+
cd "$EXECUTORCH_ROOT_PATH"
1821

1922
echo "ExecuTorch: Building Tests"
2023

@@ -39,4 +42,12 @@ echo "ExecuTorch: Copying libraries"
3942
mkdir "$LIBRARIES_DIR_PATH"
4043
cp -f "$CMAKE_BUILD_DIR_PATH/libexecutorch.a" "$LIBRARIES_DIR_PATH"
4144

45+
#Copy ExecuTorch headers
46+
echo "ExecuTorch: Copying headers"
47+
rm -rf "$EXECUTORCH_INCLUDE_DIR_PATH"
48+
mkdir -p "$EXECUTORCH_INCLUDE_DIR_PATH"
49+
find extension \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \;
50+
find runtime \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \;
51+
find util \( -name "*.h" -o -name "*.hpp" \) -exec rsync -R '{}' "$EXECUTORCH_INCLUDE_DIR_PATH" \;
52+
4253
source "$SCRIPT_DIR_PATH/generate_test_models.sh"

backends/apple/coreml/scripts/generate_test_models.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ SCRIPT_DIR_PATH="$(
1010
pwd -P
1111
)"
1212

13-
EXECUTORCH_ROOT_PATH="$SCRIPT_DIR_PATH/../../../../"
13+
EXECUTORCH_ROOT_PATH=$(realpath "$SCRIPT_DIR_PATH/../../../../")
1414
COREML_DIR_PATH="$EXECUTORCH_ROOT_PATH/backends/apple/coreml"
1515

16+
cd "$EXECUTORCH_ROOT_PATH"
17+
1618
mkdir "$COREML_DIR_PATH/runtime/test/models/"
1719
#Generate models
1820
echo "Executorch: Generating test models"

backends/apple/coreml/scripts/install_requirements.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ SCRIPT_DIR_PATH="$(
1313
red=`tput setaf 1`
1414
green=`tput setaf 2`
1515

16-
EXECUTORCH_ROOT_PATH="$SCRIPT_DIR_PATH/../../../../"
16+
EXECUTORCH_ROOT_PATH=$(realpath "$SCRIPT_DIR_PATH/../../../../")
1717
COREML_DIR_PATH="$EXECUTORCH_ROOT_PATH/backends/apple/coreml"
1818

19+
cd "$EXECUTORCH_ROOT_PATH"
20+
1921
# clone and install coremltools
2022
if [ -d "/tmp/coremltools" ]; then
2123
rm -rf "/tmp/coremltools"
@@ -85,4 +87,4 @@ STATUS=$?
8587
if [ $STATUS -ne 0 ]; then
8688
echo "${red}ExecuTorch: Failed to install inmemoryfs extension."
8789
exit 1
88-
fi
90+
fi

backends/apple/coreml/scripts/install_requirements_internal.sh

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

backends/apple/coreml/scripts/run_tests.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ SCRIPT_DIR_PATH="$(
1010
pwd -P
1111
)"
1212

13-
EXECUTORCH_ROOT_PATH="$SCRIPT_DIR_PATH/../../../../"
13+
EXECUTORCH_ROOT_PATH=$(realpath "$SCRIPT_DIR_PATH/../../../../")
1414
COREML_DIR_PATH="$EXECUTORCH_ROOT_PATH/backends/apple/coreml"
1515

16+
cd "$EXECUTORCH_ROOT_PATH"
17+
1618
# Run the test
1719
echo "ExecuTorch: Running executorchcoreml_tests"
1820
XCODE_WORKSPACE_DIR_PATH="$COREML_DIR_PATH/runtime/workspace"

0 commit comments

Comments
 (0)