-
Notifications
You must be signed in to change notification settings - Fork 974
Expand file tree
/
Copy pathtest_ios.sh
More file actions
executable file
·105 lines (75 loc) · 2.54 KB
/
test_ios.sh
File metadata and controls
executable file
·105 lines (75 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# 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.
# Usage:
# ./test_ios.sh [output]
# Arguments:
# output - The directory where the repository will be cloned and built.
# Default is 'executorch'.
set -e
OUTPUT="${1:-executorch}"
EXIT_STATUS=0
APP_PATH="examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo"
MODEL_NAME="mv3"
SIMULATOR_NAME="executorch"
finish() {
EXIT_STATUS=$?
if xcrun simctl list | grep -q "$SIMULATOR_NAME"; then
say "Deleting Simulator"
xcrun simctl delete "$SIMULATOR_NAME"
fi
if [ -d "$OUTPUT" ]; then
popd > /dev/null
say "Deleting Output Directory"
rm -rf "$OUTPUT"
fi
if [ $EXIT_STATUS -eq 0 ]; then
say "SUCCEEDED"
else
say "FAILED"
fi
exit $EXIT_STATUS
}
trap finish EXIT
say() {
echo -e "\033[1m\n\t** $1 **\n\033[0m"
}
say "Cloning the Code"
pushd . > /dev/null
git clone https://github.com/pytorch/executorch.git "$OUTPUT"
cd "$OUTPUT"
say "Updating the Submodules"
git submodule update --init
say "Activating a Virtual Environment"
python3 -m venv .venv
source .venv/bin/activate
say "Installing Requirements"
pip install --upgrade cmake pip setuptools wheel zstd
./install_executorch.sh --pybind coreml mps xnnpack
say "Installing CoreML Backend Requirements"
./backends/apple/coreml/scripts/install_requirements.sh
say "Installing MPS Backend Requirements"
./backends/apple/mps/install_requirements.sh
say "Exporting Models"
python3 -m examples.portable.scripts.export --model_name="$MODEL_NAME"
python3 -m examples.apple.coreml.scripts.export --model_name="$MODEL_NAME"
python3 -m examples.apple.mps.scripts.mps_example --model_name="$MODEL_NAME"
python3 -m examples.xnnpack.aot_compiler --model_name="$MODEL_NAME" --delegate
mkdir -p "$APP_PATH/Resources/Models/MobileNet/"
mv $MODEL_NAME*.pte "$APP_PATH/Resources/Models/MobileNet/"
say "Downloading Labels"
curl https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt \
-o "$APP_PATH/Resources/Models/MobileNet/imagenet_classes.txt"
say "Building Frameworks"
./build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
mv cmake-out "$APP_PATH/Frameworks"
say "Creating Simulator"
xcrun simctl create "$SIMULATOR_NAME" "iPhone 15"
say "Running Tests"
xcodebuild test \
-project "$APP_PATH.xcodeproj" \
-scheme MobileNetClassifierTest \
-destination name="$SIMULATOR_NAME"