Skip to content

Commit 2b87df7

Browse files
authored
Merge branch 'main' into jz/phi-4-mini-readme
2 parents 0484d16 + 94ec549 commit 2b87df7

Some content is hidden

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

46 files changed

+361
-200
lines changed

.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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
# Build LLM Demo for Android
3636
export BUILD_AAR_DIR=aar-out
3737
mkdir -p $BUILD_AAR_DIR
38-
bash build/build_android_library.sh ${ARTIFACTS_DIR_NAME}
38+
bash scripts/build_android_library.sh ${ARTIFACTS_DIR_NAME}
3939
bash .ci/scripts/build_android_instrumentation.sh ${ARTIFACTS_DIR_NAME}
4040
4141
mkdir -p examples/demo-apps/android/LlamaDemo/app/libs
@@ -120,7 +120,7 @@ jobs:
120120
with:
121121
api-level: ${{ env.API_LEVEL }}
122122
arch: x86_64
123-
script: ./build/run_android_emulator.sh
123+
script: ./scripts/run_android_emulator.sh
124124
# NB: This is to boot the emulator faster following the instructions on
125125
# https://github.com/ReactiveCircus/android-emulator-runner. The max number
126126
# 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/pull.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.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/_passes/insert_table_ops.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class InsertTableOpsPass(ExportPass):
4141
"""
4242

4343
table_ops: Dict[EdgeOpOverload, Callable[[torch.Tensor], torch.Tensor]] = {
44+
exir_ops.edge.aten.ceil.default: torch.ceil,
4445
exir_ops.edge.aten.exp.default: torch.exp,
4546
exir_ops.edge.aten.floor.default: torch.floor,
4647
exir_ops.edge.aten.log.default: torch.log,

backends/arm/operator_support/tosa_supported_operators.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def is_node_supported(
147147
exir_ops.edge.aten.bitwise_xor.Tensor,
148148
exir_ops.edge.aten.expand_copy.default,
149149
exir_ops.edge.aten.cat.default,
150+
exir_ops.edge.aten.ceil.default,
150151
exir_ops.edge.aten.clamp.default,
151152
exir_ops.edge.aten.bmm.default,
152153
exir_ops.edge.aten.permute_copy.default,
@@ -208,26 +209,41 @@ def is_node_supported(
208209
class EthosU55NotSupported(OperatorSupportBase):
209210
"""
210211
Certain operators are not supported on U55. These are listed in `unsupported_ops`.
212+
The comment mentions the unsupported TOSA operator that the aten operator maps to where it is not obvious.
213+
For unimplemented operators, this is the anticipated mapping, and it might be incorrect.
211214
"""
212215

213216
unsupported_ops = [
214-
exir_ops.edge.aten.any.default,
215-
exir_ops.edge.aten.any.dim,
216-
exir_ops.edge.aten.any.dims,
217+
exir_ops.edge.aten.any.default, # REDUCE_ANY
218+
exir_ops.edge.aten.any.dim, # REDUCE_ANY
219+
exir_ops.edge.aten.any.dims, # REDUCE_ANY
217220
exir_ops.edge.aten.bitwise_and.Tensor,
218221
exir_ops.edge.aten.bitwise_or.Tensor,
219222
exir_ops.edge.aten.bitwise_xor.Tensor,
223+
exir_ops.edge.aten.bitwise_not,
220224
exir_ops.edge.aten.logical_and.default,
221225
exir_ops.edge.aten.logical_or.default,
222226
exir_ops.edge.aten.logical_xor.default,
223227
exir_ops.edge.aten.logical_not.default,
224-
exir_ops.edge.aten.amax.default,
225-
exir_ops.edge.aten.amin.default,
228+
exir_ops.edge.aten.amax.default, # REDUCE_MAX
229+
exir_ops.edge.aten.amin.default, # REDUCE_MIN
226230
exir_ops.edge.aten.eq.Tensor,
227231
exir_ops.edge.aten.ge.Tensor,
228232
exir_ops.edge.aten.gt.Tensor,
229233
exir_ops.edge.aten.le.Tensor,
230234
exir_ops.edge.aten.lt.Tensor,
235+
exir_ops.edge.aten.flip.default, # REVERSE
236+
exir_ops.edge.aten.grid_sampler_2d, # GATHER
237+
exir_ops.edge.aten.scatter.src,
238+
exir_ops.edge.aten.scatter.value,
239+
exir_ops.edge.aten.select_scatter.default,
240+
exir_ops.edge.aten.scatter_reduce.two,
241+
exir_ops.edge.aten.scatter_add.default,
242+
exir_ops.edge.aten.upsample_nearest2d.vec, # RESIZE
243+
exir_ops.edge.aten.upsample_bilinear2d.vec, # RESIZE
244+
exir_ops.edge.aten.reflection_pad1d.default, # REVERSE
245+
exir_ops.edge.aten.reflection_pad2d.default, # REVERSE
246+
exir_ops.edge.aten.reflection_pad3d.default, # REVERSE
231247
]
232248

233249
def __init__(self, reporter: WhyNoPartitionReporter):

backends/arm/operators/ops_unary.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,6 @@ def define_node(
5353
register_node_visitor(UnaryOperator)
5454

5555

56+
unary_operator_factory("aten.ceil.default", TosaOp.Op().CEIL)
5657
unary_operator_factory("aten.floor.default", TosaOp.Op().FLOOR)
5758
unary_operator_factory("aten.logical_not.default", TosaOp.Op().LOGICAL_NOT)

backends/arm/quantizer/quantization_annotator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ def _match_pattern(
126126

127127
_one_to_one = [
128128
torch.ops.aten.abs.default,
129+
torch.ops.aten.ceil.default,
129130
torch.ops.aten.exp.default,
130131
torch.ops.aten.floor.default,
131132
torch.ops.aten.log.default,

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)

backends/arm/test/ops/test_floor.py

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)