-
Notifications
You must be signed in to change notification settings - Fork 527
/
Copy pathtest_ios.sh
executable file
·91 lines (66 loc) · 2.25 KB
/
test_ios.sh
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
#!/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="executorch-examples/apple/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 "Activating a Virtual Environment"
python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip
say "Installing Requirements"
./install_executorch.sh
say "Cloning the Demo App"
git clone --depth 1 https://github.com/pytorch-labs/executorch-examples.git
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 "Creating Simulator"
xcrun simctl create "$SIMULATOR_NAME" "iPhone 15"
say "Running Tests"
xcodebuild test \
-project "$APP_PATH.xcodeproj" \
-scheme MobileNetClassifierTest \
-destination name="$SIMULATOR_NAME"