Skip to content

Commit eed28d1

Browse files
committed
Update on "Use extension module for pybind"
Deprecate the module class in pybindings, previously it was blocked by bundled program, and now it's resolved with https://github.com/pytorch/executorch/blob/2bb567f15a54fbc0ef621e5e85ff24e5da505b11/extension/module/bundled_module.h#L4 Differential Revision: [D70516347](https://our.internmc.facebook.com/intern/diff/D70516347/) [ghstack-poisoned]
2 parents 4cd2f88 + da3a8ee commit eed28d1

File tree

154 files changed

+5468
-1416
lines changed

Some content is hidden

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

154 files changed

+5468
-1416
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ on:
1616
options:
1717
- "xnnpack"
1818
- "vulkan+xnnpack"
19+
- "qnn"
1920
schedule:
2021
- cron: 0 10 * * *
2122

@@ -83,17 +84,29 @@ jobs:
8384
8485
echo -n "$SECRET_EXECUTORCH_MAVEN_SIGNING_GPG_KEY_CONTENTS" | base64 -d > /tmp/secring.gpg
8586
87+
GRADLE_ARGS=""
88+
8689
# Update the version name in build.gradle in case of maven publish
8790
VERSION="${{ inputs.version }}"
8891
if [ ! -z "$VERSION" ]; then
89-
sed -i "s/\(coordinates(\"org.pytorch\", \"executorch-android\", \"\)\([0-9]\+.[0-9]\+.[0-9]\+\)\(\")\)/\1$VERSION\3/" extension/android/executorch_android/build.gradle
92+
GRADLE_ARGS+=" -DexecuTorchVersion=${VERSION}"
9093
fi
9194
9295
FLAVOR="${{ inputs.flavor }}"
9396
if [[ "$FLAVOR" == "vulkan+xnnpack" || -z "$FLAVOR" ]]; then
9497
export EXECUTORCH_BUILD_VULKAN=ON
9598
fi
9699
100+
if [[ "$FLAVOR" == "qnn" ]]; then
101+
PYTHON_EXECUTABLE=python bash .ci/scripts/setup-qnn-deps.sh
102+
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh
103+
export EXECUTORCH_BUILD_QNN=ON
104+
source backends/qualcomm/scripts/qnn_config.sh
105+
export QNN_SDK_ROOT="/tmp/qnn/${QNN_VERSION}"
106+
export ANDROID_ABIS=arm64-v8a
107+
GRADLE_ARGS+=" -DqnnVersion=2.28.0"
108+
fi
109+
97110
# Build AAR Package
98111
mkdir aar-out
99112
export BUILD_AAR_DIR=aar-out
@@ -106,7 +119,7 @@ jobs:
106119
# Publish to maven staging
107120
UPLOAD_TO_MAVEN="${{ inputs.upload_to_maven }}"
108121
if [[ "$UPLOAD_TO_MAVEN" == "true" ]]; then
109-
(cd extension/android; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew :executorch_android:publishToMavenCentral)
122+
(cd extension/android; ANDROID_HOME="${ANDROID_SDK:-/opt/android/sdk}" ./gradlew ${GRADLE_ARGS} :executorch_android:publishToMavenCentral)
110123
fi
111124
112125
upload-release-aar:

.github/workflows/apple-perf.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ jobs:
416416
- set-parameters
417417
secrets: inherit
418418
with:
419-
runner: macos-latest-xlarge
419+
runner: macos-14-xlarge
420420
python-version: '3.11'
421421
submodules: 'recursive'
422422
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

.github/workflows/apple.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
5050
secrets: inherit
5151
with:
52-
runner: macos-latest-xlarge
52+
runner: macos-14-xlarge
5353
python-version: '3.11'
5454
submodules: 'recursive'
5555
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -136,7 +136,7 @@ jobs:
136136
needs: set-version
137137
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
138138
with:
139-
runner: macos-latest-xlarge
139+
runner: macos-14-xlarge
140140
python-version: '3.11'
141141
submodules: 'recursive'
142142
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -276,7 +276,7 @@ jobs:
276276
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
277277
secrets: inherit
278278
with:
279-
runner: macos-latest-xlarge
279+
runner: macos-14-xlarge
280280
python-version: '3.11'
281281
submodules: 'recursive'
282282
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}

