Skip to content

Conversation

SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Apr 22, 2025

Summary:

Changes

Modified the CMakeLists.txt of test targets to be able to build for Android.

Apply SPIR-V optimization when building Vulkan compute shaders.

Test Plan:

Test Plan

Built and ran test binaries on local Android device.

After installing main ET C++ libs for Android...

Build compute_api_test binary.

pp cmake backends/vulkan/test \
  -DCMAKE_INSTALL_PREFIX=cmake-android-out \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-28 \
  -DPYTHON_EXECUTABLE=python \
  -DCMAKE_BUILD_TYPE=Release \
  -Bcmake-android-out/backends/vulkan/test && \
cmake --build cmake-android-out/backends/vulkan/test -j16 --config Release

Push and run on device:

adb -s $IP push cmake-android-out/backends/vulkan/test/vulkan_compute_api_test /data/local/tmp/test_bin && \
adb -s $IP shell /data/local/tmp/test_bin \
    --gtest_filter="*add*"

Build the operator test binaries:

rm -rf cmake-out/backends/vulkan/test/op_tests && \
pp cmake backends/vulkan/test/op_tests \
  -DCMAKE_INSTALL_PREFIX=cmake-android-out \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-28 \
  -DPYTHON_EXECUTABLE=python \
  -DCMAKE_BUILD_TYPE=Release \
  -DTORCH_OPS_YAML_PATH=/home/ssjia/Github/pytorch/aten/src/ATen/native \
  -DTORCH_INSTALL_PREFIX=/home/ssjia/Github/pytorch/build_android \
  -Bcmake-android-out/backends/vulkan/test/op_tests && \
cmake --build cmake-android-out/backends/vulkan/test/op_tests -j16 --config Release

Push and run on device. Note that these binaries require libtorch so files to be pushed to the device as well.


# Push torch libs
adb -s $IP push /home/ssjia/Github/pytorch/build_android/lib/libtorch.so /data/local/tmp/ && \
adb -s $IP push /home/ssjia/Github/pytorch/build_android/lib/libtorch_cpu.so /data/local/tmp/ && \
adb -s $IP push /home/ssjia/Github/pytorch/build_android/lib/libc10.so /data/local/tmp/ && \
adb push $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/18/lib/linux/aarch64/libomp.so /data/local/tmp/libomp.so


adb -s $IP push cmake-android-out/backends/vulkan/test/op_tests/vulkan_linear_weight_int4_test /data/local/tmp/test_bin && \
adb -s $IP shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/test_bin

@pytorch-bot pytorch-bot bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Apr 22, 2025
Copy link

pytorch-bot bot commented Apr 22, 2025

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/10368

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 5 Pending

As of commit 52390a7 with merge base b52ad91 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 22, 2025
@SS-JIA SS-JIA added the release notes: vulkan Changes to the Vulkan backend delegate label Apr 22, 2025
Summary:
## Changes

Modified the `CMakeLists.txt` of test targets to be able to build for Android.

Apply SPIR-V optimization when building Vulkan compute shaders.

Test Plan:
## Test Plan

Built and ran test binaries on local Android device.

After installing main ET C++ libs for Android...


Build compute_api_test binary.

```
pp cmake backends/vulkan/test \
  -DCMAKE_INSTALL_PREFIX=cmake-android-out \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-28 \
  -DPYTHON_EXECUTABLE=python \
  -DCMAKE_BUILD_TYPE=Release \
  -Bcmake-android-out/backends/vulkan/test && \
cmake --build cmake-android-out/backends/vulkan/test -j16 --config Release
```

Push and run on device:

```
adb -s $IP push cmake-android-out/backends/vulkan/test/vulkan_compute_api_test /data/local/tmp/test_bin && \
adb -s $IP shell /data/local/tmp/test_bin \
    --gtest_filter="*add*"
```

Build the operator test binaries:

```
rm -rf cmake-out/backends/vulkan/test/op_tests && \
pp cmake backends/vulkan/test/op_tests \
  -DCMAKE_INSTALL_PREFIX=cmake-android-out \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_PLATFORM=android-28 \
  -DPYTHON_EXECUTABLE=python \
  -DCMAKE_BUILD_TYPE=Release \
  -DTORCH_OPS_YAML_PATH=/home/ssjia/Github/pytorch/aten/src/ATen/native \
  -DTORCH_INSTALL_PREFIX=/home/ssjia/Github/pytorch/build_android \
  -Bcmake-android-out/backends/vulkan/test/op_tests && \
cmake --build cmake-android-out/backends/vulkan/test/op_tests -j16 --config Release
```

Push and run on device. Note that these binaries require `libtorch` so files to be pushed to the device as well.

```

# Push torch libs
adb -s $IP push /home/ssjia/Github/pytorch/build_android/lib/libtorch.so /data/local/tmp/ && \
adb -s $IP push /home/ssjia/Github/pytorch/build_android/lib/libtorch_cpu.so /data/local/tmp/ && \
adb -s $IP push /home/ssjia/Github/pytorch/build_android/lib/libc10.so /data/local/tmp/ && \
adb push $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/18/lib/linux/aarch64/libomp.so /data/local/tmp/libomp.so


adb -s $IP push cmake-android-out/backends/vulkan/test/op_tests/vulkan_linear_weight_int4_test /data/local/tmp/test_bin && \
adb -s $IP shell LD_LIBRARY_PATH=/data/local/tmp /data/local/tmp/test_bin
```
@SS-JIA SS-JIA merged commit b71f03c into main Apr 22, 2025
89 checks passed
@SS-JIA SS-JIA deleted the pr10368 branch April 22, 2025 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ release notes: vulkan Changes to the Vulkan backend delegate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants