Skip to content

Commit 91d6452

Browse files
Guang Yangpytorchbot
authored andcommitted
Move benchmark apps to extension/benchmark dir (#5951)
Summary: Pull Request resolved: #5951 Reviewed By: huydhn Differential Revision: D64012575 Pulled By: guangy10 fbshipit-source-id: 27bb25586af2aafb8df6c0623d502482b4fa238b (cherry picked from commit ac2ae07)
1 parent 7b93aa2 commit 91d6452

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+226
-37
lines changed

.github/workflows/android-perf.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,3 +232,78 @@ jobs:
232232
test-spec: ${{ inputs.test_spec || 'https://ossci-android.s3.amazonaws.com/executorch/android-llm-device-farm-test-spec.yml' }}
233233
# Uploaded to S3 from the previous job
234234
extra-data: https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/${{ matrix.model }}_${{ matrix.delegate }}/model.zip
235+
236+
upload-benchmark-results:
237+
needs:
238+
- benchmark-on-device
239+
if: always()
240+
runs-on: linux.2xlarge
241+
environment: upload-benchmark-results
242+
permissions:
243+
id-token: write
244+
contents: read
245+
steps:
246+
- uses: actions/checkout@v3
247+
with:
248+
submodules: false
249+
250+
- name: Authenticate with AWS
251+
uses: aws-actions/configure-aws-credentials@v4
252+
with:
253+
role-to-assume: arn:aws:iam::308535385114:role/gha_workflow_upload-benchmark-results
254+
# The max duration enforced by the server side
255+
role-duration-seconds: 18000
256+
aws-region: us-east-1
257+
258+
- name: Setup conda
259+
uses: pytorch/test-infra/.github/actions/setup-miniconda@main
260+
with:
261+
python-version: '3.10'
262+
263+
- name: Download the list of artifacts from S3
264+
env:
265+
ARTIFACTS_S3_DIR: s3://gha-artifacts/device_farm/${{ github.run_id }}/${{ github.run_attempt }}/artifacts/
266+
shell: bash
267+
run: |
268+
set -eux
269+
${CONDA_RUN} python -mpip install awscli==1.32.18
270+
271+
mkdir -p artifacts
272+
pushd artifacts
273+
${CONDA_RUN} aws s3 sync "${ARTIFACTS_S3_DIR}" .
274+
popd
275+
276+
ls -lah artifacts
277+
278+
- name: Extract the benchmark results JSON
279+
shell: bash
280+
run: |
281+
set -eux
282+
283+
mkdir -p benchmark-results
284+
285+
for ARTIFACTS_BY_JOB in artifacts/*.json; do
286+
[ -f "${ARTIFACTS_BY_JOB}" ] || break
287+
echo "${ARTIFACTS_BY_JOB}"
288+
${CONDA_RUN} python .github/scripts/extract_benchmark_results.py \
289+
--artifacts "${ARTIFACTS_BY_JOB}" \
290+
--output-dir benchmark-results \
291+
--repo ${{ github.repository }} \
292+
--head-branch ${{ github.head_ref || github.ref_name }} \
293+
--workflow-name "${{ github.workflow }}" \
294+
--workflow-run-id ${{ github.run_id }} \
295+
--workflow-run-attempt ${{ github.run_attempt }}
296+
done
297+
298+
ls -lah benchmark-results
299+
300+
for BENCHMARK_RESULTS in benchmark-results/*.json; do
301+
cat "${BENCHMARK_RESULTS}"
302+
echo
303+
done
304+
305+
- name: Upload the benchmark results
306+
uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main
307+
with:
308+
benchmark-results-dir: 'benchmark-results'
309+
dry-run: false

.github/workflows/android.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ on:
1515
- install_requirements.sh
1616
- examples/demo-apps/android/**
1717
- extension/android/**
18+
- extension/benchmark/android/**
1819
- extension/module/**
1920
workflow_dispatch:
2021

.github/workflows/apple-perf.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,17 @@ jobs:
235235
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
236236
build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
237237
238-
mkdir -p extension/apple/Benchmark/Frameworks
238+
mkdir -p extension/benchmark/apple/Benchmark/Frameworks
239239
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
240-
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/apple/Benchmark/Frameworks/
240+
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/benchmark/apple/Benchmark/Frameworks/
241241
) done
242242
echo "::endgroup::"
243243
244244
# NB: Although exported models can be copied to this directory and bundled together with the
245245
# app, we don't use this in CI and rely on AWS extra data parameter to make the model and the
246246
# tokenizer available to the benchmark. This decouples the app and the model. We just need to
247247
# create the directory here to pass the build
248-
mkdir -p extension/apple/Benchmark/Models
248+
mkdir -p extension/benchmark/apple/Benchmark/Models
249249
${CONDA_RUN} --no-capture-output \
250250
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
251251

.github/workflows/apple.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
- build/test_ios_ci.sh
1818
- examples/demo-apps/apple_ios/**
1919
- extension/apple/**
20+
- extension/benchmark/apple/**
2021
- extension/module/**
2122
workflow_dispatch:
2223

@@ -215,3 +216,70 @@ jobs:
215216
shasum -a 256 "${FILENAME}"
216217
${AWS_CMD} "${FILENAME}" s3://ossci-ios/executorch/ --acl public-read
217218
done
219+
220+
build-benchmark-app:
221+
name: build-benchmark-app
222+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
223+
secrets: inherit
224+
with:
225+
runner: macos-latest-xlarge
226+
python-version: '3.11'
227+
submodules: 'true'
228+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
229+
upload-artifact: ios-apps
230+
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
231+
timeout: 90
232+
script: |
233+
set -eux
234+
235+
echo "::group::Setting up CI environment"
236+
.ci/scripts/setup-conda.sh
237+
238+
BUILD_TOOL=cmake
239+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
240+
GITHUB_RUNNER=1 PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
241+
.ci/scripts/setup-macos.sh "${BUILD_TOOL}"
242+
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
243+
244+
# Setup Apple certificate for iOS development
245+
BUILD_PROVISION_PROFILE_BASE64="${SECRET_EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64}" \
246+
BUILD_CERTIFICATE_BASE64="${SECRET_BUILD_CERTIFICATE_BASE64}" \
247+
KEYCHAIN_PASSWORD="${SECRET_KEYCHAIN_PASSWORD}" \
248+
.ci/scripts/setup-ios.sh
249+
250+
# Install CoreML Backend Requirements
251+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
252+
backends/apple/coreml/scripts/install_requirements.sh
253+
254+
# Install MPS Backend Requirements
255+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
256+
backends/apple/mps/install_requirements.sh
257+
echo "::endgroup::"
258+
259+
echo "::group::Build ExecuTorch iOS frameworks"
260+
FRAMEWORKS=(
261+
"executorch"
262+
"backend_coreml"
263+
"backend_mps"
264+
"backend_xnnpack"
265+
"kernels_custom"
266+
"kernels_optimized"
267+
"kernels_portable"
268+
"kernels_quantized"
269+
)
270+
271+
# Build Release iOS Frameworks
272+
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
273+
build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
274+
275+
mkdir -p extension/benchmark/apple/Benchmark/Frameworks
276+
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
277+
cp -r "cmake-out/${FRAMEWORK}.xcframework" extension/benchmark/apple/Benchmark/Frameworks/
278+
) done
279+
echo "::endgroup::"
280+
281+
echo "::group::Build ExecuTorch benchmark app"
282+
mkdir -p extension/benchmark/apple/Benchmark/Models
283+
${CONDA_RUN} --no-capture-output \
284+
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
285+
echo "::endgroup::"

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
FILES_NEEDS_FORMAT=$(/opt/google-java-format -n extension/android/src/main/java/org/pytorch/executorch/*.java \
6767
examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/*.java \
6868
examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/*.java \
69-
extension/android/benchmark/app/src/main/java/org/pytorch/minibench/*.java)
69+
extension/benchmark/android/benchmark/app/src/main/java/org/pytorch/minibench/*.java)
7070
if [ -n "$FILES_NEEDS_FORMAT" ]; then
7171
echo "Warning: The following files need formatting. Please use google-java-format."
7272
echo "Use a binary from https://github.com/google/google-java-format/releases/"

.github/workflows/upload-android-test-specs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
pull_request:
55
paths:
66
- .github/workflows/upload-android-test-specs.yml
7-
- extension/android/benchmark/android-llm-device-farm-test-spec.yml
7+
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
88
push:
99
branches:
1010
- main
1111
paths:
1212
- .github/workflows/upload-android-test-specs.yml
13-
- extension/android/benchmark/android-llm-device-farm-test-spec.yml
13+
- extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
1414

1515
concurrency:
1616
# NB: This concurency group needs to be different than the one used in android-perf, otherwise
@@ -32,7 +32,7 @@ jobs:
3232
${{ github.repository }}/${{ github.run_id }}/artifacts
3333
retention-days: 1
3434
if-no-files-found: error
35-
path: extension/android/benchmark/android-llm-device-farm-test-spec.yml
35+
path: extension/benchmark/android/benchmark/android-llm-device-farm-test-spec.yml
3636

3737
validate-android-test-spec:
3838
needs: upload-android-test-spec-for-validation
@@ -77,7 +77,7 @@ jobs:
7777
7878
- name: Upload the spec to S3 ossci-android bucket
7979
shell: bash
80-
working-directory: extension/android/benchmark/
80+
working-directory: extension/benchmark/android/benchmark/
8181
env:
8282
SPEC_FILE: android-llm-device-farm-test-spec.yml
8383
run: |

.github/workflows/upload-apple-test-specs.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ on:
44
pull_request:
55
paths:
66
- .github/workflows/upload-apple-test-specs.yml
7-
- examples/demo-apps/apple_ios/default-ios-device-farm-appium-test-spec.yml
7+
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
88
push:
99
branches:
1010
- main
1111
paths:
1212
- .github/workflows/upload-apple-test-specs.yml
13-
- examples/demo-apps/apple_ios/default-ios-device-farm-appium-test-spec.yml
13+
- extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
1414

1515
concurrency:
1616
# NB: This concurency group needs to be different than the one used in apple-perf, otherwise
@@ -32,7 +32,7 @@ jobs:
3232
${{ github.repository }}/${{ github.run_id }}/artifacts
3333
retention-days: 1
3434
if-no-files-found: error
35-
path: examples/demo-apps/apple_ios/default-ios-device-farm-appium-test-spec.yml
35+
path: extension/benchmark/apple/Benchmark/default-ios-device-farm-appium-test-spec.yml
3636

3737
validate-apple-test-spec:
3838
needs: upload-apple-test-spec-for-validation
@@ -78,7 +78,7 @@ jobs:
7878
7979
- name: Upload the spec to S3 ossci-ios bucket
8080
shell: bash
81-
working-directory: examples/demo-apps/apple_ios
81+
working-directory: extension/benchmark/apple/Benchmark/
8282
env:
8383
SPEC_FILE: default-ios-device-farm-appium-test-spec.yml
8484
run: |

build/build_android_llm_demo.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ build_android_demo_apps() {
108108
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew build assembleAndroidTest
109109
popd
110110

111-
mkdir -p extension/android/benchmark/app/libs
112-
cp ${BUILD_AAR_DIR}/executorch.aar extension/android/benchmark/app/libs
113-
pushd extension/android/benchmark
111+
mkdir -p extension/benchmark/android/benchmark/app/libs
112+
cp ${BUILD_AAR_DIR}/executorch.aar extension/benchmark/android/benchmark/app/libs
113+
pushd extension/benchmark/android/benchmark
114114
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew build assembleAndroidTest
115115
popd
116116
}
@@ -135,8 +135,8 @@ collect_artifacts_to_be_uploaded() {
135135
# Collect MiniBench APK
136136
MINIBENCH_APP_DIR="${ARTIFACTS_DIR_NAME}/minibench"
137137
mkdir -p "${MINIBENCH_APP_DIR}"
138-
cp extension/android/benchmark/app/build/outputs/apk/debug/*.apk "${MINIBENCH_APP_DIR}"
139-
cp extension/android/benchmark/app/build/outputs/apk/androidTest/debug/*.apk "${MINIBENCH_APP_DIR}"
138+
cp extension/benchmark/android/benchmark/app/build/outputs/apk/debug/*.apk "${MINIBENCH_APP_DIR}"
139+
cp extension/benchmark/android/benchmark/app/build/outputs/apk/androidTest/debug/*.apk "${MINIBENCH_APP_DIR}"
140140
}
141141

142142
BUILD_AAR_DIR="$(mktemp -d)"

build/build_apple_llm_demo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
set -euo pipefail
99

1010
ARTIFACTS_DIR_NAME="$1"
11-
APP_PATH="extension/apple/Benchmark/Benchmark"
11+
APP_PATH="extension/benchmark/apple/Benchmark/Benchmark"
1212

1313
xcodebuild build-for-testing \
1414
-project "${APP_PATH}.xcodeproj" \
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignEscapedNewlinesLeft: true
4+
AlignTrailingComments: false
5+
AllowAllParametersOfDeclarationOnNextLine: true
6+
AllowShortIfStatementsOnASingleLine: false
7+
AllowShortLoopsOnASingleLine: false
8+
AlwaysBreakBeforeMultilineStrings: true
9+
AlwaysBreakTemplateDeclarations: true
10+
BinPackArguments: false
11+
BinPackParameters: false
12+
BreakBeforeBinaryOperators: false
13+
BreakBeforeBraces: Attach
14+
BreakConstructorInitializersBeforeComma: false
15+
ColumnLimit: 80
16+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
17+
ConstructorInitializerIndentWidth: 4
18+
ContinuationIndentWidth: 4
19+
Cpp11BracedListStyle: true
20+
DerivePointerAlignment: false
21+
ExperimentalAutoDetectBinPacking: true
22+
IndentCaseLabels: false
23+
IndentFunctionDeclarationAfterType: false
24+
IndentWidth: 2
25+
MaxEmptyLinesToKeep: 1
26+
NamespaceIndentation: None
27+
ObjCSpaceBeforeProtocolList: false
28+
PenaltyBreakBeforeFirstCallParameter: 10
29+
PenaltyBreakComment: 60
30+
PenaltyBreakFirstLessLess: 20
31+
PenaltyBreakString: 1000
32+
PenaltyExcessCharacter: 1000000
33+
PenaltyReturnTypeOnItsOwnLine: 200
34+
PointerAlignment: Right
35+
SpaceAfterControlStatementKeyword: true
36+
SpaceBeforeAssignmentOperators: true
37+
SpaceInEmptyParentheses: false
38+
SpacesBeforeTrailingComments: 1
39+
SpacesInAngles: false
40+
SpacesInCStyleCastParentheses: false
41+
SpacesInParentheses: false
42+
Standard: Cpp11
43+
TabWidth: 8
44+
UseTab: Never
45+
...

0 commit comments

Comments
 (0)