Skip to content

Commit a405ce1

Browse files
committed
Update
[ghstack-poisoned]
2 parents c02d474 + 90f0843 commit a405ce1

File tree

122 files changed

+1445
-1078
lines changed

Some content is hidden

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

122 files changed

+1445
-1078
lines changed

.ci/scripts/build_android_instrumentation.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ fi
1313
which "${PYTHON_EXECUTABLE}"
1414

1515
build_android_test() {
16-
pushd extension/android_test
17-
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew testDebugUnitTest
18-
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew build assembleAndroidTest
16+
mkdir -p extension/android/executorch_android/src/androidTest/resources
17+
cp extension/module/test/resources/add.pte extension/android/executorch_android/src/androidTest/resources
18+
pushd extension/android
19+
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:testDebugUnitTest
20+
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:assembleAndroidTest
1921
popd
2022
}
2123

@@ -24,8 +26,7 @@ collect_artifacts_to_be_uploaded() {
2426
# Collect Java library test
2527
JAVA_LIBRARY_TEST_DIR="${ARTIFACTS_DIR_NAME}/library_test_dir"
2628
mkdir -p "${JAVA_LIBRARY_TEST_DIR}"
27-
cp extension/android_test/build/outputs/apk/debug/*.apk "${JAVA_LIBRARY_TEST_DIR}"
28-
cp extension/android_test/build/outputs/apk/androidTest/debug/*.apk "${JAVA_LIBRARY_TEST_DIR}"
29+
cp extension/android/executorch_android/build/outputs/apk/androidTest/debug/*.apk "${JAVA_LIBRARY_TEST_DIR}"
2930
}
3031

3132
main() {

.ci/scripts/unittest-macos.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ export TMP_DIR=$(mktemp -d)
1919
export PATH="${TMP_DIR}:$PATH"
2020
trap 'rm -rfv ${TMP_DIR}' EXIT
2121

22-
if [[ "$BUILD_TOOL" == "cmake" ]]; then
23-
# Setup MacOS dependencies as there is no Docker support on MacOS atm
24-
PYTHON_EXECUTABLE=python \
25-
EXECUTORCH_BUILD_PYBIND=ON \
26-
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
27-
${CONDA_RUN} --no-capture-output \
28-
.ci/scripts/setup-macos.sh "$@"
22+
# Setup MacOS dependencies as there is no Docker support on MacOS atm
23+
PYTHON_EXECUTABLE=python \
24+
EXECUTORCH_BUILD_PYBIND=ON \
25+
CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON" \
26+
${CONDA_RUN} --no-capture-output \
27+
.ci/scripts/setup-macos.sh "$@"
2928

29+
if [[ "$BUILD_TOOL" == "cmake" ]]; then
3030
# Install llama3_2_vision dependencies.
3131
PYTHON_EXECUTABLE=python \
3232
${CONDA_RUN} --no-capture-output \

.github/workflows/_android.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@ jobs:
2828
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool buck2
2929
export ARTIFACTS_DIR_NAME=artifacts-to-be-uploaded
3030
31+
mkdir -p ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
32+
bash examples/models/llama/install_requirements.sh
33+
bash ".ci/scripts/test_llama.sh" -model stories110M -build_tool cmake -dtype fp16 -mode portable -upload ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
34+
3135
# Build LLM Demo for Android
3236
export BUILD_AAR_DIR=aar-out
33-
bash build/build_android_library.sh ${ARTIFACTS_DIR_NAME}
37+
mkdir -p $BUILD_AAR_DIR
38+
bash scripts/build_android_library.sh ${ARTIFACTS_DIR_NAME}
3439
bash .ci/scripts/build_android_instrumentation.sh ${ARTIFACTS_DIR_NAME}
3540
36-
mkdir -p ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
37-
bash ".ci/scripts/test_llama.sh" -model stories110M -build_tool cmake -dtype fp16 -mode portable -upload ${ARTIFACTS_DIR_NAME}/fp32-xnnpack-custom
38-
3941
mkdir -p examples/demo-apps/android/LlamaDemo/app/libs
4042
cp aar-out/executorch.aar examples/demo-apps/android/LlamaDemo/app/libs
4143
pushd examples/demo-apps/android/LlamaDemo
@@ -94,7 +96,6 @@ jobs:
9496
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug.apk
9597
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/llm_demo/app-debug-androidTest.apk
9698
curl -O https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/fp32-xnnpack-custom/model.zip
97-
curl -o android-test-debug.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/executorch-debug.apk
9899
curl -o android-test-debug-androidTest.apk https://gha-artifacts.s3.amazonaws.com/${{ github.repository }}/${{ github.run_id }}/artifacts/library_test_dir/executorch-debug-androidTest.apk
99100
unzip model.zip
100101
mv *.pte model.pte
@@ -119,7 +120,7 @@ jobs:
119120
with:
120121
api-level: ${{ env.API_LEVEL }}
121122
arch: x86_64
122-
script: ./build/run_android_emulator.sh
123+
script: ./scripts/run_android_emulator.sh
123124
# NB: This is to boot the emulator faster following the instructions on
124125
# https://github.com/ReactiveCircus/android-emulator-runner. The max number
125126
# of cores we can set is 6, any higher number will be reduced to 6.

.github/workflows/android-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ jobs:
363363
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
364364
365365
mkdir -p aar-out
366-
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029 bash build/build_android_library.sh
366+
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029 bash scripts/build_android_library.sh
367367
mkdir -p extension/benchmark/android/benchmark/app/libs
368368
cp aar-out/executorch.aar extension/benchmark/android/benchmark/app/libs
369369
pushd extension/benchmark/android/benchmark

.github/workflows/android-release-artifacts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
# Build AAR Package
5656
mkdir aar-out
5757
export BUILD_AAR_DIR=aar-out
58-
bash build/build_android_library.sh
58+
bash scripts/build_android_library.sh
5959
mkdir -p "${ARTIFACTS_DIR_NAME}"
6060
cp aar-out/executorch.aar "${ARTIFACTS_DIR_NAME}/executorch.aar"
6161

.github/workflows/apple-perf.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ jobs:
387387
388388
echo "::group::Build ExecuTorch iOS frameworks"
389389
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
390-
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
390+
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
391391
echo "::endgroup::"
392392
393393
# NB: Although exported models can be copied to this directory and bundled together with the
@@ -396,7 +396,7 @@ jobs:
396396
# create the directory here to pass the build
397397
mkdir -p extension/benchmark/apple/Benchmark/Models
398398
${CONDA_RUN} --no-capture-output \
399-
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
399+
scripts/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
400400
401401
upload-benchmark-app:
402402
needs: build-benchmark-app

.github/workflows/apple.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ on:
1111
- .github/workflows/apple.yml
1212
- install_executorch.sh
1313
- backends/apple/**
14-
- build/build_apple_frameworks.sh
15-
- build/build_apple_llm_demo.sh
16-
- build/create_frameworks.sh
14+
- scripts/build_apple_frameworks.sh
15+
- scripts/build_apple_llm_demo.sh
16+
- scripts/create_frameworks.sh
1717
- .ci/scripts/test_ios_ci.sh
1818
- examples/demo-apps/apple_ios/**
1919
- extension/apple/**
@@ -172,7 +172,7 @@ jobs:
172172
173173
# Build iOS Frameworks
174174
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
175-
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
175+
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
176176
177177
# Bundle iOS Frameworks
178178
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
@@ -313,11 +313,11 @@ jobs:
313313
314314
echo "::group::Build ExecuTorch iOS frameworks"
315315
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
316-
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
316+
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
317317
echo "::endgroup::"
318318
319319
echo "::group::Build ExecuTorch benchmark app"
320320
mkdir -p extension/benchmark/apple/Benchmark/Models
321321
${CONDA_RUN} --no-capture-output \
322-
build/build_apple_llm_demo.sh "${ARTIFACTS_DIR_NAME}"
322+
scripts/build_apple_llm_demo.sh "${ARTIFACTS_DIR_NAME}"
323323
echo "::endgroup::"

.github/workflows/doc-build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
with:
2727
job-name: Build doc
2828
runner: linux.2xlarge
29-
docker-image: executorch-ubuntu-22.04-clang12
29+
docker-image: executorch-ubuntu-22.04-clang12-android
3030
submodules: 'true'
3131
repository: pytorch/executorch
3232
upload-artifact: docs
@@ -70,8 +70,8 @@ jobs:
7070
7171
# Build javadoc:
7272
cd extension/android
73-
./gradlew javadoc
74-
cp -rf build/docs/javadoc "${RUNNER_DOCS_DIR}"
73+
ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:javaDocReleaseGeneration
74+
cp -rf executorch_android/build/intermediates/java_doc_dir/release/javaDocReleaseGeneration "${RUNNER_DOCS_DIR}/javadoc"
7575
cd ../..
7676
7777
# If it's main branch, add noindex tag to all .html files to exclude from Google Search indexing.

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ jobs:
7676
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
7777
timeout: 90
7878
script: |
79-
FILES_NEEDS_FORMAT=$(/opt/google-java-format -n extension/android/src/main/java/org/pytorch/executorch/*.java \
80-
examples/demo-apps/android/ExecuTorchDemo/app/src/main/java/com/example/executorchdemo/*.java \
79+
FILES_NEEDS_FORMAT=$(/opt/google-java-format -n \
80+
extension/android/executorch_android/src/main/java/org/pytorch/executorch/*.java \
8181
examples/demo-apps/android/LlamaDemo/app/src/main/java/com/example/executorchllamademo/*.java \
8282
extension/benchmark/android/benchmark/app/src/main/java/org/pytorch/minibench/*.java)
8383
if [ -n "$FILES_NEEDS_FORMAT" ]; then

.github/workflows/pull.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- runner: linux.arm64.2xlarge
6161
docker-image: executorch-ubuntu-22.04-clang12
6262
# TODO: Need to figure out why buck2 doesnt work on Graviton instances.
63-
- runner: linux.arm64.2xlarge
63+
- runner: linux.arm64.2xlarge
6464
build-tool: buck2
6565
fail-fast: false
6666
with:
@@ -290,6 +290,36 @@ jobs:
290290
# run e2e (export, tokenizer and runner)
291291
PYTHON_EXECUTABLE=python bash .ci/scripts/test_llava.sh
292292
293+
test-moshi-linux:
294+
name: test-moshi-linux
295+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
296+
permissions:
297+
id-token: write
298+
contents: read
299+
strategy:
300+
fail-fast: false
301+
with:
302+
runner: linux.2xlarge
303+
docker-image: executorch-ubuntu-22.04-clang12
304+
submodules: 'true'
305+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
306+
timeout: 90
307+
script: |
308+
# The generic Linux job chooses to use base env, not the one setup by the image
309+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
310+
conda activate "${CONDA_ENV}"
311+
312+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-linux.sh --build-tool "cmake"
313+
314+
# install Mimi requirements
315+
bash examples/models/moshi/mimi/install_requirements.sh
316+
317+
# reinstall executorch
318+
bash ./install_executorch.sh
319+
320+
# run python unittest
321+
python -m unittest examples.models.moshi.mimi.test_mimi
322+
293323
test-quantized-aot-lib-linux:
294324
name: test-quantized-aot-lib-linux
295325
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
@@ -420,7 +450,6 @@ jobs:
420450
permissions:
421451
id-token: write
422452
contents: read
423-
needs: test-llama-runner-linux
424453

425454
unittest:
426455
uses: ./.github/workflows/_unittest.yml

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ __pycache__/
1111
arm_test/
1212
buck-out/
1313
buck2-bin/
14+
build/
1415
cmake-android-out/
1516
cmake-ios-out/
1617
cmake-out*

README.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ We welcome contributions. To get started review the [guidelines](CONTRIBUTING.md
6767
```
6868
executorch
6969
├── backends # Backend delegate implementations.
70-
├── build # Utilities for managing the build system.
7170
├── codegen # Tooling to autogenerate bindings between kernels and the runtime.
7271
├── configurations
7372
├── docs # Static docs tooling.
@@ -81,8 +80,7 @@ executorch
8180
| ├── operator # Operator node manipulation utilities.
8281
| ├── passes # Built-in compiler passes.
8382
| ├── program # Export artifacts.
84-
| ├── serde # Graph module
85-
serialization/deserialization.
83+
| ├── serde # Graph module serialization/deserialization.
8684
| ├── verification # IR verification.
8785
├── extension # Extensions built on top of the runtime.
8886
| ├── android # ExecuTorch wrappers for Android apps.
@@ -97,8 +95,7 @@ serialization/deserialization.
9795
| ├── parallel # C++ threadpool integration.
9896
| ├── pybindings # Python API for executorch runtime.
9997
| ├── pytree # C++ and Python flattening and unflattening lib for pytrees.
100-
| ├── runner_util # Helpers for writing C++ PTE-execution
101-
tools.
98+
| ├── runner_util # Helpers for writing C++ PTE-execution tools.
10299
| ├── testing_util # Helpers for writing C++ tests.
103100
| ├── training # Experimental libraries for on-device training
104101
├── kernels # 1st party kernel implementations.
@@ -114,9 +111,9 @@ tools.
114111
| ├── executor # Model loading, initialization, and execution.
115112
| ├── kernel # Kernel registration and management.
116113
| ├── platform # Layer between architecture specific code and portable C++.
117-
├── schema # ExecuTorch PTE file format flatbuffer
118-
schemas.
119-
├── scripts # Utility scripts for size management, dependency management, etc.
114+
├── schema # ExecuTorch PTE file format flatbuffer schemas.
115+
├── scripts # Utility scripts for building libs, size management, dependency management, etc.
116+
├── tools # Development tool management.
120117
├── devtools # Model profiling, debugging, and introspection.
121118
├── shim # Compatibility layer between OSS and Internal builds
122119
├── test # Broad scoped end-to-end tests.

backends/apple/coreml/setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ xcode-select --install
5050

5151
```bash
5252
cd executorch
53-
./build/build_apple_frameworks.sh --coreml
53+
./scripts/build_apple_frameworks.sh --coreml
5454
```
5555
5. Open the project in Xcode, and drag `executorch.xcframework` and `coreml_backend.xcframework` frameworks generated from Step 2 to Frameworks.
5656

backends/apple/mps/setup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ python3 -m sdk.inspector.inspector_cli --etdump_path etdump.etdp --etrecord_path
130130
***Step 1***. Create the ExecuTorch core and MPS delegate frameworks to link on iOS
131131
```bash
132132
cd executorch
133-
./build/build_apple_frameworks.sh --mps
133+
./scripts/build_apple_frameworks.sh --mps
134134
```
135135

136136
`mps_delegate.xcframework` will be in `cmake-out` folder, along with `executorch.xcframework` and `portable_delegate.xcframework`:

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,26 +208,41 @@ def is_node_supported(
208208
class EthosU55NotSupported(OperatorSupportBase):
209209
"""
210210
Certain operators are not supported on U55. These are listed in `unsupported_ops`.
211+
The comment mentions the unsupported TOSA operator that the aten operator maps to where it is not obvious.
212+
For unimplemented operators, this is the anticipated mapping, and it might be incorrect.
211213
"""
212214

213215
unsupported_ops = [
214-
exir_ops.edge.aten.any.default,
215-
exir_ops.edge.aten.any.dim,
216-
exir_ops.edge.aten.any.dims,
216+
exir_ops.edge.aten.any.default, # REDUCE_ANY
217+
exir_ops.edge.aten.any.dim, # REDUCE_ANY
218+
exir_ops.edge.aten.any.dims, # REDUCE_ANY
217219
exir_ops.edge.aten.bitwise_and.Tensor,
218220
exir_ops.edge.aten.bitwise_or.Tensor,
219221
exir_ops.edge.aten.bitwise_xor.Tensor,
222+
exir_ops.edge.aten.bitwise_not,
220223
exir_ops.edge.aten.logical_and.default,
221224
exir_ops.edge.aten.logical_or.default,
222225
exir_ops.edge.aten.logical_xor.default,
223226
exir_ops.edge.aten.logical_not.default,
224-
exir_ops.edge.aten.amax.default,
225-
exir_ops.edge.aten.amin.default,
227+
exir_ops.edge.aten.amax.default, # REDUCE_MAX
228+
exir_ops.edge.aten.amin.default, # REDUCE_MIN
226229
exir_ops.edge.aten.eq.Tensor,
227230
exir_ops.edge.aten.ge.Tensor,
228231
exir_ops.edge.aten.gt.Tensor,
229232
exir_ops.edge.aten.le.Tensor,
230233
exir_ops.edge.aten.lt.Tensor,
234+
exir_ops.edge.aten.flip.default, # REVERSE
235+
exir_ops.edge.aten.grid_sampler_2d, # GATHER
236+
exir_ops.edge.aten.scatter.src,
237+
exir_ops.edge.aten.scatter.value,
238+
exir_ops.edge.aten.select_scatter.default,
239+
exir_ops.edge.aten.scatter_reduce.two,
240+
exir_ops.edge.aten.scatter_add.default,
241+
exir_ops.edge.aten.upsample_nearest2d.vec, # RESIZE
242+
exir_ops.edge.aten.upsample_bilinear2d.vec, # RESIZE
243+
exir_ops.edge.aten.reflection_pad1d.default, # REVERSE
244+
exir_ops.edge.aten.reflection_pad2d.default, # REVERSE
245+
exir_ops.edge.aten.reflection_pad3d.default, # REVERSE
231246
]
232247

233248
def __init__(self, reporter: WhyNoPartitionReporter):

backends/arm/test/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def parametrize(
231231
arg_name: str,
232232
test_data: dict[str, Any],
233233
xfails: dict[str, xfail_type] | None = None,
234+
strict: bool = True,
234235
):
235236
"""
236237
Custom version of pytest.mark.parametrize with some syntatic sugar and added xfail functionality
@@ -261,7 +262,9 @@ def decorator_func(func):
261262
pytest_param = pytest.param(
262263
test_parameters,
263264
id=id,
264-
marks=pytest.mark.xfail(reason=reason, raises=raises, strict=True),
265+
marks=pytest.mark.xfail(
266+
reason=reason, raises=raises, strict=strict
267+
),
265268
)
266269
else:
267270
pytest_param = pytest.param(test_parameters, id=id)

0 commit comments

Comments
 (0)