Skip to content

Commit 9b0db51

Browse files
committed
Update on "[executorch][flat_tensor] Serialize flat tensor tests"
More comprehensive testing for flat tensor serialization. Differential Revision: [D67007821](https://our.internmc.facebook.com/intern/diff/D67007821/) [ghstack-poisoned]
2 parents 8f7a39b + 432992e commit 9b0db51

File tree

331 files changed

+8572
-3677
lines changed

Some content is hidden

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

331 files changed

+8572
-3677
lines changed

.ci/docker/ci_commit_pins/buck2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2024-05-15
1+
2024-12-16

.ci/docker/ci_commit_pins/pytorch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2ea4b56ec872424e486c4fe2d55da061067a2ed3
1+
0a94bb432ed75cc2d950d81b2921363218a7e459

.ci/docker/conda-env-ci.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
cmake=3.22.1
22
ninja=1.10.2
3+
libuv
4+
pkg-config
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Copyright 2024 Arm Limited and/or its affiliates.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
# NB: This function could be used to install Arm dependencies
8+
# Setup arm example environment (including TOSA tools)
9+
git config --global user.email "[email protected]"
10+
git config --global user.name "Github Executorch"
11+
bash examples/arm/setup.sh --i-agree-to-the-contained-eula

.ci/scripts/setup-macos.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,9 @@ if [[ -z "${GITHUB_RUNNER:-}" ]]; then
131131
fi
132132

133133
print_cmake_info
134-
install_executorch
134+
install_pytorch_and_domains
135+
# We build PyTorch from source here instead of using nightly. This allows CI to test against
136+
# the pinned commit from PyTorch
137+
install_executorch "use-pt-pinned-commit"
135138
build_executorch_runner "${BUILD_TOOL}"
139+
do_not_use_nightly_on_ci

.ci/scripts/utils.sh

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,42 @@ install_pip_dependencies() {
4040
popd || return
4141
}
4242

43+
install_domains() {
44+
echo "Install torchvision and torchaudio"
45+
pip install --no-use-pep517 --user "git+https://github.com/pytorch/audio.git@${TORCHAUDIO_VERSION}"
46+
pip install --no-use-pep517 --user "git+https://github.com/pytorch/vision.git@${TORCHVISION_VERSION}"
47+
}
48+
49+
install_pytorch_and_domains() {
50+
pushd .ci/docker || return
51+
TORCH_VERSION=$(cat ci_commit_pins/pytorch.txt)
52+
popd || return
53+
54+
git clone https://github.com/pytorch/pytorch.git
55+
56+
# Fetch the target commit
57+
pushd pytorch || return
58+
git checkout "${TORCH_VERSION}"
59+
git submodule update --init --recursive
60+
61+
export USE_DISTRIBUTED=1
62+
# Then build and install PyTorch
63+
python setup.py bdist_wheel
64+
pip install "$(echo dist/*.whl)"
65+
66+
# Grab the pinned audio and vision commits from PyTorch
67+
TORCHAUDIO_VERSION=$(cat .github/ci_commit_pins/audio.txt)
68+
export TORCHAUDIO_VERSION
69+
TORCHVISION_VERSION=$(cat .github/ci_commit_pins/vision.txt)
70+
export TORCHVISION_VERSION
71+
72+
install_domains
73+
74+
popd || return
75+
# Print sccache stats for debugging
76+
sccache --show-stats || true
77+
}
78+
4379
install_flatc_from_source() {
4480
# NB: This function could be used to install flatbuffer from source
4581
pushd third-party/flatbuffers || return
@@ -59,17 +95,6 @@ install_flatc_from_source() {
5995
popd || return
6096
}
6197

62-
install_arm() {
63-
# NB: This function could be used to install Arm dependencies
64-
# Setup arm example environment (including TOSA tools)
65-
git config --global user.email "[email protected]"
66-
git config --global user.name "Github Executorch"
67-
bash examples/arm/setup.sh --i-agree-to-the-contained-eula
68-
69-
# Test tosa_reference flow
70-
source examples/arm/ethos-u-scratch/setup_path.sh
71-
}
72-
7398
build_executorch_runner_buck2() {
7499
# Build executorch runtime with retry as this step is flaky on macos CI
75100
retry buck2 build //examples/portable/executor_runner:executor_runner

.github/workflows/android-perf.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ jobs:
9898
- uses: actions/checkout@v3
9999

100100
- name: Prepare the spec
101+
id: prepare
101102
shell: bash
102103
env:
103104
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
@@ -111,7 +112,7 @@ jobs:
111112
# so let's just sed it
112113
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' android-llm-device-farm-test-spec.yml.j2
113114
114-
BENCHMARK_CONFIG_ID="${{ matrix.model }}_${{ matrix.config }}"
115+
BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
115116
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
116117
# later by the upload script
117118
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' android-llm-device-farm-test-spec.yml.j2
@@ -122,6 +123,7 @@ jobs:
122123
123124
# Save the benchmark configs so that we can use it later in the dashboard
124125
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
126+
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT
125127
126128
- name: Upload the spec
127129
uses: seemethere/upload-artifact-s3@v5
@@ -141,7 +143,7 @@ jobs:
141143
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
142144
retention-days: 1
143145
if-no-files-found: error
144-
path: extension/benchmark/android/benchmark/${{ matrix.model }}_${{ matrix.config }}.json
146+
path: extension/benchmark/android/benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json
145147

146148
export-models:
147149
name: export-models

.github/workflows/apple-perf.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ jobs:
100100
- uses: actions/checkout@v3
101101

102102
- name: Prepare the spec
103+
id: prepare
103104
shell: bash
104105
env:
105106
BENCHMARK_CONFIG: ${{ toJSON(matrix) }}
@@ -113,7 +114,7 @@ jobs:
113114
# so let's just sed it
114115
sed -i -e 's,{{ model_path }},'"${MODEL_PATH}"',g' default-ios-device-farm-appium-test-spec.yml.j2
115116
116-
BENCHMARK_CONFIG_ID="${{ matrix.model }}_${{ matrix.config }}"
117+
BENCHMARK_CONFIG_ID=$(echo "${{ matrix.model }}_${{ matrix.config }}" | sed -e 's/[^A-Za-z0-9._-]/_/g')
117118
# The config for this benchmark runs, we save it in the test spec so that it can be fetched
118119
# later by the upload script
119120
sed -i -e 's,{{ benchmark_config_id }},'"${BENCHMARK_CONFIG_ID}"',g' default-ios-device-farm-appium-test-spec.yml.j2
@@ -124,6 +125,7 @@ jobs:
124125
125126
# Save the benchmark configs so that we can use it later in the dashboard
126127
echo "${BENCHMARK_CONFIG}" > "${BENCHMARK_CONFIG_ID}.json"
128+
echo "benchmark-config-id=${BENCHMARK_CONFIG_ID}" >> $GITHUB_OUTPUT
127129
128130
- name: Upload the spec
129131
uses: seemethere/upload-artifact-s3@v5
@@ -143,7 +145,7 @@ jobs:
143145
${{ github.repository }}/${{ github.run_id }}/artifacts/benchmark-configs/
144146
retention-days: 1
145147
if-no-files-found: error
146-
path: extension/benchmark/apple/Benchmark/${{ matrix.model }}_${{ matrix.config }}.json
148+
path: extension/benchmark/apple/Benchmark/${{ steps.prepare.outputs.benchmark-config-id }}.json
147149

148150
export-models:
149151
name: export-models
@@ -408,7 +410,7 @@ jobs:
408410
runs-on: linux.2xlarge
409411
steps:
410412
- name: Download the apps from GitHub
411-
uses: actions/download-artifact@v3
413+
uses: actions/download-artifact@v4
412414
with:
413415
# The name here needs to match the name of the upload-artifact parameter
414416
name: ios-apps

.github/workflows/apple.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
5454
timeout: 90
5555
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_DEMO_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
56-
upload-artifact: ios-apps
56+
upload-artifact: ios-demo-app
5757
script: |
5858
set -eux
5959
@@ -83,10 +83,10 @@ jobs:
8383
runs-on: linux.2xlarge
8484
steps:
8585
- name: Download the artifacts from GitHub
86-
uses: actions/download-artifact@v3
86+
uses: actions/download-artifact@v4
8787
with:
8888
# The name here needs to match the name of the upload-artifact parameter
89-
name: ios-apps
89+
name: ios-demo-app
9090
path: ${{ runner.temp }}/artifacts/
9191

9292
- name: Verify the artifacts
@@ -216,7 +216,7 @@ jobs:
216216
role-to-assume: arn:aws:iam::308535385114:role/gha_executorch_upload-frameworks-ios
217217
aws-region: us-east-1
218218
- name: Download the artifact
219-
uses: actions/download-artifact@v3
219+
uses: actions/download-artifact@v4
220220
with:
221221
# NB: The name here needs to match the upload-artifact name from build-frameworks-ios job
222222
name: executorch-frameworks-ios
@@ -291,7 +291,7 @@ jobs:
291291
python-version: '3.11'
292292
submodules: 'true'
293293
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
294-
upload-artifact: ios-apps
294+
upload-artifact: ios-benchmark-app
295295
secrets-env: BUILD_CERTIFICATE_BASE64 EXECUTORCH_BENCHMARK_BUILD_PROVISION_PROFILE_BASE64 KEYCHAIN_PASSWORD
296296
timeout: 90
297297
script: |

.github/workflows/lint.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,19 @@ jobs:
2020
with:
2121
runner: linux.2xlarge
2222
docker-image: executorch-ubuntu-22.04-linter
23+
submodules: 'true'
2324
fetch-depth: 0
2425
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
2526
timeout: 90
2627
script: |
2728
# The generic Linux job chooses to use base env, not the one setup by the image
2829
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
2930
conda activate "${CONDA_ENV}"
31+
32+
# For mypy linting, we need to first install executorch first so that
33+
# it builds the python package information.
34+
BUILD_TOOL="cmake"
35+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh "${BUILD_TOOL}"
3036
3137
CACHE_DIRECTORY="/tmp/.lintbin"
3238
# Try to recover the cached binaries

.github/workflows/pull.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -354,13 +354,11 @@ jobs:
354354
EXECUTORCH_BUILD_ARM_BAREMETAL=ON \
355355
.ci/scripts/setup-linux.sh "${BUILD_TOOL}"
356356
357-
source .ci/scripts/utils.sh
358357
# Install Arm dependencies
359-
install_arm
360-
361-
# Run pytest with coverage
362-
pytest -c /dev/null -v -n auto --cov=./ --cov-report=xml backends/arm/test
358+
.ci/scripts/setup-arm-baremetal-tools.sh
363359
360+
# Run pytest without simulator
361+
backends/arm/test/test_arm_baremetal.sh test_pytest
364362
365363
test-llama-runner-qnn-linux:
366364
name: test-llama-runner-qnn-linux

.github/workflows/trunk.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,15 @@ jobs:
146146
source .ci/scripts/utils.sh
147147
install_executorch
148148
149-
install_arm
149+
.ci/scripts/setup-arm-baremetal-tools.sh
150150
151151
# Increase number of files user can monitor to bypass buck failures.
152152
# Hopefully this is high enough for this setup.
153153
sudo sysctl fs.inotify.max_user_watches=1048576 # 1024 * 1024
154154
155155
# Test ethos-u delegate examples with run.sh
156-
PYTHON_EXECUTABLE=python bash examples/arm/run.sh examples/arm/ethos-u-scratch/
156+
backends/arm/test/test_arm_baremetal.sh test_run_ethosu_fvp
157+
157158
158159
test-arm-reference-delegation:
159160
name: test-arm-reference-delegation
@@ -172,10 +173,10 @@ jobs:
172173
source .ci/scripts/utils.sh
173174
install_executorch
174175
175-
install_arm
176+
.ci/scripts/setup-arm-baremetal-tools.sh
176177
177-
# Run arm unit tests
178-
pytest -c /dev/null -v -n auto --cov=./ --cov-report=xml backends/arm/test
178+
# Run arm unit tests using the simulator
179+
backends/arm/test/test_arm_baremetal.sh test_pytest_ethosu_fvp
179180
180181
test-coreml-delegate:
181182
name: test-coreml-delegate

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.hypothesis
22
buck-out/
3+
.mypy_cache/
34
buck2-bin/
45
cmake-out*
56
.DS_Store

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
url = https://github.com/pybind/pybind11.git
6767
[submodule "backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3"]
6868
path = backends/cadence/fusion_g3/third-party/nnlib/nnlib-FusionG3
69-
url = https://github.com/foss-xtensa/nnlib-FusionG3/
69+
url = https://github.com/foss-xtensa/nnlib-FusionG3.git
7070
[submodule "third-party/ao"]
7171
path = third-party/ao
7272
url = https://github.com/pytorch/ao.git

.lintrunner.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,51 @@ command = [
285285
'--',
286286
'@{{PATHSFILE}}',
287287
]
288+
289+
[[linter]]
290+
code = 'MYPY'
291+
include_patterns = [
292+
# TODO(https://github.com/pytorch/executorch/issues/7441): Gradually start enabling all folders.
293+
# 'backends/**/*.py',
294+
'build/**/*.py',
295+
'codegen/**/*.py',
296+
# 'devtools/**/*.py',
297+
'docs/**/*.py',
298+
# 'examples/**/*.py',
299+
# 'exir/**/*.py',
300+
# 'extension/**/*.py',
301+
'kernels/**/*.py',
302+
'profiler/**/*.py',
303+
'runtime/**/*.py',
304+
'scripts/**/*.py',
305+
'test/**/*.py',
306+
'util/**/*.py',
307+
'*.py',
308+
]
309+
exclude_patterns = [
310+
'third-party/**',
311+
'**/third-party/**',
312+
'scripts/check_binary_dependencies.py',
313+
'profiler/test/test_profiler_e2e.py',
314+
]
315+
command = [
316+
'python',
317+
'-m',
318+
'lintrunner_adapters',
319+
'run',
320+
'mypy_linter',
321+
'--config=.mypy.ini',
322+
'--show-disable',
323+
'--',
324+
'--explicit-package-bases',
325+
'@{{PATHSFILE}}'
326+
]
327+
init_command = [
328+
'python',
329+
'-m',
330+
'lintrunner_adapters',
331+
'run',
332+
'pip_init',
333+
'--dry-run={{DRYRUN}}',
334+
'--requirement=requirements-lintrunner.txt',
335+
]

0 commit comments

Comments
 (0)