Commit 52390a7
Sicheng Jia
[ET-VK][ez] Enable Vulkan tests to build for Android in OSS + misc fixes
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
```1 parent b52ad91 commit 52390a7
File tree
3 files changed
+25
-18
lines changed- backends/vulkan
- cmake
- test
- op_tests
3 files changed
+25
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | | - | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
23 | 28 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
31 | 36 | | |
32 | 37 | | |
33 | 38 | | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
41 | 42 | | |
42 | | - | |
43 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
91 | | - | |
| 94 | + | |
92 | 95 | | |
93 | 96 | | |
94 | 97 | | |
| |||
0 commit comments