diff --git a/.ci/docker/ci_commit_pins/pytorch.txt b/.ci/docker/ci_commit_pins/pytorch.txt index a846b87c198..fc941a1f7dc 100644 --- a/.ci/docker/ci_commit_pins/pytorch.txt +++ b/.ci/docker/ci_commit_pins/pytorch.txt @@ -1 +1 @@ -7ae0ce6360b6e4f944906502d20da24c04debee5 +release/2.7 diff --git a/.github/workflows/_android.yml b/.github/workflows/_android.yml index e29833015d3..406b2067089 100644 --- a/.github/workflows/_android.yml +++ b/.github/workflows/_android.yml @@ -7,7 +7,7 @@ on: jobs: build-llm-demo: name: build-llm-demo - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -66,7 +66,7 @@ jobs: API_LEVEL: 34 steps: - name: Setup SSH (Click me for login details) - uses: pytorch/test-infra/.github/actions/setup-ssh@main + uses: pytorch/test-infra/.github/actions/setup-ssh@release/2.7 with: github-secret: ${{ secrets.GITHUB_TOKEN }} instructions: | @@ -77,7 +77,7 @@ jobs: submodules: false - name: Setup conda - uses: pytorch/test-infra/.github/actions/setup-miniconda@main + uses: pytorch/test-infra/.github/actions/setup-miniconda@release/2.7 with: python-version: '3.10' diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index eb6c9c24257..734090bc76c 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -26,7 +26,7 @@ on: jobs: linux: - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -41,7 +41,7 @@ jobs: .ci/scripts/unittest-linux.sh --build-tool "${{ inputs.build-tool }}" --build-mode "${{ inputs.build-mode }}" --editable "${{ inputs.editable }}" macos: - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 with: runner: macos-m1-stable python-version: '3.11' diff --git a/.github/workflows/android-perf.yml b/.github/workflows/android-perf.yml index 09a6453094f..3c50317dabf 100644 --- a/.github/workflows/android-perf.yml +++ b/.github/workflows/android-perf.yml @@ -155,7 +155,7 @@ jobs: export-models: name: export-models - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -337,7 +337,7 @@ jobs: build-benchmark-app: name: build-benchmark-app - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -381,7 +381,7 @@ jobs: permissions: id-token: write contents: read - uses: pytorch/test-infra/.github/workflows/mobile_job.yml@main + uses: pytorch/test-infra/.github/workflows/mobile_job.yml@release/2.7 needs: - set-parameters - prepare-test-specs @@ -427,7 +427,7 @@ jobs: aws-region: us-east-1 - name: Setup conda - uses: pytorch/test-infra/.github/actions/setup-miniconda@main + uses: pytorch/test-infra/.github/actions/setup-miniconda@release/2.7 with: python-version: '3.10' @@ -485,7 +485,7 @@ jobs: done - name: Upload the benchmark results (v3) - uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main + uses: pytorch/test-infra/.github/actions/upload-benchmark-results@release/2.7 with: benchmark-results-dir: benchmark-results/v3 dry-run: false diff --git a/.github/workflows/android-release-artifacts.yml b/.github/workflows/android-release-artifacts.yml index 24aa6c1ad27..95664c116f4 100644 --- a/.github/workflows/android-release-artifacts.yml +++ b/.github/workflows/android-release-artifacts.yml @@ -31,7 +31,7 @@ jobs: build-aar: name: build-aar needs: check-if-aar-exists - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read diff --git a/.github/workflows/apple-perf.yml b/.github/workflows/apple-perf.yml index 6e75aaf4f85..fead3b52f0e 100644 --- a/.github/workflows/apple-perf.yml +++ b/.github/workflows/apple-perf.yml @@ -157,7 +157,7 @@ jobs: export-models: name: export-models - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 needs: set-parameters secrets: inherit strategy: @@ -346,7 +346,7 @@ jobs: build-benchmark-app: name: build-benchmark-app - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 needs: - set-parameters secrets: inherit @@ -436,7 +436,7 @@ jobs: permissions: id-token: write contents: read - uses: pytorch/test-infra/.github/workflows/mobile_job.yml@main + uses: pytorch/test-infra/.github/workflows/mobile_job.yml@release/2.7 strategy: matrix: ${{ fromJson(needs.set-parameters.outputs.benchmark_configs) }} fail-fast: false @@ -479,7 +479,7 @@ jobs: aws-region: us-east-1 - name: Setup conda - uses: pytorch/test-infra/.github/actions/setup-miniconda@main + uses: pytorch/test-infra/.github/actions/setup-miniconda@release/2.7 with: python-version: '3.10' @@ -535,7 +535,7 @@ jobs: done - name: Upload the benchmark results (v3) - uses: pytorch/test-infra/.github/actions/upload-benchmark-results@main + uses: pytorch/test-infra/.github/actions/upload-benchmark-results@release/2.7 with: benchmark-results-dir: benchmark-results/v3 dry-run: false diff --git a/.github/workflows/apple.yml b/.github/workflows/apple.yml index 214d4f13fc8..43d35c7c4a9 100644 --- a/.github/workflows/apple.yml +++ b/.github/workflows/apple.yml @@ -37,14 +37,14 @@ jobs: id: set_version shell: bash run: | - VERSION="0.5.0.$(TZ='PST8PDT' date +%Y%m%d)" + VERSION="0.6.0" echo "version=$VERSION" >> "$GITHUB_OUTPUT" build-demo-ios: name: build-demo-ios # NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway if: ${{ !github.event.pull_request.head.repo.fork }} - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 secrets: inherit with: runner: macos-latest-xlarge @@ -114,7 +114,7 @@ jobs: permissions: id-token: write contents: read - uses: pytorch/test-infra/.github/workflows/mobile_job.yml@main + uses: pytorch/test-infra/.github/workflows/mobile_job.yml@release/2.7 with: device-type: ios # For iOS testing, the runner just needs to call AWS Device Farm, so there is no need to run this on macOS @@ -132,7 +132,7 @@ jobs: build-frameworks-ios: name: build-frameworks-ios needs: set-version - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 with: runner: macos-latest-xlarge python-version: '3.11' @@ -212,7 +212,7 @@ jobs: name: executorch-frameworks-ios path: ${{ runner.temp }}/frameworks-ios/ - name: Only push to S3 when running the workflow manually from main branch - if: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/main' }} + if: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.ref == 'refs/heads/release/0.6' }} shell: bash run: | echo "UPLOAD_ON_MAIN=1" >> "${GITHUB_ENV}" @@ -274,7 +274,7 @@ jobs: name: build-benchmark-app # NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway if: ${{ !github.event.pull_request.head.repo.fork }} - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 secrets: inherit with: runner: macos-latest-xlarge diff --git a/.github/workflows/build-wheels-linux.yml b/.github/workflows/build-wheels-linux.yml index 4c08968f3d6..216447e0638 100644 --- a/.github/workflows/build-wheels-linux.yml +++ b/.github/workflows/build-wheels-linux.yml @@ -22,7 +22,7 @@ on: jobs: generate-matrix: - uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main + uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.7 with: package-type: wheel os: linux @@ -47,7 +47,7 @@ jobs: smoke-test-script: .ci/scripts/wheel/test_linux.py package-name: executorch name: ${{ matrix.repository }} - uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@main + uses: pytorch/test-infra/.github/workflows/build_wheels_linux.yml@release/2.7 with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/build-wheels-macos.yml b/.github/workflows/build-wheels-macos.yml index 3a394cff64b..8c49e108773 100644 --- a/.github/workflows/build-wheels-macos.yml +++ b/.github/workflows/build-wheels-macos.yml @@ -22,7 +22,7 @@ on: jobs: generate-matrix: - uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main + uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@release/2.7 with: package-type: wheel os: macos-arm64 @@ -47,7 +47,7 @@ jobs: smoke-test-script: .ci/scripts/wheel/test_macos.py package-name: executorch name: ${{ matrix.repository }} - uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@main + uses: pytorch/test-infra/.github/workflows/build_wheels_macos.yml@release/2.7 with: repository: ${{ matrix.repository }} ref: "" diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index b8b63078643..7afc599e70e 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -15,7 +15,7 @@ on: jobs: build: - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -93,7 +93,7 @@ jobs: permissions: id-token: write contents: write - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 with: repository: pytorch/executorch download-artifact: docs diff --git a/.github/workflows/docker-builds.yml b/.github/workflows/docker-builds.yml index 791a52b96c1..abcf2686b36 100644 --- a/.github/workflows/docker-builds.yml +++ b/.github/workflows/docker-builds.yml @@ -57,7 +57,7 @@ jobs: mkdir "${GITHUB_WORKSPACE}" - name: Setup SSH (Click me for login details) - uses: pytorch/test-infra/.github/actions/setup-ssh@main + uses: pytorch/test-infra/.github/actions/setup-ssh@release/2.7 with: github-secret: ${{ secrets.GITHUB_TOKEN }} @@ -65,11 +65,11 @@ jobs: uses: actions/checkout@v3 - name: Setup Linux - uses: pytorch/test-infra/.github/actions/setup-linux@main + uses: pytorch/test-infra/.github/actions/setup-linux@release/2.7 - name: Build docker image id: build-docker-image - uses: pytorch/test-infra/.github/actions/calculate-docker-image@main + uses: pytorch/test-infra/.github/actions/calculate-docker-image@release/2.7 with: docker-image-name: ${{ matrix.docker-image-name }} always-rebuild: true @@ -77,5 +77,5 @@ jobs: force-push: true - name: Teardown Linux - uses: pytorch/test-infra/.github/actions/teardown-linux@main + uses: pytorch/test-infra/.github/actions/teardown-linux@release/2.7 if: always() diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5a3c8595c72..ce8705f3d39 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -16,7 +16,7 @@ concurrency: jobs: lintrunner: - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -65,7 +65,7 @@ jobs: exit $RC android-java-format: - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f8ffd41d214..a6b35350e91 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -21,7 +21,7 @@ jobs: environment: ${{ (github.event_name == 'schedule') && 'update-commit-hash' || '' }} steps: - name: update-pytorch-commit-hash - uses: pytorch/test-infra/.github/actions/update-commit-hash@main + uses: pytorch/test-infra/.github/actions/update-commit-hash@release/2.7 if: ${{ github.event_name == 'schedule' }} with: repo-name: pytorch diff --git a/.github/workflows/periodic.yml b/.github/workflows/periodic.yml index fa3fa6e1cd2..511dc471057 100644 --- a/.github/workflows/periodic.yml +++ b/.github/workflows/periodic.yml @@ -39,7 +39,7 @@ jobs: test-models-linux: name: test-models-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read diff --git a/.github/workflows/pull.yml b/.github/workflows/pull.yml index c3eafc02c39..b2dbee9b1dc 100644 --- a/.github/workflows/pull.yml +++ b/.github/workflows/pull.yml @@ -15,7 +15,7 @@ concurrency: jobs: test-setup-linux-gcc: name: test-setup-linux-gcc - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -40,7 +40,7 @@ jobs: test-models-linux-basic: name: test-models-linux-basic - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -84,7 +84,7 @@ jobs: test-models-linux: name: test-models-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -138,7 +138,7 @@ jobs: test-llama-runner-linux: # Test Both linux x86 and linux aarch64 name: test-llama-runner-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -188,7 +188,7 @@ jobs: test-llama-runner-linux-android: name: test-llama-runner-linux-android - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -213,7 +213,7 @@ jobs: test-custom-ops-linux: name: test-custom-ops-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -237,7 +237,7 @@ jobs: test-selective-build-linux: name: test-selective-build-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -261,7 +261,7 @@ jobs: test-llava-runner-linux: name: test-llava-runner-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -292,7 +292,7 @@ jobs: test-moshi-linux: name: test-moshi-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -322,7 +322,7 @@ jobs: test-quantized-aot-lib-linux: name: test-quantized-aot-lib-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -345,7 +345,7 @@ jobs: test-pybind-build-linux: name: test-pybind-build-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -373,7 +373,7 @@ jobs: test-binary-size-linux-gcc: name: test-binary-size-linux-gcc - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -409,7 +409,7 @@ jobs: test-binary-size-linux: name: test-binary-size-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -482,7 +482,7 @@ jobs: docker-image: executorch-ubuntu-22.04-clang12 unittest-arm: - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -515,7 +515,7 @@ jobs: test-llama-runner-qnn-linux: name: test-llama-runner-qnn-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -554,7 +554,7 @@ jobs: test-static-llama-qnn-linux: name: test-static-llama-qnn-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -588,7 +588,7 @@ jobs: test-qnn-models-linux: name: test-qnn-models-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -610,7 +610,7 @@ jobs: test-phi-3-mini-runner-linux: name: test-phi-3-mini-runner-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -637,7 +637,7 @@ jobs: test-eval_llama-wikitext-linux: name: test-eval_llama-wikitext-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -664,7 +664,7 @@ jobs: test-eval_llama-mmlu-linux: name: test-eval_llama-mmlu-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -691,7 +691,7 @@ jobs: test-llama_runner_eager-linux: name: test-llama_runner_eager-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -718,7 +718,7 @@ jobs: test-mediatek-models-linux: name: test-mediatek-models-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read diff --git a/.github/workflows/trunk.yml b/.github/workflows/trunk.yml index 6c4d7f8a58e..62e55ed87b8 100644 --- a/.github/workflows/trunk.yml +++ b/.github/workflows/trunk.yml @@ -20,7 +20,7 @@ concurrency: jobs: test-models-macos: name: test-models-macos - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 strategy: matrix: # Mac runners are expensive and limited, and non reliable. @@ -57,7 +57,7 @@ jobs: test-models-linux-aarch64: name: test-models-linux-aarch64 - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -107,7 +107,7 @@ jobs: test-custom-ops-macos: name: test-custom-ops-macos - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 strategy: matrix: include: @@ -129,7 +129,7 @@ jobs: test-selective-build-macos: name: test-selective-build-macos - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 strategy: matrix: include: @@ -151,7 +151,7 @@ jobs: test-demo-backend-delegation: name: test-demo-backend-delegation - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -178,7 +178,7 @@ jobs: test-arm-backend-delegation: name: test-arm-backend-delegation - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -208,7 +208,7 @@ jobs: test-arm-reference-delegation: name: test-arm-reference-delegation - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -233,7 +233,7 @@ jobs: test-coreml-delegate: name: test-coreml-delegate - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 with: runner: macos-latest-xlarge python-version: '3.11' @@ -251,7 +251,7 @@ jobs: test-pybind-build-macos: name: test-pybind-build-macos - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 strategy: matrix: include: @@ -275,7 +275,7 @@ jobs: test-static-llama-ane: name: test-static-llama-ane - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 with: runner: macos-m1-stable python-version: '3.11' @@ -297,7 +297,7 @@ jobs: test-llama-torchao-lowbit: name: test-llama-torchao-lowbit - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 with: runner: macos-m1-stable python-version: '3.11' @@ -318,7 +318,7 @@ jobs: test-llama-runner-linux: # Test Both linux x86 and linux aarch64 name: test-llama-runner-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -376,7 +376,7 @@ jobs: test-llama-runner-macos: name: test-llama-runner-mac - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 strategy: matrix: dtype: [fp32] @@ -416,7 +416,7 @@ jobs: # # TODO(jackzhxng): Runner consistently runs out of memory before test finishes. Try to find a more powerful runner. # test-llava-runner-macos: # name: test-llava-runner-macos - # uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + # uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 # strategy: # fail-fast: false # with: @@ -444,7 +444,7 @@ jobs: test-qnn-model: name: test-qnn-model - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -470,7 +470,7 @@ jobs: test-apple-model: name: test-apple-model - uses: pytorch/test-infra/.github/workflows/macos_job.yml@main + uses: pytorch/test-infra/.github/workflows/macos_job.yml@release/2.7 strategy: fail-fast: false with: @@ -507,7 +507,7 @@ jobs: # NB: Don't run this on fork PRs because they won't have access to the secret and would fail anyway if: ${{ !github.event.pull_request.head.repo.fork }} name: test-huggingface-transformers - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read @@ -572,7 +572,7 @@ jobs: test-llama-runner-qnn-linux: name: test-llama-runner-qnn-linux - uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@main + uses: pytorch/test-infra/.github/workflows/linux_job_v2.yml@release/2.7 permissions: id-token: write contents: read diff --git a/.github/workflows/update-viablestrict.yml b/.github/workflows/update-viablestrict.yml index e639c497549..5316b117da9 100644 --- a/.github/workflows/update-viablestrict.yml +++ b/.github/workflows/update-viablestrict.yml @@ -16,7 +16,7 @@ jobs: environment: ${{ (github.event_name == 'schedule') && 'update-viable-strict' || '' }} steps: - name: Update viable/strict - uses: pytorch/test-infra/.github/actions/update-viablestrict@main + uses: pytorch/test-infra/.github/actions/update-viablestrict@release/2.7 with: repository: pytorch/executorch stable-branch: viable/strict diff --git a/backends/xnnpack/operators/op_static_constant_pad.py b/backends/xnnpack/operators/op_static_constant_pad.py index 3381227a885..c14db8192a2 100644 --- a/backends/xnnpack/operators/op_static_constant_pad.py +++ b/backends/xnnpack/operators/op_static_constant_pad.py @@ -7,6 +7,7 @@ from typing import cast, Dict, List import torch + from executorch.backends.xnnpack.operators.node_visitor import ( get_tensor_value, NodeVisitor, @@ -17,7 +18,11 @@ XNNStaticConstantPad, XNode, ) -from executorch.backends.xnnpack.utils.utils import check_or_raise, get_input_node +from executorch.backends.xnnpack.utils.utils import ( + check_or_raise, + get_input_node, + PERM_NCHW_TO_NHWC, +) @register_node_visitor @@ -113,8 +118,15 @@ def define_node( # b) # tuple[0] = prepadding dim[-1] # tuple[1] = postpadding dim[-1] + is_channels_last = node.meta.get("XNN_NHWC_NODE", False) pre_paddings = all_paddings[-2::-2] # even index elements in reverse order post_paddings = all_paddings[::-2] # odd index elements in reverse order + if is_channels_last: + check_or_raise(len(pre_paddings) == 4, "Expecting prepaddings to be 4D") + check_or_raise(len(post_paddings) == 4, "Expecting postpaddings to be 4D") + + pre_paddings = [pre_paddings[i] for i in PERM_NCHW_TO_NHWC] + post_paddings = [post_paddings[i] for i in PERM_NCHW_TO_NHWC] # the padding value, which defaults to 0.0 padding_value = cast(float, node.args[2]) if len(node.args) > 2 else 0.0 diff --git a/backends/xnnpack/test/ops/test_static_constant_pad.py b/backends/xnnpack/test/ops/test_static_constant_pad.py index c5d103f596a..9613308f6a6 100644 --- a/backends/xnnpack/test/ops/test_static_constant_pad.py +++ b/backends/xnnpack/test/ops/test_static_constant_pad.py @@ -14,6 +14,30 @@ class TestStaticConstantPad(unittest.TestCase): def setUp(self): torch._dynamo.reset() + class NHWCStaticConstantPad(torch.nn.Module): + def __init__(self): + super().__init__() + self.conv1 = torch.nn.Conv2d(in_channels=2, out_channels=2, kernel_size=1) + self.conv2 = torch.nn.Conv2d(in_channels=13, out_channels=13, kernel_size=1) + + def forward(self, x): + a = self.conv1(x) + pad_6 = (1, 2, 3, 4, 5, 6) + a = torch.nn.functional.pad( + input=a, + pad=pad_6, + mode="constant", + value=3.1, + ) + # tensorshape = [1, 13, 10, 7] + a = self.conv2(a) + + return a + + def sample_inputs(self): + # NCHW + return (torch.randn(1, 2, 3, 4),) + class StaticConstantPadFunctional(torch.nn.Module): def __init__(self): super().__init__() @@ -205,3 +229,24 @@ def test_qs8_static_constant_pad_2d(self): .serialize() .run_method_and_compare_outputs() ) + + def test_fp32_static_constant_pad_nhwc(self): + conv = self.NHWCStaticConstantPad() + inputs = conv.sample_inputs() + ( + Tester(conv, inputs) + .export() + .check_count({"torch.ops.aten.pad.default": 1}) + .dump_artifact() + .to_edge_transform_and_lower() + .check_count({"torch.ops.higher_order.executorch_call_delegate": 1}) + .check_not( + [ + "executorch_exir_dialects_edge__ops_aten_constant_pad_nd_default", + "executorch_exir_dialects_edge__ops_aten_convolution_default", + ] + ) + .to_executorch() + .serialize() + .run_method_and_compare_outputs() + ) diff --git a/docs/README.md b/docs/README.md index dd1fded5aa9..20476f3c162 100644 --- a/docs/README.md +++ b/docs/README.md @@ -39,17 +39,20 @@ To build the documentation locally: 1. Clone the ExecuTorch repo to your machine. -1. If you don't have it already, start a conda environment: + ```bash + git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch + ``` - ```{note} - The below command generates a completely new environment and resets - any existing dependencies. If you have an environment already, skip - the `conda create` command. +1. If you don't have it already, start either a Python virtual envitonment: + + ```bash + python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip ``` + Or a Conda environment: + ```bash - conda create -yn executorch python=3.10.0 - conda activate executorch + conda create -yn executorch python=3.10.0 && conda activate executorch ``` 1. Install dependencies: @@ -57,15 +60,11 @@ To build the documentation locally: ```bash pip3 install -r ./.ci/docker/requirements-ci.txt ``` -1. Update submodules - ```bash - git submodule sync && git submodule update --init - ``` 1. Run: ```bash - bash install_executorch.sh + ./install_executorch.sh ``` 1. Go to the `docs/` directory. diff --git a/docs/source/_static/img/android_studio.jpeg b/docs/source/_static/img/android_studio.jpeg new file mode 100644 index 00000000000..e65aac0e374 Binary files /dev/null and b/docs/source/_static/img/android_studio.jpeg differ diff --git a/docs/source/_static/img/android_studio.mp4 b/docs/source/_static/img/android_studio.mp4 new file mode 100644 index 00000000000..2303ef5863c Binary files /dev/null and b/docs/source/_static/img/android_studio.mp4 differ diff --git a/docs/source/backend-delegates-xnnpack-reference.md b/docs/source/backend-delegates-xnnpack-reference.md index 52d208de219..62dead75a4e 100644 --- a/docs/source/backend-delegates-xnnpack-reference.md +++ b/docs/source/backend-delegates-xnnpack-reference.md @@ -142,5 +142,5 @@ def _qdq_quantized_linear( You can read more indepth explanations on PyTorch 2 quantization [here](https://pytorch.org/tutorials/prototype/pt2e_quant_ptq.html). ## See Also -- [Integrating XNNPACK Delegate Android App](demo-apps-android.md) +- [Integrating XNNPACK Delegate in Android AAR](using-executorch-android.md) - [Complete the Lowering to XNNPACK Tutorial](tutorial-xnnpack-delegate-lowering.md) diff --git a/docs/source/backends-qualcomm.md b/docs/source/backends-qualcomm.md index 7a2f749e185..71f1d3cd93c 100644 --- a/docs/source/backends-qualcomm.md +++ b/docs/source/backends-qualcomm.md @@ -351,11 +351,6 @@ The command-line arguments are written in [utils.py](https://github.com/pytorch/ The model, inputs, and output location are passed to `qnn_executorch_runner` by `--model_path`, `--input_list_path`, and `--output_folder_path`. -### Running a model via ExecuTorch's android demo-app - -An Android demo-app using Qualcomm AI Engine Direct Backend can be found in -`examples`. Please refer to android demo app [tutorial](demo-apps-android.md). - ## Supported model list Please refer to `$EXECUTORCH_ROOT/examples/qualcomm/scripts/` and `EXECUTORCH_ROOT/examples/qualcomm/oss_scripts/` to the list of supported models. diff --git a/docs/source/getting-started.md b/docs/source/getting-started.md index 741454fed27..a11856421de 100644 --- a/docs/source/getting-started.md +++ b/docs/source/getting-started.md @@ -137,7 +137,7 @@ For a full example of running a model on Android, see the [DeepLabV3AndroidDemo] #### Installation ExecuTorch supports both iOS and MacOS via C++, as well as hardware backends for CoreML, MPS, and CPU. The iOS runtime library is provided as a collection of .xcframework targets and are made available as a Swift PM package. -To get started with Xcode, go to File > Add Package Dependencies. Paste the URL of the ExecuTorch repo into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version in format “swiftpm-”, (e.g. “swiftpm-0.5.0”). The ExecuTorch dependency can also be added to the package file manually. See [Using ExecuTorch on iOS](using-executorch-ios.md) for more information. +To get started with Xcode, go to File > Add Package Dependencies. Paste the URL of the ExecuTorch repo into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version in format “swiftpm-”, (e.g. “swiftpm-0.6.0”). The ExecuTorch dependency can also be added to the package file manually. See [Using ExecuTorch on iOS](using-executorch-ios.md) for more information. #### Runtime APIs Models can be loaded and run from Objective-C using the C++ APIs. @@ -151,7 +151,7 @@ ExecuTorch provides C++ APIs, which can be used to target embedded or mobile dev CMake is the preferred build system for the ExecuTorch C++ runtime. To use with CMake, clone the ExecuTorch repository as a subdirectory of your project, and use CMake's `add_subdirectory("executorch")` to include the dependency. The `executorch` target, as well as kernel and backend targets will be made available to link against. The runtime can also be built standalone to support diverse toolchains. See [Using ExecuTorch with C++](using-executorch-cpp.md) for a detailed description of build integration, targets, and cross compilation. ``` -git clone -b release/0.5 https://github.com/pytorch/executorch.git +git clone -b release/0.6 https://github.com/pytorch/executorch.git ``` ```python # CMakeLists.txt diff --git a/docs/source/index.md b/docs/source/index.md new file mode 100644 index 00000000000..47ea42a21ea --- /dev/null +++ b/docs/source/index.md @@ -0,0 +1,287 @@ +(home)= +# Welcome to the ExecuTorch Documentation + +**ExecuTorch** is PyTorch's solution to training and inference on the +Edge. + +## Key Value Propositions + +- **Portability:** Compatibility with a wide variety of computing + platforms, from high-end mobile phones to highly constrained + embedded systems and microcontrollers. +- **Productivity:** Enabling developers to use the same toolchains and + Developer Tools from PyTorch model authoring and conversion, to + debugging and deployment to a wide variety of platforms. +- **Performance:** Providing end users with a seamless and + high-performance experience due to a lightweight runtime and + utilizing full hardware capabilities such as CPUs, NPUs, and DSPs. + +ExecuTorch provides support for: + +* **Strong Model Support** LLMs (Large Language Models), + CV (Computer Vision), ASR (Automatic Speech Recognition), TTS (Text To Speech) +* **All Major Platforms** Android, Mac, Linux, Windows +* **Rich Acceleration Support** Apple, Arm, Cadence, MediaTek, + Qualcomm, Vulkan, XNNPACK + +### Documentation Navigation +#### Introduction +- [Overview](intro-overview) +- [How it Works](intro-how-it-works) +- [Getting Started with Architecture](getting-started-architecture) +- [Concepts](concepts) +#### Usage +- [Getting Started](getting-started) +- [Using Executorch Export](using-executorch-export) +- [Using Executorch on Android](using-executorch-android) +- [Using Executorch on iOS](using-executorch-ios) +- [Using Executorch with C++](using-executorch-cpp) +- [Runtime Integration](using-executorch-runtime-integration) +- [Troubleshooting](using-executorch-troubleshooting) +- [Building from Source](using-executorch-building-from-source) +- [FAQs](using-executorch-faqs) +#### Examples +- [Android Demo Apps](https://github.com/pytorch-labs/executorch-examples/tree/main/dl3/android/DeepLabV3Demo#executorch-android-demo-app) +- [iOS Demo Apps](demo-apps-ios.md) +#### Backends +- [Overview](backends-overview) +- [XNNPACK](backends-xnnpack) +- [Core ML](backends-coreml) +- [MPS](backends-mps) +- [Vulkan](backends-vulkan) +- [ARM Ethos-U](backends-arm-ethos-u) +- [Qualcomm](backends-qualcomm) +- [MediaTek](backends-mediatek) +- [Cadence](backends-cadence) +#### Developer Tools +- [Overview](devtools-overview) +- [Bundled IO](bundled-io) +- [ETRecord](etrecord) +- [ETDump](etdump) +- [Runtime Profiling](runtime-profiling) +- [Model Debugging](model-debugging) +- [Model Inspector](model-inspector) +- [Memory Planning Inspection](memory-planning-inspection) +- [Delegate Debugging](delegate-debugging) +- [Tutorial](devtools-tutorial) +#### Runtime +- [Overview](runtime-overview) +- [Extension Module](extension-module) +- [Extension Tensor](extension-tensor) +- [Running a Model (C++ Tutorial)](running-a-model-cpp-tutorial) +- [Backend Delegate Implementation and Linking](runtime-backend-delegate-implementation-and-linking) +- [Platform Abstraction Layer](runtime-platform-abstraction-layer) +#### Portable C++ Programming +- [PTE File Format](pte-file-format) +#### API Reference +- [Export to Executorch API Reference](export-to-executorch-api-reference) +- [Executorch Runtime API Reference](executorch-runtime-api-reference) +- [Runtime Python API Reference](runtime-python-api-reference) +- [API Life Cycle](api-life-cycle) +- [Javadoc](https://pytorch.org/executorch/main/javadoc/) +#### Quantization +- [Overview](quantization-overview) +#### Kernel Library +- [Overview](kernel-library-overview) +- [Custom ATen Kernel](kernel-library-custom-aten-kernel) +- [Selective Build](kernel-library-selective-build) +#### Working with LLMs +- [Llama](llm/llama) +- [Llama on Android](llm/llama-demo-android) +- [Llama on iOS](llm/llama-demo-ios) +- [Llama on Android via Qualcomm backend](llm/build-run-llama3-qualcomm-ai-engine-direct-backend) +- [Intro to LLMs in Executorch](llm/getting-started) +#### Backend Development +- [Delegates Integration](backend-delegates-integration) +- [XNNPACK Reference](backend-delegates-xnnpack-reference) +- [Dependencies](backend-delegates-dependencies) +- [Compiler Delegate and Partitioner](compiler-delegate-and-partitioner) +- [Debug Backend Delegate](debug-backend-delegate) +#### IR Specification +- [EXIR](ir-exir) +- [Ops Set Definition](ir-ops-set-definition) +#### Compiler Entry Points +- [Backend Dialect](compiler-backend-dialect) +- [Custom Compiler Passes](compiler-custom-compiler-passes) +- [Memory Planning](compiler-memory-planning) +#### Contributing +- [Contributing](contributing) + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Introduction +:hidden: + +intro-overview +intro-how-it-works +getting-started-architecture +concepts +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Usage +:hidden: + +getting-started +using-executorch-export +using-executorch-android +using-executorch-ios +using-executorch-cpp +using-executorch-runtime-integration +using-executorch-troubleshooting +using-executorch-building-from-source +using-executorch-faqs +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Examples +:hidden: + +Building an ExecuTorch Android Demo App +demo-apps-ios.md +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Backends +:hidden: + +backends-overview +backends-xnnpack +backends-coreml +backends-mps +backends-vulkan +backends-arm-ethos-u +backends-qualcomm +backends-mediatek +backends-cadence +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Developer Tools +:hidden: + +devtools-overview +bundled-io +etrecord +etdump +runtime-profiling +model-debugging +model-inspector +memory-planning-inspection +delegate-debugging +devtools-tutorial +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Runtime +:hidden: + +runtime-overview +extension-module +extension-tensor +running-a-model-cpp-tutorial +runtime-backend-delegate-implementation-and-linking +runtime-platform-abstraction-layer +portable-cpp-programming +pte-file-format +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: API Reference +:hidden: + +export-to-executorch-api-reference +executorch-runtime-api-reference +runtime-python-api-reference +api-life-cycle +Javadoc +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Quantization +:hidden: + +quantization-overview +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Kernel Library +:hidden: + +kernel-library-overview +kernel-library-custom-aten-kernel +kernel-library-selective-build +``` + +```{toctree} +:glob: +:maxdepth: 2 +:caption: Working with LLMs +:hidden: + +Llama +Llama on Android +Llama on iOS +Llama on Android via Qualcomm backend +Intro to LLMs in Executorch +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Backend Development +:hidden: + +backend-delegates-integration +backend-delegates-xnnpack-reference +backend-delegates-dependencies +compiler-delegate-and-partitioner +debug-backend-delegate +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: IR Specification +:hidden: + +ir-exir +ir-ops-set-definition +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Compiler Entry Points +:hidden: + +compiler-backend-dialect +compiler-custom-compiler-passes +compiler-memory-planning +``` + +```{toctree} +:glob: +:maxdepth: 1 +:caption: Contributing +:hidden: + +contributing +``` diff --git a/docs/source/index.rst b/docs/source/index.rst deleted file mode 100644 index 187a5300c58..00000000000 --- a/docs/source/index.rst +++ /dev/null @@ -1,378 +0,0 @@ -.. _home: - -Welcome to the ExecuTorch Documentation -======================================= - -.. important:: - v0.4.0 was the beta release of ExecuTorch. Starting from v0.4.0, the API - follows the `API Lifecycle and Deprecation Policy `__, - and the ``.pte`` binary format complies with the `Runtime Compatibility - Policy - `__. - This helps ensure that application developers can update to the latest - version of ExecuTorch without breaking existing integration code, in - accordance with these policies. If any issues arise or compatibility breaks - occur, please `report them in GitHub - `__. - - We welcome any feedback, suggestions, and bug reports from the community - to help us improve the technology. Please use the `PyTorch Forums - `__ for discussion and feedback - about ExecuTorch using the **ExecuTorch** category, and our `GitHub - repository `__ for bug - reporting. - -.. raw:: html - -
-