.github/workflows/build-presets.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
with:
2323
job-name: build
2424
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
25-
runner: macos-latest-xlarge
25+
runner: macos-14-xlarge
2626
python-version: 3.12
2727
submodules: recursive
2828
timeout: 90
@@ -109,7 +109,7 @@ jobs:
109109
strategy:
110110
fail-fast: false
111111
matrix:
112-
preset: [windows]
112+
preset: [pybind, windows]
113113
with:
114114
job-name: build
115115
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -122,14 +122,17 @@ jobs:
122122
Set-PSDebug -Trace 1
123123
\$ErrorActionPreference = 'Stop'
124124
\$PSNativeCommandUseErrorActionPreference = \$true
125+
125126
conda create --yes --quiet -n et python=3.12
126127
conda activate et
127128
python install_requirements.py
129+
128130
cmake --preset ${{ matrix.preset }} -T ClangCL
129131
if (\$LASTEXITCODE -ne 0) {
130132
Write-Host "CMake configuration was unsuccessful. Exit code: \$LASTEXITCODE."
131133
exit \$LASTEXITCODE
132134
}
135+
133136
\$numCores = [System.Environment]::GetEnvironmentVariable('NUMBER_OF_PROCESSORS') - 1
134137
cmake --build cmake-out -j \$numCores
135138
if (\$LASTEXITCODE -ne 0) {

.github/workflows/build-wheels-macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
post-script: ${{ matrix.post-script }}
6464
package-name: ${{ matrix.package-name }}
6565
# Meta's macOS runners do not have Xcode, so use GitHub's runners.
66-
runner-type: macos-latest-xlarge
66+
runner-type: macos-14-xlarge
6767
setup-miniconda: true
6868
smoke-test-script: ${{ matrix.smoke-test-script }}
6969
trigger-event: ${{ github.event_name }}

.github/workflows/pull.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,8 @@ jobs:
855855
.ci/scripts/setup-linux.sh --build-tool "cmake"
856856
857857
# Install test requirements
858-
pip install -r backends/nxp/requirements-tests.txt
858+
pip install -r backends/nxp/requirements-tests-pypi.txt
859+
pip install -r backends/nxp/requirements-tests-eiq.txt
859860
860861
# Run pytest
861862
PYTHON_EXECUTABLE=python bash backends/nxp/run_unittests.sh

.github/workflows/trunk.yml

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ jobs:
435435
name: test-coreml-delegate
436436
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
437437
with:
438-
runner: macos-latest-xlarge
438+
runner: macos-14-xlarge
439439
python-version: '3.11'
440440
submodules: 'recursive'
441441
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
@@ -940,3 +940,42 @@ jobs:
940940
build-mode: Release
941941
build-tool: cmake
942942
docker-image: ci-image:executorch-ubuntu-22.04-clang12
943+
944+
test-mcu-models:
945+
name: test-mcu-models
946+
uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main
947+
strategy:
948+
matrix:
949+
include:
950+
- build-tool: cmake
951+
fail-fast: false
952+
permissions:
953+
id-token: write
954+
contents: read
955+
with:
956+
runner: linux.2xlarge
957+
docker-image: ci-image:executorch-ubuntu-22.04-arm-sdk
958+
submodules: 'recursive'
959+
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
960+
timeout: 90
961+
script: |
962+
BUILD_TOOL=${{ matrix.build-tool }}
963+
964+
# The generic Linux job chooses to use base env, not the one setup by the image
965+
CONDA_ENV=$(conda env list --json | jq -r ".envs | .[-1]")
966+
conda activate "${CONDA_ENV}"
967+
968+
# Try to mirror these as closely as possible
969+
source .ci/scripts/utils.sh
970+
install_executorch "--use-pt-pinned-commit"
971+
972+
.ci/scripts/setup-arm-baremetal-tools.sh
973+
source examples/arm/ethos-u-scratch/setup_path.sh
974+
975+
# Run selective Build
976+
chmod +x examples/selective_build/test_selective_build.sh
977+
examples/selective_build/test_selective_build.sh "${BUILD_TOOL}"
978+
979+
# Run MCU models
980+
chmod +x examples/arm/run_mcu_models_fvp.sh
981+
examples/arm/run_mcu_models_fvp.sh --target=cortex-m55

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,6 @@ endif()
582582

583583
if(EXECUTORCH_BUILD_EXTENSION_APPLE)
584584
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/apple)
585-
list(APPEND _executorch_extensions apple_extension)
586585
endif()
587586

