From a1a3dbec07236a624580966daf6ed6aecfa8faca Mon Sep 17 00:00:00 2001 From: Hansong Zhang <107070759+kirklandsign@users.noreply.github.com> Date: Thu, 25 Sep 2025 10:09:35 -0700 Subject: [PATCH 1/3] Android use new glslc (#14596) Validated by workflow https://github.com/pytorch/executorch/actions/runs/18013292360 Currently download SDK each time when we build vulkan AAR. Co-authored-by: Stephen Jia --- .../workflows/android-release-artifacts.yml | 3 +++ backends/vulkan/cmake/ShaderLibrary.cmake | 25 ++++++++----------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/android-release-artifacts.yml b/.github/workflows/android-release-artifacts.yml index 89e604c75f3..1b746e37166 100644 --- a/.github/workflows/android-release-artifacts.yml +++ b/.github/workflows/android-release-artifacts.yml @@ -94,6 +94,9 @@ jobs: FLAVOR="${{ inputs.flavor }}" if [[ "$FLAVOR" == "vulkan+xnnpack" || -z "$FLAVOR" ]]; then + curl -O https://sdk.lunarg.com/sdk/download/1.4.321.1/linux/vulkansdk-linux-x86_64-1.4.321.1.tar.xz + tar xf vulkansdk-linux-x86_64-1.4.321.1.tar.xz -C /tmp + export PATH="/tmp/1.4.321.1/x86_64/bin:$PATH" export EXECUTORCH_BUILD_VULKAN=ON fi diff --git a/backends/vulkan/cmake/ShaderLibrary.cmake b/backends/vulkan/cmake/ShaderLibrary.cmake index 1b6838c4dfd..16a60abf6f3 100644 --- a/backends/vulkan/cmake/ShaderLibrary.cmake +++ b/backends/vulkan/cmake/ShaderLibrary.cmake @@ -24,22 +24,17 @@ if(NOT EXECUTORCH_ROOT) message("WARNING: EXECUTORCH_ROOT is not set! A failure is likely imminent.") endif() -if(ANDROID) - if(NOT ANDROID_NDK) - message(FATAL_ERROR "ANDROID_NDK not set") - endif() - - if(NOT GLSLC_PATH) - set(GLSLC_PATH - "${ANDROID_NDK}/shader-tools/${ANDROID_NDK_HOST_SYSTEM_NAME}/glslc" - ) - endif() -else() - find_program(GLSLC_PATH glslc PATHS $ENV{PATH}) +find_program(GLSLC_PATH glslc PATHS $ENV{PATH}) - if(NOT GLSLC_PATH) - message(FATAL_ERROR "USE_VULKAN glslc not found") - endif() +if(NOT GLSLC_PATH) + message( + FATAL_ERROR + "glslc from the Vulkan SDK must be installed to build the Vulkan backend. " + "Please install the Vulkan SDK 1.4.321.0 or newer from " + "https://vulkan.lunarg.com/sdk/home and ensure that the glslc binary is in your PATH. " + "Note that the glslc distributed with the Android NDK is not compatible since it " + "does not support the GL_EXT_integer_dot_product extension. " + ) endif() # Required to enable linking with --whole-archive From 2e77313059b9a28a965b25d69d6d97cd093ea30e Mon Sep 17 00:00:00 2001 From: Hansong Zhang <107070759+kirklandsign@users.noreply.github.com> Date: Thu, 25 Sep 2025 11:57:31 -0700 Subject: [PATCH 2/3] Support uploading different AAR to S3 (#14605) Now stage AAR upload to https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}-${FLAVOR}/executorch.aar so we can have multiple flavors. Example: https://github.com/pytorch/executorch/actions/runs/18017149226, https://github.com/pytorch/executorch/actions/runs/18017146445 --- .../workflows/android-release-artifacts.yml | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/android-release-artifacts.yml b/.github/workflows/android-release-artifacts.yml index 1b746e37166..6c89aac2ef7 100644 --- a/.github/workflows/android-release-artifacts.yml +++ b/.github/workflows/android-release-artifacts.yml @@ -15,15 +15,11 @@ on: type: choice options: - "xnnpack" - - "vulkan+xnnpack" + - "vulkan" - "qnn" schedule: - cron: 0 10 * * * -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - jobs: check-if-aar-exists: name: check-if-aar-exists @@ -34,12 +30,13 @@ jobs: shell: bash run: | VERSION="${{ inputs.version }}" + FLAVOR="${{ inputs.flavor }}" if [ -z "$VERSION" ]; then echo "No version name specified. Will create a snapshot AAR" exit 0 fi - if curl -I "https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}/executorch.aar" | grep "200 OK"; then - echo "AAR already exists at https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}/executorch.aar" + if curl -I "https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}-${FLAVOR}/executorch.aar" | grep "200 OK"; then + echo "AAR already exists at https://ossci-android.s3.amazonaws.com/executorch/release/${VERSION}-${FLAVOR}/executorch.aar" echo "Will skip build/upload" exit 1 fi @@ -93,7 +90,7 @@ jobs: fi FLAVOR="${{ inputs.flavor }}" - if [[ "$FLAVOR" == "vulkan+xnnpack" || -z "$FLAVOR" ]]; then + if [[ "$FLAVOR" == "vulkan" || -z "$FLAVOR" ]]; then curl -O https://sdk.lunarg.com/sdk/download/1.4.321.1/linux/vulkansdk-linux-x86_64-1.4.321.1.tar.xz tar xf vulkansdk-linux-x86_64-1.4.321.1.tar.xz -C /tmp export PATH="/tmp/1.4.321.1/x86_64/bin:$PATH" @@ -148,8 +145,12 @@ jobs: pip install awscli==1.32.18 AWS_CMD="aws s3 cp" VERSION="${{ inputs.version }}" + FLAVOR="${{ inputs.flavor }}" if [ -z "$VERSION" ]; then VERSION="snapshot-$(date +"%Y%m%d")" fi - ${AWS_CMD} executorch.aar s3://ossci-android/executorch/release/${VERSION}/executorch.aar --acl public-read - ${AWS_CMD} executorch.aar.sha256sums s3://ossci-android/executorch/release/${VERSION}/executorch.aar.sha256sums --acl public-read + if [ -z "$FLAVOR" ]; then + FLAVOR="xnnpack" + fi + ${AWS_CMD} executorch.aar s3://ossci-android/executorch/release/${VERSION}-${FLAVOR}/executorch.aar --acl public-read + ${AWS_CMD} executorch.aar.sha256sums s3://ossci-android/executorch/release/${VERSION}-${FLAVOR}/executorch.aar.sha256sums --acl public-read From f2ba735efc706b89f7bf01300b0fb516e2a8e863 Mon Sep 17 00:00:00 2001 From: Hansong Zhang Date: Thu, 25 Sep 2025 12:16:00 -0700 Subject: [PATCH 3/3] Different maven package names of flavors --- .github/workflows/android-release-artifacts.yml | 4 ++++ extension/android/executorch_android/build.gradle | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/android-release-artifacts.yml b/.github/workflows/android-release-artifacts.yml index 6c89aac2ef7..19b4b2338f2 100644 --- a/.github/workflows/android-release-artifacts.yml +++ b/.github/workflows/android-release-artifacts.yml @@ -90,6 +90,10 @@ jobs: fi FLAVOR="${{ inputs.flavor }}" + if [ ! -z "$FLAVOR" ]; then + GRADLE_ARGS+=" -Dflavor=${FLAVOR}" + fi + if [[ "$FLAVOR" == "vulkan" || -z "$FLAVOR" ]]; then curl -O https://sdk.lunarg.com/sdk/download/1.4.321.1/linux/vulkansdk-linux-x86_64-1.4.321.1.tar.xz tar xf vulkansdk-linux-x86_64-1.4.321.1.tar.xz -C /tmp diff --git a/extension/android/executorch_android/build.gradle b/extension/android/executorch_android/build.gradle index e36044e3da5..0c18d60721e 100644 --- a/extension/android/executorch_android/build.gradle +++ b/extension/android/executorch_android/build.gradle @@ -15,6 +15,7 @@ plugins { def qnnVersion = System.properties['qnnVersion'] def execuTorchVersion = System.properties['execuTorchVersion'] +def flavor = System.properties['flavor'] android { namespace = "org.pytorch.executorch" @@ -69,7 +70,7 @@ mavenPublishing { publishToMavenCentral() signAllPublications() - coordinates("org.pytorch", "executorch-android" + (qnnVersion ? "-qnn" : ""), execuTorchVersion ? execuTorchVersion : "0.7.0-SNAPSHOT") + coordinates("org.pytorch", "executorch-android" + (flavor ? "-" + flavor : ""), execuTorchVersion ? execuTorchVersion : "1.0.0-SNAPSHOT") pom { name = "ExecuTorch Android"