ExecuTorch is a PyTorch platform that provides infrastructure to run PyTorch programs everywhere from AR/VR wearables to standard on-device iOS and Android mobile deployments. One of the main goals for ExecuTorch is to enable wider customization and deployment capabilities of the PyTorch programs.

-

ExecuTorch heavily relies on such PyTorch technologies as torch.compile and torch.export. If you are not familiar with these APIs, you might want to read about them in the PyTorch documentation before diving into the ExecuTorch documentation.

-
ExecuTorch logo
-
- -The ExecuTorch source is hosted on GitHub at -https://github.com/pytorch/executorch. - -Join us on `Discord `__ if you have questions -about ExecuTorch or would like to become a contributor! - -Getting Started -~~~~~~~~~~~~~~~ - -Topics in this section will help you get started with ExecuTorch. - -.. grid:: 3 - - .. grid-item-card:: :octicon:`file-code;1em` - What is ExecuTorch? - :img-top: _static/img/card-background.svg - :link: intro-overview.html - :link-type: url - - A gentle introduction to ExecuTorch. In this section, - you will learn about main features of ExecuTorch - and how you can use them in your projects. - - .. grid-item-card:: :octicon:`file-code;1em` - Getting started with ExecuTorch - :img-top: _static/img/card-background.svg - :link: getting-started.html - :link-type: url - - A step-by-step tutorial on how to get started with - ExecuTorch. - - .. grid-item-card:: :octicon:`file-code;1em` - ExecuTorch Llama - :img-top: _static/img/card-background.svg - :link: llm/llama.html - :link-type: url - - Learn about running Llama models via ExecuTorch - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Introduction - :hidden: - - intro-overview - intro-how-it-works - getting-started-architecture - concepts - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Usage - :hidden: - - getting-started - using-executorch-export - using-executorch-android - using-executorch-ios - using-executorch-cpp - using-executorch-runtime-integration - using-executorch-troubleshooting - using-executorch-building-from-source - using-executorch-faqs - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Examples - :hidden: - - Building an ExecuTorch Android Demo App - demo-apps-ios.md - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Backends - :hidden: - - backends-overview - backends-xnnpack - backends-coreml - backends-mps - backends-vulkan - backends-arm-ethos-u - backends-qualcomm - backends-mediatek - backends-cadence - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Tutorials - :hidden: - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Developer Tools - :hidden: - - devtools-overview - bundled-io - etrecord - etdump - runtime-profiling - model-debugging - model-inspector - memory-planning-inspection - delegate-debugging - devtools-tutorial - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Runtime - :hidden: - - runtime-overview - extension-module - extension-tensor - running-a-model-cpp-tutorial - runtime-backend-delegate-implementation-and-linking - runtime-platform-abstraction-layer - portable-cpp-programming - pte-file-format - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: API Reference - :hidden: - - export-to-executorch-api-reference - executorch-runtime-api-reference - runtime-python-api-reference - api-life-cycle - Javadoc - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Quantization - :hidden: - - quantization-overview - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Kernel Library - :hidden: - - kernel-library-overview - kernel-library-custom-aten-kernel - kernel-library-selective-build - -.. toctree:: - :glob: - :maxdepth: 2 - :caption: Working with LLMs - :hidden: - - Llama - Llama on Android - Llama on iOS - Llama on Android via Qualcomm backend - Intro to LLMs in Executorch - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Backend Development - :hidden: - - backend-delegates-integration - backend-delegates-xnnpack-reference - backend-delegates-dependencies - compiler-delegate-and-partitioner - debug-backend-delegate - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: IR Specification - :hidden: - - ir-exir - ir-ops-set-definition - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Compiler Entry Points - :hidden: - - compiler-backend-dialect - compiler-custom-compiler-passes - compiler-memory-planning - -.. toctree:: - :glob: - :maxdepth: 1 - :caption: Contributing - :hidden: - - contributing - -Tutorials and Examples -~~~~~~~~~~~~~~~~~~~~~~ - -Ready to experiment? Check out some of the -ExecuTorch tutorials. - -.. customcardstart:: - -.. customcarditem:: - :header: Exporting to ExecuTorch Tutorial - :card_description: A tutorial for exporting a model and lowering a it to be runnable on the ExecuTorch runtime. - :image: _static/img/generic-pytorch-logo.png - :link: tutorials/export-to-executorch-tutorial.html - :tags: Export,Delegation,Quantization - -.. customcarditem:: - :header: Running an ExecuTorch Model C++ Tutorial - :card_description: A tutorial for setting up memory pools, loading a model, setting inputs, executing the model, and retrieving outputs on device. - :image: _static/img/generic-pytorch-logo.png - :link: running-a-model-cpp-tutorial.html - :tags: - -.. customcarditem:: - :header: Simplified Runtime APIs Tutorial - :card_description: A simplified tutorial for executing the model on device. - :image: _static/img/generic-pytorch-logo.png - :link: extension-module.html - :tags: - -.. customcarditem:: - :header: Managing Tensor Memory in C++ Tutorial - :card_description: A tutorial for managing the dynamic memory when working with tensors. - :image: _static/img/generic-pytorch-logo.png - :link: extension-tensor.html - :tags: - -.. customcarditem:: - :header: Using the ExecuTorch Developer Tools to Profile a Model - :card_description: A tutorial for using the ExecuTorch Developer Tools to profile and analyze a model with linkage back to source code. - :image: _static/img/generic-pytorch-logo.png - :link: tutorials/devtools-integration-tutorial.html - :tags: devtools - -.. customcarditem:: - :header: Integrating and Running ExecuTorch on Apple Platforms - :card_description: A tutorial on integrating, using, and troubleshooting the ExecuTorch runtime on iOS. - :image: _static/img/generic-pytorch-logo.png - :link: apple-runtime.html - :tags: iOS, macOS - -.. customcarditem:: - :header: Building an ExecuTorch iOS Demo App - :card_description: A demo tutorial that explains how to build ExecuTorch into iOS frameworks and run an iOS app. - :image: _static/img/demo_ios_app.jpg - :link: demo-apps-ios.html - :tags: Delegation,iOS - -.. customcarditem:: - :header: Building an ExecuTorch Android Demo App - :card_description: A demo tutorial that explains how to build ExecuTorch into a JNI library and build an Android app. - :image: _static/img/android_app.png - :link: demo-apps-android.html - :tags: Delegation,Android - -.. customcarditem:: - :header: Lowering a Model as a Delegate - :card_description: An end-to-end example showing how to lower a model as a delegate - :image: _static/img/generic-pytorch-logo.png - :link: examples-end-to-end-to-lower-model-to-delegate.html - :tags: Export,Delegation - -.. - First-party backends that are good intros for readers. - -.. customcarditem:: - :header: Building and Running ExecuTorch with XNNPACK Backend - :card_description: A demo tutorial for lowering and exporting models with the XNNPACK Backend - :image: _static/img/generic-pytorch-logo.png - :link: tutorial-xnnpack-delegate-lowering.html - :tags: Export,Backend,Delegation,Quantization,XNNPACK - -.. customcarditem:: - :header: Building and Running ExecuTorch with Vulkan Backend - :card_description: A tutorial that walks you through the process of building ExecuTorch with Vulkan Backend - :image: _static/img/generic-pytorch-logo.png - :link: backends-vulkan.html - :tags: Export,Backend,Delegation,Vulkan - -.. - Alphabetical by backend name. Be sure to keep the same order in the Tutorials - toctree entry above. - -.. customcarditem:: - :header: Building and Running ExecuTorch with ARM Ethos-U Backend - :card_description: A tutorial that walks you through the process of building ExecuTorch with ARM Ethos-U Backend - :image: _static/img/generic-pytorch-logo.png - :link: executorch-arm-delegate-tutorial.html - :tags: Export,Backend,Delegation,ARM,Ethos-U - -.. customcarditem:: - :header: Building and Running ExecuTorch with CoreML Backend - :card_description: A tutorial that walks you through the process of building ExecuTorch with CoreML Backend - :image: _static/img/generic-pytorch-logo.png - :link: backends-coreml.html - :tags: Export,Backend,Delegation,CoreML - -.. customcarditem:: - :header: Building and Running ExecuTorch with MediaTek Backend - :card_description: A tutorial that walks you through the process of building ExecuTorch with MediaTek Backend - :image: _static/img/generic-pytorch-logo.png - :link: backends-mediatek-backend.html - :tags: Export,Backend,Delegation,MediaTek - -.. customcarditem:: - :header: Building and Running ExecuTorch with MPS Backend - :card_description: A tutorial that walks you through the process of building ExecuTorch with MPSGraph Backend - :image: _static/img/generic-pytorch-logo.png - :link: backends-mps.html - :tags: Export,Backend,Delegation,MPS,MPSGraph - -.. customcarditem:: - :header: Building and Running ExecuTorch with Qualcomm AI Engine Direct Backend - :card_description: A tutorial that walks you through the process of building ExecuTorch with Qualcomm AI Engine Direct Backend - :image: _static/img/generic-pytorch-logo.png - :link: backends-qualcomm.html - :tags: Export,Backend,Delegation,QNN - -.. customcarditem:: - :header: Building and Running ExecuTorch on Xtensa HiFi4 DSP - :card_description: A tutorial that walks you through the process of building ExecuTorch for an Xtensa Hifi4 DSP using custom operators - :image: _static/img/generic-pytorch-logo.png - :link: backends-cadence.html - :tags: Export,Custom-Operators,DSP,Xtensa - -.. customcardend:: diff --git a/docs/source/llm/getting-started.md b/docs/source/llm/getting-started.md index 066bb3f3d1c..a4ff2b6fad2 100644 --- a/docs/source/llm/getting-started.md +++ b/docs/source/llm/getting-started.md @@ -43,15 +43,17 @@ Instructions on installing miniconda can be [found here](https://docs.anaconda.c mkdir et-nanogpt cd et-nanogpt -# Clone the ExecuTorch repository and submodules. +# Clone the ExecuTorch repository. mkdir third-party -git clone -b release/0.4 https://github.com/pytorch/executorch.git third-party/executorch -cd third-party/executorch -git submodule update --init +git clone -b release/0.6 https://github.com/pytorch/executorch.git third-party/executorch && cd third-party/executorch -# Create a conda environment and install requirements. -conda create -yn executorch python=3.10.0 -conda activate executorch +# Create either a Python virtual environment: +python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip + +# Or a Conda environment: +conda create -yn executorch python=3.10.0 && conda activate executorch + +# Install requirements ./install_executorch.sh cd ../.. @@ -76,11 +78,8 @@ pyenv install -s 3.10 pyenv virtualenv 3.10 executorch pyenv activate executorch -# Clone the ExecuTorch repository and submodules. -mkdir third-party -git clone -b release/0.4 https://github.com/pytorch/executorch.git third-party/executorch -cd third-party/executorch -git submodule update --init +# Clone the ExecuTorch repository. +git clone -b release/0.6 https://github.com/pytorch/executorch.git third-party/executorch && cd third-party/executorch # Install requirements. PYTHON_EXECUTABLE=python ./install_executorch.sh diff --git a/docs/source/tutorial-xnnpack-delegate-lowering.md b/docs/source/tutorial-xnnpack-delegate-lowering.md index a469edebd54..7fc97476ef7 100644 --- a/docs/source/tutorial-xnnpack-delegate-lowering.md +++ b/docs/source/tutorial-xnnpack-delegate-lowering.md @@ -176,7 +176,7 @@ Now you should be able to find the executable built at `./cmake-out/backends/xnn ``` ## Building and Linking with the XNNPACK Backend -You can build the XNNPACK backend [CMake target](https://github.com/pytorch/executorch/blob/main/backends/xnnpack/CMakeLists.txt#L83), and link it with your application binary such as an Android or iOS application. For more information on this you may take a look at this [resource](demo-apps-android.md) next. +You can build the XNNPACK backend [CMake target](https://github.com/pytorch/executorch/blob/main/backends/xnnpack/CMakeLists.txt#L83), and link it with your application binary such as an Android or iOS application. For more information on this you may take a look at this [resource](./using-executorch-android.md) next. ## Profiling To enable profiling in the `xnn_executor_runner` pass the flags `-DEXECUTORCH_ENABLE_EVENT_TRACER=ON` and `-DEXECUTORCH_BUILD_DEVTOOLS=ON` to the build command (add `-DENABLE_XNNPACK_PROFILING=ON` for additional details). This will enable ETDump generation when running the inference and enables command line flags for profiling (see `xnn_executor_runner --help` for details). diff --git a/docs/source/using-executorch-android.md b/docs/source/using-executorch-android.md index 99b68008dc6..f1a18ba4ae4 100644 --- a/docs/source/using-executorch-android.md +++ b/docs/source/using-executorch-android.md @@ -22,21 +22,28 @@ The AAR artifact contains the Java library for users to integrate with their Jav - LLaMa-specific Custom ops library. - Comes with two ABI variants, arm64-v8a and x86\_64. +The AAR library can be used for generic Android device with arm64-v8a or x86_64 architecture. It can be used across form factors, including phones, tablets, tv boxes, etc, as it does not contain any UI components. + ## Using AAR from Maven Central ExecuTorch is available on [Maven Central](https://mvnrepository.com/artifact/org.pytorch/executorch-android). -Simply add the target [`org.pytorch:executorch-android:0.5.1`](https://repo.maven.apache.org/maven2/org/pytorch/executorch-android/0.5.1/) to your Android app dependency (build.gradle), and build your app. +Simply add the target [`org.pytorch:executorch-android:0.6.0-rc1`](https://repo.maven.apache.org/maven2/org/pytorch/executorch-android/0.6.0-rc1/) to your Android app dependency (build.gradle), and build your app. For example: ``` # app/build.gradle.kts dependencies { - implementation("org.pytorch:executorch-android:0.5.1") + implementation("org.pytorch:executorch-android:0.6.0-rc1") } ``` -Note: `org.pytorch:executorch-android:0.5.1` corresponds to executorch v0.5.0. +Note: If you want to use release v0.5.0, please use dependency `org.pytorch:executorch-android:0.5.1`. + +Click the screenshot below to watch the *demo video* on how to add the package and run a simple ExecuTorch model with Android Studio. + + Integrating and Running ExecuTorch on Android + ## Using AAR file directly @@ -46,6 +53,7 @@ You can also directly specify an AAR file in the app. We upload pre-built AAR to | Version | AAR | SHASUMS | | ------- | --- | ------- | +| [v0.6.0-rc1](https://github.com/pytorch/executorch/releases/tag/v0.6.0-rc1) | [executorch.aar](https://ossci-android.s3.amazonaws.com/executorch/release/v0.6.0-rc1/executorch.aar) | [executorch.aar.sha256sums](https://ossci-android.s3.amazonaws.com/executorch/release/v0.6.0-rc1/executorch.aar.sha256sums) | | [v0.5.0](https://github.com/pytorch/executorch/releases/tag/v0.5.0) | [executorch.aar](https://ossci-android.s3.amazonaws.com/executorch/release/v0.5.0-rc3/executorch.aar) | [executorch.aar.sha256sums](https://ossci-android.s3.amazonaws.com/executorch/release/v0.5.0-rc3/executorch.aar.sha256sums) | ### Snapshots from main branch @@ -71,7 +79,7 @@ implementation("com.facebook.fbjni:fbjni:0.5.1") In your app working directory, such as executorch/examples/demo-apps/android/LlamaDemo, ``` mkdir -p app/libs -curl https://ossci-android.s3.amazonaws.com/executorch/release/v0.5.0-rc3/executorch.aar -o app/libs/executorch.aar +curl https://ossci-android.s3.amazonaws.com/executorch/release/v0.6.0-rc1/executorch.aar -o app/libs/executorch.aar ``` And include it in gradle: @@ -103,6 +111,8 @@ export ANDROID_NDK=/path/to/ndk sh scripts/build_android_library.sh ``` +Currently, XNNPACK backend is always built with the script. + ### Optional environment variables Optionally, set these environment variables before running `build_android_library.sh`. diff --git a/docs/source/using-executorch-building-from-source.md b/docs/source/using-executorch-building-from-source.md index 345f0324d50..61f1ce78097 100644 --- a/docs/source/using-executorch-building-from-source.md +++ b/docs/source/using-executorch-building-from-source.md @@ -36,27 +36,23 @@ portability details. ## Environment Setup -### Create a Virtual Environment +### Clone ExecuTorch -[Install conda on your machine](https://conda.io/projects/conda/en/latest/user-guide/install/index.html). Then, create a virtual environment to manage our dependencies. ```bash - # Create and activate a conda environment named "executorch" - conda create -yn executorch python=3.10.0 - conda activate executorch + # Clone the ExecuTorch repo from GitHub + git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` -### Clone ExecuTorch +### Create a Virtual Environment +Create and activate a Python virtual environment: ```bash - # Clone the ExecuTorch repo from GitHub - # 'main' branch is the primary development branch where you see the latest changes. - # 'viable/strict' contains all of the commits on main that pass all of the necessary CI checks. - git clone --branch viable/strict https://github.com/pytorch/executorch.git - cd executorch - - # Update and pull submodules - git submodule sync - git submodule update --init + python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip + ``` + +Or alternatively, [install conda on your machine](https://conda.io/projects/conda/en/latest/user-guide/install/index.html). Then, create a Conda environment named "executorch". + ```bash + conda create -yn executorch python=3.10.0 && conda activate executorch ``` ## Install ExecuTorch pip package from Source @@ -67,7 +63,7 @@ portability details. ./install_executorch.sh ``` - Use the [`--pybind` flag](https://github.com/pytorch/executorch/blob/main/install_executorch.sh#L26-L29) to install with pybindings and dependencies for other backends. + Use the [`--pybind` flag](https://github.com/pytorch/executorch/blob/main/install_executorch.sh#L26-L29) to install with pybindings and dependencies for other backends. ```bash ./install_executorch.sh --pybind @@ -86,7 +82,7 @@ portability details. For development mode, run the command with `--editable`, which allows us to modify Python source code and see changes reflected immediately. ```bash ./install_executorch.sh --editable [--pybind xnnpack] - + # Or you can directly do the following if dependencies are already installed # either via a previous invocation of `./install_executorch.sh` or by explicitly installing requirements via `./install_requirements.sh` first. pip install -e . @@ -200,7 +196,7 @@ I 00:00:00.000612 executorch:executor_runner.cpp:138] Setting up planned buffer I 00:00:00.000669 executorch:executor_runner.cpp:161] Method loaded. I 00:00:00.000685 executorch:executor_runner.cpp:171] Inputs prepared. I 00:00:00.000764 executorch:executor_runner.cpp:180] Model executed successfully. -I 00:00:00.000770 executorch:executor_runner.cpp:184] 1 outputs: +I 00:00:00.000770 executorch:executor_runner.cpp:184] 1 outputs: Output 0: tensor(sizes=[1], [2.]) ``` @@ -210,6 +206,8 @@ Output 0: tensor(sizes=[1], [2.]) Following are instruction on how to perform cross compilation for Android and iOS. ### Android + +#### Building executor_runner shell binary - Prerequisite: [Android NDK](https://developer.android.com/ndk), choose one of the following: - Option 1: Download Android Studio by following the instructions to [install ndk](https://developer.android.com/studio/projects/install-ndk). - Option 2: Download Android NDK directly from [here](https://developer.android.com/ndk/downloads). @@ -235,6 +233,20 @@ adb push add.pte /data/local/tmp/executorch adb shell "/data/local/tmp/executorch/executor_runner --model_path /data/local/tmp/executorch/add.pte" ``` +#### Building AAR for app integration from source +- Prerequisite: Android NDK from the previous section, and Android SDK (Android Studio is recommended). + +Assuming Android NDK and SDK is available, run: +```bash +export ANDROID_ABIS=arm64-v8a +export BUILD_AAR_DIR=aar-out +mkdir -p $BUILD_AAR_DIR +sh scripts/build_android_library.sh +``` + +This script will build the AAR, which contains the Java API and its corresponding JNI library. Please see +[this documentation](./using-executorch-android#using-aar-file) for usage. + ### iOS For iOS we'll build [frameworks](https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle) instead of static libraries, that will also contain the public headers inside. @@ -268,5 +280,5 @@ Check out the [iOS Demo App](demo-apps-ios.md) tutorial for more info. You have successfully cross-compiled `executor_runner` binary to iOS and Android platforms. You can start exploring advanced features and capabilities. Here is a list of sections you might want to read next: * [Selective build](kernel-library-selective-build.md) to build the runtime that links to only kernels used by the program, which can provide significant binary size savings. -* Tutorials on building [Android](./demo-apps-android.md) and [iOS](./demo-apps-ios.md) demo apps. +* Tutorials on building [Android](https://github.com/pytorch-labs/executorch-examples/tree/main/dl3/android/DeepLabV3Demo#executorch-android-demo-app) and [iOS](./demo-apps-ios.md) demo apps. * Tutorials on deploying applications to embedded devices such as [ARM Cortex-M/Ethos-U](backends-arm-ethos-u.md) and [XTensa HiFi DSP](./backends-cadence.md). diff --git a/docs/source/using-executorch-ios.md b/docs/source/using-executorch-ios.md index 70c2b366fa8..56f9084376f 100644 --- a/docs/source/using-executorch-ios.md +++ b/docs/source/using-executorch-ios.md @@ -25,7 +25,7 @@ The prebuilt ExecuTorch runtime, backend, and kernels are available as a [Swift #### Xcode -In Xcode, go to `File > Add Package Dependencies`. Paste the URL of the [ExecuTorch repo](https://github.com/pytorch/executorch) into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version in format "swiftpm-", (e.g. "swiftpm-0.5.0"), or a branch name in format "swiftpm-." (e.g. "swiftpm-0.5.0-20250228") for a nightly build on a specific date. +In Xcode, go to `File > Add Package Dependencies`. Paste the URL of the [ExecuTorch repo](https://github.com/pytorch/executorch) into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version in format "swiftpm-", (e.g. "swiftpm-0.6.0"), or a branch name in format "swiftpm-." (e.g. "swiftpm-0.6.0-20250501") for a nightly build on a specific date. ![](_static/img/swiftpm_xcode1.png) @@ -58,7 +58,7 @@ let package = Package( ], dependencies: [ // Use "swiftpm-." branch name for a nightly build. - .package(url: "https://github.com/pytorch/executorch.git", branch: "swiftpm-0.5.0") + .package(url: "https://github.com/pytorch/executorch.git", branch: "swiftpm-0.6.0") ], targets: [ .target( @@ -97,7 +97,7 @@ xcode-select --install 2. Clone ExecuTorch: ```bash -git clone https://github.com/pytorch/executorch.git --depth 1 --recurse-submodules --shallow-submodules && cd executorch +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` 3. Set up [Python](https://www.python.org/downloads/macos/) 3.10+ and activate a virtual environment: @@ -106,15 +106,16 @@ git clone https://github.com/pytorch/executorch.git --depth 1 --recurse-submodul python3 -m venv .venv && source .venv/bin/activate && ./install_requirements.sh ``` -4. Install the required dependencies, including those needed for the backends like [Core ML](backends-coreml.md) or [MPS](backends-mps.md). Choose one: +4. Install the required dependencies, including those needed for the backends like [Core ML](backends-coreml.md) or [MPS](backends-mps.md). Choose one, or both: ```bash # ExecuTorch with xnnpack and CoreML backend -./install_executorch.sh --pybind xnnpack +./backends/apple/coreml/scripts/install_requirements.sh +./install_executorch.sh --pybind coreml xnnpack -# Optional: ExecuTorch with xnnpack, CoreML, and MPS backend +# ExecuTorch with xnnpack and MPS backend ./backends/apple/mps/install_requirements.sh -./install_executorch.sh --pybind xnnpack mps +./install_executorch.sh --pybind mps xnnpack ``` 5. Install [CMake](https://cmake.org): diff --git a/examples/arm/setup.sh b/examples/arm/setup.sh index 5ae7bd7798d..016e03f04a2 100755 --- a/examples/arm/setup.sh +++ b/examples/arm/setup.sh @@ -160,7 +160,7 @@ function setup_tosa_reference_model() { # reference_model flatbuffers version clashes with Vela. # go with Vela's since it newer. # Vela's flatbuffer requirement is expected to loosen, then remove this. MLETORCH-565 - pip install tosa-tools@git+${tosa_reference_model_url}@${tosa_reference_model_rev} --no-dependencies flatbuffers + CMAKE_POLICY_VERSION_MINIMUM=3.5 pip install tosa-tools@git+${tosa_reference_model_url}@${tosa_reference_model_rev} --no-dependencies flatbuffers } diff --git a/examples/demo-apps/android/LlamaDemo/docs/delegates/mediatek_README.md b/examples/demo-apps/android/LlamaDemo/docs/delegates/mediatek_README.md index 4d1346963c7..dabe0b6dc6d 100644 --- a/examples/demo-apps/android/LlamaDemo/docs/delegates/mediatek_README.md +++ b/examples/demo-apps/android/LlamaDemo/docs/delegates/mediatek_README.md @@ -21,23 +21,29 @@ Phone verified: MediaTek Dimensity 9300 (D9300) chip. ## Setup ExecuTorch In this section, we will need to set up the ExecuTorch repo first with Conda environment management. Make sure you have Conda available in your system (or follow the instructions to install it [here](https://anaconda.org/anaconda/conda)). The commands below are running on Linux (CentOS). -Create a Conda environment +Checkout ExecuTorch repo and sync submodules + ``` -conda create -yn et_mtk python=3.10.0 -conda activate et_mtk +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` -Checkout ExecuTorch repo and sync submodules +Create either a Python virtual environment: + +``` +python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip ``` -git clone https://github.com/pytorch/executorch.git -cd executorch -git submodule sync -git submodule update --init + +Or a Conda environment: + +``` +conda create -n et_xnnpack python=3.10.0 && conda activate et_xnnpack ``` + Install dependencies ``` ./install_executorch.sh ``` + ## Setup Environment Variables ### Download Buck2 and make executable * Download Buck2 from the official [Release Page](https://github.com/facebook/buck2/releases/tag/2024-02-01) diff --git a/examples/demo-apps/android/LlamaDemo/docs/delegates/qualcomm_README.md b/examples/demo-apps/android/LlamaDemo/docs/delegates/qualcomm_README.md index 92afe613f7b..bb14e7d295d 100644 --- a/examples/demo-apps/android/LlamaDemo/docs/delegates/qualcomm_README.md +++ b/examples/demo-apps/android/LlamaDemo/docs/delegates/qualcomm_README.md @@ -19,19 +19,24 @@ Phone verified: OnePlus 12, Samsung 24+, Samsung 23 ## Setup ExecuTorch In this section, we will need to set up the ExecuTorch repo first with Conda environment management. Make sure you have Conda available in your system (or follow the instructions to install it [here](https://anaconda.org/anaconda/conda)). The commands below are running on Linux (CentOS). -Create a Conda environment +Checkout ExecuTorch repo and sync submodules + ``` -conda create -n et_qnn python=3.10.0 -conda activate et_qnn +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` -Checkout ExecuTorch repo and sync submodules +Create either a Python virtual environment: + ``` -git clone https://github.com/pytorch/executorch.git -cd executorch -git submodule sync -git submodule update --init +python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip ``` + +Or a Conda environment: + +``` +conda create -n et_xnnpack python=3.10.0 && conda activate et_xnnpack +``` + Install dependencies ``` ./install_executorch.sh @@ -74,7 +79,7 @@ cmake --build cmake-out -j16 --target install --config Release ### Setup Llama Runner Next we need to build and compile the Llama runner. This is similar to the requirements for running Llama with XNNPACK. ``` -sh examples/models/llama/install_requirements.sh +./examples/models/llama/install_requirements.sh cmake -DPYTHON_EXECUTABLE=python \ -DCMAKE_INSTALL_PREFIX=cmake-out \ diff --git a/examples/demo-apps/android/LlamaDemo/docs/delegates/xnnpack_README.md b/examples/demo-apps/android/LlamaDemo/docs/delegates/xnnpack_README.md index 2b9bad21b7a..61926246470 100644 --- a/examples/demo-apps/android/LlamaDemo/docs/delegates/xnnpack_README.md +++ b/examples/demo-apps/android/LlamaDemo/docs/delegates/xnnpack_README.md @@ -21,35 +21,34 @@ Phone verified: OnePlus 12, OnePlus 9 Pro. Samsung S23 (Llama only), Samsung S24 ## Setup ExecuTorch In this section, we will need to set up the ExecuTorch repo first with Conda environment management. Make sure you have Conda available in your system (or follow the instructions to install it [here](https://anaconda.org/anaconda/conda)). The commands below are running on Linux (CentOS). -Create a Conda environment +Checkout ExecuTorch repo and sync submodules + ``` -conda create -yn executorch python=3.10.0 -conda activate executorch +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` -Checkout ExecuTorch repo and sync submodules +Create either a Python virtual environment: + ``` -git clone https://github.com/pytorch/executorch.git -cd executorch -git submodule sync -git submodule update --init +python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip ``` -Install dependencies + +Or a Conda environment: + ``` -./install_executorch.sh +conda create -n et_xnnpack python=3.10.0 && conda activate et_xnnpack ``` -Optional: Use the --pybind flag to install with pybindings. +Install dependencies ``` -./install_executorch.sh --pybind xnnpack +./install_executorch.sh ``` - ## Prepare Models In this demo app, we support text-only inference with up-to-date Llama models and image reasoning inference with LLaVA 1.5. * You can request and download model weights for Llama through Meta official [website](https://llama.meta.com/). * For chat use-cases, download the instruct models instead of pretrained. -* Run `examples/models/llama/install_requirements.sh` to install dependencies. +* Run `./examples/models/llama/install_requirements.sh` to install dependencies. * Rename tokenizer for Llama3.x with command: `mv tokenizer.model tokenizer.bin`. We are updating the demo app to support tokenizer in original format directly. ### For Llama 3.2 1B and 3B SpinQuant models diff --git a/examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj b/examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj index 2ee4db5361d..7c88eff27a5 100644 --- a/examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj +++ b/examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo.xcodeproj/project.pbxproj @@ -806,7 +806,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/pytorch/executorch"; requirement = { - branch = "swiftpm-0.5.0.20250317"; + branch = "swiftpm-0.6.0"; kind = branch; }; }; diff --git a/examples/demo-apps/apple_ios/ExecuTorchDemo/README.md b/examples/demo-apps/apple_ios/ExecuTorchDemo/README.md index 844c83d2200..0a44de8268d 100644 --- a/examples/demo-apps/apple_ios/ExecuTorchDemo/README.md +++ b/examples/demo-apps/apple_ios/ExecuTorchDemo/README.md @@ -44,8 +44,7 @@ Follow the [Setting Up ExecuTorch](https://pytorch.org/executorch/stable/getting tutorial to configure the basic environment: ```bash -git clone https://github.com/pytorch/executorch.git --depth 1 --recurse-submodules --shallow-submodules -cd executorch +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch python3 -m venv .venv && source .venv/bin/activate diff --git a/examples/demo-apps/apple_ios/LLaMA/LLaMA.xcodeproj/project.pbxproj b/examples/demo-apps/apple_ios/LLaMA/LLaMA.xcodeproj/project.pbxproj index a067873a0b9..0cfc4ddaa74 100644 --- a/examples/demo-apps/apple_ios/LLaMA/LLaMA.xcodeproj/project.pbxproj +++ b/examples/demo-apps/apple_ios/LLaMA/LLaMA.xcodeproj/project.pbxproj @@ -852,7 +852,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/pytorch/executorch"; requirement = { - branch = "swiftpm-0.5.0.20250228"; + branch = "swiftpm-0.6.0"; kind = branch; }; }; diff --git a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md index f5292fe5c05..dd0dfda7330 100644 --- a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md +++ b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/mps_README.md @@ -14,26 +14,29 @@ More specifically, it covers: ## Setup ExecuTorch In this section, we will need to set up the ExecuTorch repo first with Conda environment management. Make sure you have Conda available in your system (or follow the instructions to install it [here](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)). The commands below are running on Linux (CentOS). -Create a Conda environment +Checkout ExecuTorch repo and sync submodules ``` -conda create -n et_mps python=3.10.0 -conda activate et_mps +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` -Checkout ExecuTorch repo and sync submodules +Create either a Python virtual environment: + +``` +python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip +``` + +Or a Conda environment ``` -git clone https://github.com/pytorch/executorch.git -cd executorch -git submodule sync -git submodule update --init +conda create -n et_mps python=3.10.0 && conda activate et_mps ``` Install dependencies ``` ./install_executorch.sh +./backends/apple/mps/install_requirements.sh ``` ## Prepare Models @@ -42,7 +45,7 @@ In this demo app, we support text-only inference with Llama 3.1, Llama 3, and Ll Install the required packages to export the model ``` -sh examples/models/llama/install_requirements.sh +./examples/models/llama/install_requirements.sh ``` Export the model @@ -76,17 +79,7 @@ sudo /Applications/CMake.app/Contents/bin/cmake-gui --install The prebuilt ExecuTorch runtime, backend, and kernels are available as a Swift PM package. ### Xcode -Open the project in Xcode.In Xcode, go to `File > Add Package Dependencies`. Paste the URL of the ExecuTorch repo into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version, e.g., “swiftpm-0.5.0”, or a branch name in format "swiftpm-." (e.g. "swiftpm-0.5.0-20250228") for a nightly build on a specific date. - -Note: If you're running into any issues related to package dependencies, quit Xcode entirely, delete the whole executorch repo, clean the caches by running the command below in terminal and clone the repo again. - -``` -rm -rf \ - ~/Library/org.swift.swiftpm \ - ~/Library/Caches/org.swift.swiftpm \ - ~/Library/Caches/com.apple.dt.Xcode \ - ~/Library/Developer/Xcode/DerivedData -``` +Open the project in Xcode.In Xcode, go to `File > Add Package Dependencies`. Paste the URL of the ExecuTorch repo into the search bar and select it. Make sure to change the branch name to the desired ExecuTorch version, e.g., “swiftpm-0.6.0”, or a branch name in format "swiftpm-." (e.g. "swiftpm-0.6.0-20250501") for a nightly build on a specific date. Link your binary with the ExecuTorch runtime and any backends or kernels used by the exported ML model. It is recommended to link the core runtime to the components that use ExecuTorch directly, and link kernels and backends against the main app target. diff --git a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md index c45871a1fe5..687ef034bd1 100644 --- a/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md +++ b/examples/demo-apps/apple_ios/LLaMA/docs/delegates/xnnpack_README.md @@ -13,31 +13,30 @@ More specifically, it covers: ## Setup ExecuTorch In this section, we will need to set up the ExecuTorch repo first with Conda environment management. Make sure you have Conda available in your system (or follow the instructions to install it [here](https://conda.io/projects/conda/en/latest/user-guide/install/index.html)). The commands below are running on Linux (CentOS). -Create a Conda environment +Checkout ExecuTorch repo and sync submodules ``` -conda create -n et_xnnpack python=3.10.0 -conda activate et_xnnpack +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` -Checkout ExecuTorch repo and sync submodules +Create either a Python virtual environment: ``` -git clone https://github.com/pytorch/executorch.git -cd executorch -git submodule sync -git submodule update --init +python3 -m venv .venv && source .venv/bin/activate && pip install --upgrade pip ``` -Install dependencies +Or a Conda environment: ``` -./install_executorch.sh +conda create -n et_xnnpack python=3.10.0 && conda activate et_xnnpack ``` -Optional: Use the --pybind flag to install with pybindings. + +Install dependencies + ``` -./install_executorch.sh --pybind xnnpack +./install_executorch.sh ``` + ## Prepare Models In this demo app, we support text-only inference with up-to-date Llama models and image reasoning inference with LLaVA 1.5. * You can request and download model weights for Llama through Meta official [website](https://llama.meta.com/). @@ -45,8 +44,9 @@ In this demo app, we support text-only inference with up-to-date Llama models an * Install the required packages to export the model: ``` -sh examples/models/llama/install_requirements.sh +./examples/models/llama/install_requirements.sh ``` + ### For Llama 3.2 1B and 3B SpinQuant models Meta has released prequantized INT4 SpinQuant Llama 3.2 models that ExecuTorch supports on the XNNPACK backend. * Export Llama model and generate .pte file as below: @@ -112,27 +112,14 @@ There are two options to add ExecuTorch runtime package into your XCode project: The current XCode project is pre-configured to automatically download and link the latest prebuilt package via Swift Package Manager. -If you have an old ExecuTorch package cached before in XCode, or are running into any package dependencies issues (incorrect checksum hash, missing package, outdated package), close XCode and run the following command in terminal inside your ExecuTorch directory - -``` -rm -rf \ - ~/Library/org.swift.swiftpm \ - ~/Library/Caches/org.swift.swiftpm \ - ~/Library/Caches/com.apple.dt.Xcode \ - ~/Library/Developer/Xcode/DerivedData \ - examples/demo-apps/apple_ios/LLaMA/LLaMA.xcodeproj/project.xcworkspace/xcshareddata/swiftpm -``` - -The command above will clear all the package cache, and when you re-open the XCode project, it should re-download the latest package and link them correctly. - #### (Optional) Changing the prebuilt package version While we recommended using the latest prebuilt package pre-configured with the XCode project, you can also change the package version manually to your desired version. Go to Project Navigator, click on LLaMA. `Project --> LLaMA --> Package Dependencies`, and update the package dependencies to any of the available options below: -- Branch --> swiftpm-0.5.0.20250228 (amend to match the latest nightly build) +- Branch --> swiftpm-0.6.0.20250501 (amend to match the latest nightly build) +- Branch --> swiftpm-0.6.0 - Branch --> swiftpm-0.5.0 -- Branch --> swiftpm-0.4.0 ### 2.2 Manually build the package locally and link them diff --git a/examples/demo-apps/react-native/rnllama/README.md b/examples/demo-apps/react-native/rnllama/README.md index 33c607d635f..e08e3820cd8 100644 --- a/examples/demo-apps/react-native/rnllama/README.md +++ b/examples/demo-apps/react-native/rnllama/README.md @@ -20,7 +20,7 @@ A React Native mobile application for running LLaMA language models using ExecuT ## Installation -1. Clone the repository: `git clone git@github.com:pytorch/executorch.git` +1. Clone the repository: `git clone -b release/0.6 git@github.com:pytorch/executorch.git` 2. Navigate to the root of the repository: `cd executorch` diff --git a/examples/demo-apps/react-native/rnllama/ios/rnllama.xcodeproj/project.pbxproj b/examples/demo-apps/react-native/rnllama/ios/rnllama.xcodeproj/project.pbxproj index 612dd410a1a..ea08f8cf772 100644 --- a/examples/demo-apps/react-native/rnllama/ios/rnllama.xcodeproj/project.pbxproj +++ b/examples/demo-apps/react-native/rnllama/ios/rnllama.xcodeproj/project.pbxproj @@ -947,7 +947,7 @@ isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/pytorch/executorch.git"; requirement = { - branch = "swiftpm-0.5.0.20250228"; + branch = "swiftpm-0.6.0"; kind = branch; }; }; diff --git a/examples/llm_pte_finetuning/README.md b/examples/llm_pte_finetuning/README.md index bdd317109e5..8aeea31608c 100644 --- a/examples/llm_pte_finetuning/README.md +++ b/examples/llm_pte_finetuning/README.md @@ -7,7 +7,7 @@ In this tutorial, we show how to fine-tune an LLM using executorch. You will need to have a model's checkpoint, in the Hugging Face format. For example: ```console -git clone git clone https://huggingface.co/Qwen/Qwen2-0.5B-Instruct +git clone https://huggingface.co/Qwen/Qwen2-0.5B-Instruct ``` You will need to install [torchtune](https://github.com/pytorch/torchtune) following [its installation instructions](https://github.com/pytorch/torchtune?tab=readme-ov-file#installation). diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeTensorValue.h b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeTensorValue.h deleted file mode 100644 index 103f0781017..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeTensorValue.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#ifdef __cplusplus - #import - #import -#endif - -NS_ASSUME_NONNULL_BEGIN - -@interface ExecutorchRuntimeTensorValue : NSObject - -@property (nonatomic, readonly) NSArray *shape; - -- (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; - -- (instancetype)initWithFloatArray:(NSArray *)floatArray shape:(NSArray *)sizes NS_SWIFT_NAME(init(floatArray:shape:)); - -#ifdef __cplusplus -- (nullable instancetype)initWithTensor:(torch::executor::Tensor)tensor error:(NSError * _Nullable * _Nullable)error; -- (instancetype)initWithData:(std::vector)floatData - shape:(std::vector)shape NS_DESIGNATED_INITIALIZER; -- (torch::executor::Tensor)backedValue; -#endif - -#pragma mark - -- (NSArray * _Nullable)floatArrayAndReturnError:(NSError * _Nullable * _Nullable)error; - -@end - -NS_ASSUME_NONNULL_END diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeTensorValue.mm b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeTensorValue.mm deleted file mode 100644 index cb3dcddb45f..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeTensorValue.mm +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "ExecutorchRuntimeTensorValue.h" - -#import - -#import - -using torch::executor::TensorImpl; -using torch::executor::ScalarType; - -@implementation ExecutorchRuntimeTensorValue -{ - std::unique_ptr _tensor; - // TensorImpl DOES NOT take ownership. - // This float vector is what keeps the data in memory. - std::vector _floatData; - std::vector _shape; -} - -- (instancetype)initWithData:(std::vector)floatData - shape:(std::vector)shape -{ - if (self = [super init]) { - _floatData.assign(floatData.begin(), floatData.end()); - _shape.assign(shape.begin(), shape.end()); - _tensor = std::make_unique(ScalarType::Float, std::size(_shape), _shape.data(), _floatData.data()); - } - return self; -} - -- (instancetype)initWithFloatArray:(NSArray *)floatArray shape:(NSArray *)shape -{ - std::vector floatVector; - std::vector shapeVector; - - floatVector.reserve(floatArray.count); - for (int i = 0; i < floatArray.count; i++) { - floatVector.push_back([floatArray[i] floatValue]); - } - shapeVector.reserve(shape.count); - for (int i = 0; i < shape.count; i++) { - shapeVector.push_back([shape[i] intValue]); - } - - return [self initWithData:floatVector shape:shapeVector]; -} - -- (nullable instancetype)initWithTensor:(torch::executor::Tensor)tensor error:(NSError * _Nullable * _Nullable)error -{ - if (tensor.scalar_type() != ScalarType::Float) { - if (error) { - *error = [NSError - errorWithDomain:@"ExecutorchRuntimeEngine" - code:(NSInteger)executorch::runtime::Error::InvalidArgument - userInfo: @{NSDebugDescriptionErrorKey: [NSString stringWithFormat:@"Invalid type: torch::executor::ScalarType::%hhd, expected torch::executor::ScalarType::Float", tensor.scalar_type()]}]; - } - return nil; - } - - std::vector floatVector; - std::vector shapeVector; - shapeVector.assign(tensor.sizes().begin(), tensor.sizes().end()); - floatVector.assign(tensor.const_data_ptr(), tensor.const_data_ptr() + tensor.numel()); - return [self initWithData:floatVector shape:shapeVector]; -} - -- (NSArray *)shape -{ - const auto sizes = _tensor->sizes(); - std::vector tensorSizes(sizes.begin(), sizes.end()); - - NSMutableArray *sizesArray = [[NSMutableArray alloc] initWithCapacity:tensorSizes.size()]; - for (int &tensorSize : tensorSizes) { - [sizesArray addObject:@(tensorSize)]; - } - - return sizesArray; -} - -- (NSArray * _Nullable)floatArrayAndReturnError:(NSError * _Nullable * _Nullable)error { - if (_tensor->scalar_type() == torch::executor::ScalarType::Float) { - const auto *tensorPtr = _tensor->data(); - const auto sizes = _tensor->sizes(); - std::vector tensorVec(tensorPtr, tensorPtr + _tensor->numel()); - std::vector tensorSizes(sizes.begin(), sizes.end()); - - NSMutableArray *floatArray = [[NSMutableArray alloc] initWithCapacity:tensorVec.size()]; - for (float &i : tensorVec) { - [floatArray addObject:@(i)]; - } - return floatArray; - } - - if (error) { - *error = [NSError - errorWithDomain:@"ExecutorchRuntimeEngine" - code:(NSInteger)executorch::runtime::Error::InvalidArgument - userInfo: @{NSDebugDescriptionErrorKey: [NSString stringWithFormat:@"Invalid type: torch::executor::ScalarType::%hhd, expected torch::executor::ScalarType::Float", _tensor->scalar_type()]}]; - } - - return nil; -} - -- (torch::executor::Tensor)backedValue -{ - return torch::executor::Tensor(_tensor.get()); -} - -@end diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.h b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.h deleted file mode 100644 index fc1c2c4a35f..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#ifdef __cplusplus - #import - #import -#endif - -#import "ExecutorchRuntimeTensorValue.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface ExecutorchRuntimeValue : NSObject - -- (instancetype)init NS_UNAVAILABLE; -+ (instancetype)new NS_UNAVAILABLE; - -- (instancetype)initWithTensor:(ExecutorchRuntimeTensorValue *)tensorValue; - -#ifdef __cplusplus -- (instancetype)initWithEValue:(torch::executor::EValue)value NS_DESIGNATED_INITIALIZER; -- (torch::executor::EValue)getBackedValue; -#endif - -#pragma mark - -- (ExecutorchRuntimeTensorValue *_Nullable)asTensorValueAndReturnError:(NSError * _Nullable * _Nullable)error; - -@end - -NS_ASSUME_NONNULL_END diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.mm b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.mm deleted file mode 100644 index 9cedc6d2afc..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/Data/ExecutorchRuntimeValue.mm +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "ExecutorchRuntimeValue.h" - -#import -#import - -#import "ExecutorchRuntimeTensorValue.h" - -using torch::executor::EValue; - -@implementation ExecutorchRuntimeValue -{ - EValue _value; - // IMPORTANT - // Tensor value keeps a reference to the original tensor value. However, the value that is wrapped by LiteInterpreterRuntimeTensorValue DOES NOT TAKE OWNERSHIP OF THE RAW DATA! - // This means once the wrapper is deallocated, the tensor value will be deallocated as well. - // This reference here is to keep the tensor value alive until the runtime is deallocated. - ExecutorchRuntimeTensorValue *_tensorValue; -} - -- (instancetype)initWithEValue:(EValue)value -{ - if (self = [super init]) { - _value = value; - } - return self; -} - -- (instancetype)initWithTensor:(ExecutorchRuntimeTensorValue *)tensorValue -{ - if (self = [self initWithEValue:EValue([tensorValue backedValue])]) { - _tensorValue = tensorValue; - } - return self; -} - -- (nullable ExecutorchRuntimeTensorValue *)asTensorValueAndReturnError:(NSError * _Nullable * _Nullable)error -{ - if (_value.isTensor()) { - return [[ExecutorchRuntimeTensorValue alloc] initWithTensor:_value.toTensor() error:error]; - } - - if (error) { - *error = [NSError - errorWithDomain:@"ExecutorchRuntimeEngine" - code:static_cast(executorch::runtime::Error::InvalidArgument) - userInfo: @{NSDebugDescriptionErrorKey: [NSString stringWithFormat:@"Invalid type: Tag::%d, expected Tag::Tensor", _value.tag]}]; - } - return nil; -} - -- (EValue)getBackedValue -{ - return _value; -} - -@end diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/ExecutorchRuntimeEngine.h b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/ExecutorchRuntimeEngine.h deleted file mode 100644 index a03f6b3c62f..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/ExecutorchRuntimeEngine.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import "ExecutorchRuntimeValue.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface ExecutorchRuntimeEngine : NSObject - -- (nonnull instancetype)init NS_UNAVAILABLE; -+ (nonnull instancetype)new NS_UNAVAILABLE; - -- (nullable instancetype)initWithModelPath:(NSString *)modelPath - modelMethodName:(NSString *)modelMethodName - error:(NSError * _Nullable * _Nullable)error NS_DESIGNATED_INITIALIZER; - -- (nullable NSArray *)infer:(NSArray *)values - error:(NSError * _Nullable * _Nullable)error NS_SWIFT_NAME(infer(input:)); - -@end - -NS_ASSUME_NONNULL_END diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/ExecutorchRuntimeEngine.mm b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/ExecutorchRuntimeEngine.mm deleted file mode 100644 index 756ca94f114..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/Exported/ExecutorchRuntimeEngine.mm +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import "ExecutorchRuntimeEngine.h" - -#import -#import - -#import - -@implementation ExecutorchRuntimeEngine -{ - NSString *_modelPath; - NSString *_modelMethodName; - std::unique_ptr _module; -} - -- (instancetype)initWithModelPath:(NSString *)modelPath - modelMethodName:(NSString *)modelMethodName - error:(NSError **)error -{ - if (self = [super init]) { - _modelPath = modelPath; - _modelMethodName = modelMethodName; - _module = std::make_unique(modelPath.UTF8String); - const auto e = _module->load_method(modelMethodName.UTF8String); - if (e != executorch::runtime::Error::Ok) { - if (error) { - *error = [NSError errorWithDomain:@"ExecutorchRuntimeEngine" - code:(NSInteger)e - userInfo:nil]; - } - return nil; - } - } - return self; -} - -- (nullable NSArray *)infer:(NSArray *)values - error:(NSError **)error -{ - std::vector inputEValues; - inputEValues.reserve(values.count); - for (ExecutorchRuntimeValue *inputValue in values) { - inputEValues.push_back([inputValue getBackedValue]); - } - const auto result = _module->execute(_modelMethodName.UTF8String, inputEValues); - if (!result.ok()) { - if (error) { - *error = [NSError errorWithDomain:@"ExecutorchRuntimeEngine" - code:(NSInteger)result.error() - userInfo:nil]; - } - return nil; - } - NSMutableArray *const resultValues = [NSMutableArray new]; - for (const auto &evalue : result.get()) { - [resultValues addObject:[[ExecutorchRuntimeValue alloc] initWithEValue:evalue]]; - } - return resultValues; -} - -@end diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeEngineTests.mm b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeEngineTests.mm deleted file mode 100644 index 23bc59396b2..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeEngineTests.mm +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface ExecutorchRuntimeEngineTests : XCTestCase -@end - -@implementation ExecutorchRuntimeEngineTests - -- (void)testInvalidModel -{ - NSString *const modelPath = @"invalid_model_path"; - - NSError *runtimeInitError = nil; - ExecutorchRuntimeEngine *const engine = [[ExecutorchRuntimeEngine alloc] initWithModelPath:modelPath modelMethodName:@"forward" error:&runtimeInitError]; - XCTAssertNil(engine); - XCTAssertNotNil(runtimeInitError); - - XCTAssertEqual(runtimeInitError.code, 34); - // 34 is the code for AccessFailed. -} - -- (void)testValidModel -{ - NSBundle *const bundle = [NSBundle bundleForClass:[self class]]; - // This is a simple model that adds two tensors. - NSString *const modelPath = [bundle pathForResource:@"add" ofType:@"pte"]; - NSError *runtimeInitError = nil; - ExecutorchRuntimeEngine *const engine = [[ExecutorchRuntimeEngine alloc] initWithModelPath:modelPath modelMethodName:@"forward" error:&runtimeInitError]; - XCTAssertNotNil(engine); - XCTAssertNil(runtimeInitError); - - ExecutorchRuntimeTensorValue *inputTensor = [[ExecutorchRuntimeTensorValue alloc] initWithFloatArray:@[@2.0] shape:@[@1]]; - ExecutorchRuntimeValue *inputValue = [[ExecutorchRuntimeValue alloc] initWithTensor:inputTensor]; - - NSError *inferenceError = nil; - const auto output = [engine infer:@[inputValue, inputValue] error:&inferenceError]; - XCTAssertNil(inferenceError); - - XCTAssertEqual(output.count, 1); - NSError *tensorValueError = nil; - NSError *floatRepresentationError = nil; - const auto tensorValue = [output.firstObject asTensorValueAndReturnError:&tensorValueError]; - const auto resultFloatArray = [tensorValue floatArrayAndReturnError:&floatRepresentationError]; - const auto resultShape = tensorValue.shape; - - XCTAssertNil(tensorValueError); - XCTAssertNil(floatRepresentationError); - XCTAssertEqual(resultFloatArray.count, 1); - XCTAssertEqual(resultShape.count, 1); - XCTAssertEqual(resultFloatArray.firstObject.floatValue, 4.0); - XCTAssertEqual(resultShape.firstObject.integerValue, 1); -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeValueTests.mm b/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeValueTests.mm deleted file mode 100644 index c3d3599fef2..00000000000 --- a/extension/apple/ExecutorchRuntimeBridge/ExecutorchRuntimeBridge/__tests__/ExecutorchRuntimeValueTests.mm +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. - */ - -#import - -#import -#import - -using torch::executor::EValue; -using torch::executor::TensorImpl; -using torch::executor::ScalarType; - -@interface ExecutorchRuntimeValueTests : XCTestCase -@end - -@implementation ExecutorchRuntimeValueTests - -- (void)testTensorValue -{ - NSMutableArray *data = [NSMutableArray new]; - for (int i = 0; i < 10; i++) { - [data addObject:@(i + 0.5f)]; - } - - NSArray *shape = @[@(10)]; - - ExecutorchRuntimeTensorValue *tensorValue = [[ExecutorchRuntimeTensorValue alloc] initWithFloatArray:data shape:shape]; - - const auto floatArray = [tensorValue floatArrayAndReturnError:nil]; - const auto shapeArray = [tensorValue shape]; - - XCTAssertEqualObjects(floatArray, data); - XCTAssertEqualObjects(shapeArray, shape); -} - -- (void)testTensorValueWithFloatArrayWithError -{ - std::vector data = {1, 2, 3}; - std::vector shape = {3}; - TensorImpl tensorImpl(ScalarType::Int, std::size(shape), shape.data(), data.data()); - - XCTAssertNil([[ExecutorchRuntimeTensorValue alloc] initWithTensor:*new torch::executor::Tensor(&tensorImpl) error:nil]); - NSError *error = nil; - XCTAssertNil([[ExecutorchRuntimeTensorValue alloc] initWithTensor:*new torch::executor::Tensor(&tensorImpl) error:&error]); - XCTAssertNotNil(error); - XCTAssertEqual(error.code, static_cast(executorch::runtime::Error::InvalidArgument)); - XCTAssertEqualObjects(error.userInfo[NSDebugDescriptionErrorKey], @"Invalid type: torch::executor::ScalarType::3, expected torch::executor::ScalarType::Float"); -} - -- (void)testTensorValueWithError -{ - ExecutorchRuntimeValue *value = [[ExecutorchRuntimeValue alloc] initWithEValue:EValue((int64_t)1)]; - XCTAssertNil([value asTensorValueAndReturnError:nil]); - NSError *error = nil; - XCTAssertNil([value asTensorValueAndReturnError:&error]); - XCTAssertNotNil(error); - XCTAssertEqual(error.code, static_cast(executorch::runtime::Error::InvalidArgument)); - XCTAssertEqualObjects(error.userInfo[NSDebugDescriptionErrorKey], @"Invalid type: Tag::4, expected Tag::Tensor"); -} - -@end diff --git a/extension/benchmark/apple/Benchmark/README.md b/extension/benchmark/apple/Benchmark/README.md index e993ae4f970..5f54f5bd30f 100644 --- a/extension/benchmark/apple/Benchmark/README.md +++ b/extension/benchmark/apple/Benchmark/README.md @@ -24,8 +24,7 @@ It provides a flexible framework for dynamically generating and running performa To get started, clone the ExecuTorch repository and cd into the source code directory: ```bash -git clone https://github.com/pytorch/executorch.git --depth 1 --recurse-submodules --shallow-submodules -cd executorch +git clone -b release/0.6 https://github.com/pytorch/executorch.git && cd executorch ``` This command performs a shallow clone to speed up the process. diff --git a/install_executorch.py b/install_executorch.py index 85703903ffc..491ba19dec1 100644 --- a/install_executorch.py +++ b/install_executorch.py @@ -17,11 +17,7 @@ from contextlib import contextmanager from typing import List, Tuple -from install_requirements import ( - install_requirements, - python_is_compatible, - TORCH_NIGHTLY_URL, -) +from install_requirements import install_requirements, python_is_compatible, TORCH_URL # Set up logging logging.basicConfig( @@ -260,7 +256,7 @@ def main(args): "--no-build-isolation", "-v", "--extra-index-url", - TORCH_NIGHTLY_URL, + TORCH_URL, ], check=True, ) diff --git a/install_requirements.py b/install_requirements.py index 4b3de68b8db..a0e4c65cb90 100644 --- a/install_requirements.py +++ b/install_requirements.py @@ -59,8 +59,7 @@ def python_is_compatible(): # The pip repository that hosts nightly torch packages. -TORCH_NIGHTLY_URL = "https://download.pytorch.org/whl/nightly/cpu" - +TORCH_URL = "https://download.pytorch.org/whl/test/cpu" # Since ExecuTorch often uses main-branch features of pytorch, only the nightly # pip versions will have the required features. @@ -80,16 +79,14 @@ def install_requirements(use_pytorch_nightly): # Setting use_pytorch_nightly to false to test the pinned PyTorch commit. Note # that we don't need to set any version number there because they have already # been installed on CI before this step, so pip won't reinstall them - f"torch==2.7.0.{NIGHTLY_VERSION}" if use_pytorch_nightly else "torch", + "torch==2.7.0" if use_pytorch_nightly else "torch", ( - f"torchvision==0.22.0.{NIGHTLY_VERSION}" - if use_pytorch_nightly - else "torchvision" + "torchvision==0.22.0" if use_pytorch_nightly else "torchvision" ), # For testing. ] EXAMPLES_REQUIREMENTS = [ - f"torchaudio==2.6.0.{NIGHTLY_VERSION}" if use_pytorch_nightly else "torchaudio", + "torchaudio==2.7.0" if use_pytorch_nightly else "torchaudio", ] # Assemble the list of requirements to actually install. @@ -110,7 +107,7 @@ def install_requirements(use_pytorch_nightly): "requirements-dev.txt", *REQUIREMENTS_TO_INSTALL, "--extra-index-url", - TORCH_NIGHTLY_URL, + TORCH_URL, ], check=True, ) diff --git a/pyproject.toml b/pyproject.toml index b2bd5c06944..e429d8fefff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "cmake", # For building binary targets in the wheel. + "cmake<4.0.0", # For building binary targets in the wheel. 4.0.0 breaks third-party CMake build so temporarily pin the version. "pip>=23", # For building the pip package. "pyyaml", # Imported by the kernel codegen tools. "setuptools>=63", # For building the pip package contents. diff --git a/requirements-dev.txt b/requirements-dev.txt index c79f93d0568..a05cf6fa149 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ -cmake>=3.19 # For building binary targets in the wheel. +cmake>=3.19, <4.0.0 # For building binary targets in the wheel. pip>=23 # For building the pip package. pyyaml # Imported by the kernel codegen tools. setuptools>=63 # For building the pip package contents. diff --git a/scripts/test_ios.sh b/scripts/test_ios.sh index 09461e0953e..b93d3378ff8 100755 --- a/scripts/test_ios.sh +++ b/scripts/test_ios.sh @@ -47,7 +47,7 @@ say() { say "Cloning the Code" pushd . > /dev/null -git clone https://github.com/pytorch/executorch.git "$OUTPUT" +git clone -b release/0.6 https://github.com/pytorch/executorch.git "$OUTPUT" cd "$OUTPUT" say "Updating the Submodules"