588587
if(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER)
@@ -649,7 +648,6 @@ endif()
649648

650649
if(EXECUTORCH_BUILD_EXTENSION_LLM_APPLE)
651650
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/llm/apple)
652-
list(APPEND _executorch_extensions extension_llm_apple)
653651
endif()
654652

655653
if(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL)
@@ -968,6 +966,10 @@ else()
968966
endif()
969967
target_link_libraries(executorch_kernels INTERFACE ${_executorch_kernels})
970968

969+
install(TARGETS executorch_backends executorch_extensions executorch_kernels
970+
EXPORT ExecuTorchTargets
971+
)
972+
971973
if(EXECUTORCH_BUILD_EXECUTOR_RUNNER)
972974
# Baseline libraries that executor_runner will link against.
973975
set(_executor_runner_libs executorch extension_evalue_util

backends/apple/coreml/compiler/torch_ops.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from coremltools.converters.mil.frontend.torch.ops import (
1616
_get_inputs,
1717
_get_kwinputs,
18-
noop,
1918
NUM_TO_NUMPY_DTYPE,
2019
NUM_TO_TORCH_DTYPE,
2120
split,
@@ -92,28 +91,6 @@ def _to_dim_order_copy(context, node):
9291
to(context, node)
9392

9493

95-
@register_torch_op(
96-
torch_alias=[
97-
"dim_order_ops::_clone_dim_order",
98-
"dim_order_ops._clone_dim_order",
99-
],
100-
override=False,
101-
)
102-
def _clone_dim_order(context, node):
103-
dim_order = _get_kwinputs(context, node, "dim_order", default=[None])[0]
104-
node.kwinputs.pop("dim_order")
105-
106-
# In CoreML, dim_order.val will be a ndarray, so we convert it to a list to check memory format.
107-
dim_order = [int(d) for d in dim_order.val]
108-
memory_format = get_memory_format(dim_order)
109-
assert (
110-
memory_format == _torch.contiguous_format
111-
), "Only contiguous memory format is supported in CoreML"
112-
113-
# Since CoreML only supports contiguous format, no dim_order preservation is needed. Treat this as a no-op clone.
114-
noop(context, node)
115-
116-
11794
# https://github.com/apple/coremltools/pull/2558
11895
@register_torch_op(
11996
torch_alias=["torchao::dequantize_affine", "torchao.dequantize_affine"],

backends/apple/coreml/test/test_torch_ops.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -213,28 +213,6 @@ def test_dequantize_codebook_embedding(self):
213213
et_prog = delegated_program.to_executorch()
214214
self._compare_outputs(et_prog, model, example_inputs)
215215

216-
def test__clone_dim_order_contiguous(self):
217-
class Model(torch.nn.Module):
218-
def forward(self, x):
219-
return torch.ops.dim_order_ops._clone_dim_order(
220-
x, dim_order=[0, 1, 2, 3]
221-
)
222-
223-
model, example_inputs = Model(), (torch.randn(1, 3, 8, 8),)
224-
ep = torch.export.export(model, example_inputs)
225-
delegated_program = executorch.exir.to_edge_transform_and_lower(
226-
ep,
227-
partitioner=[self._coreml_partitioner()],
228-
)
229-
for node in delegated_program.exported_program().graph.nodes:
230-
if node.op == "call_function":
231-
assert node.target.__name__ in [
232-
"executorch_call_delegate",
233-
"getitem",
234-
], f"Got unexpected node target after delegation: {node.target.__name__}"
235-
et_prog = delegated_program.to_executorch()
236-
self._compare_outputs(et_prog, model, example_inputs)
237-
238216

239217
if __name__ == "__main__":
240218
test_runner = TestTorchOps()
@@ -245,4 +223,3 @@ def forward(self, x):
245223
test_runner.test_dequantize_affine_c8w_embedding_b4w_linear()
246224
test_runner.test_dequantize_codebook_linear()
247225
test_runner.test_dequantize_codebook_embedding()
248-
test_runner.test__clone_dim_order_contiguous()

0 commit comments

Comments
 (0)