Description
🐛 Describe the bug
Hi, I tried to build an Android app using executorch, I firstly cross compile executorch with xnnpack on:
cmake -DCMAKE_TOOLCHAIN_FILE="/home/user/src/android-ndk-r25c/build/cmake/android.toolchain.cmake"\
-DCMAKE_INSTALL_PREFIX=/home/user/torch/executorch/arm64xnninstall \
-DANDROID_ABI="arm64-v8a" \
-DEXECUTORCH_BUILD_XNNPACK=ON \
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
..
cmake --build ./ -j12 --target install
Then I use a cpp file:
#include <iostream>
#include <executorch/extension/module/module.h>
using namespace torch::executor;
int main()
{
Module module("./model.pte");
float input[3*4];
Tensor::SizesType sizes[]={3,4};
TensorImpl tensor(ScalarType::Float,12,sizes,input);
const auto result = module.forward({EValue(Tensor(&tensor))});
}
and the CMakeLists.txt is:
cmake_minimum_required(VERSION 3.4.1)
set(PROJECT_NAME torchtest)
project(${PROJECT_NAME})
set(CMAKE_CXX_STANDARD 17)
include_directories(
/home/user/torch/
/home/user/torch/executorch/arm64install/include/executorch/kernels/portable
)
link_directories(
/home/user/torch/executorch/arm64xnninstall/lib
)
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME}
libexecutorch.a
libextension_module.a
libextension_data_loader.a
libexecutorch_no_prim_ops.a
libextension_module_static.a
libportable_kernels.a
libportable_ops_lib.a
libpthreadpool.a
libxnnpack_backend.a
)
target_link_options(${PROJECT_NAME} PRIVATE -fPIC )
Then use the following script to build:
cmake -DCMAKE_TOOLCHAIN_FILE="/home/user/src/android-ndk-r25c/build/cmake/android.toolchain.cmake"\
-DCMAKE_BUILD_TYPE="Release" \
-DANDROID_ABI="arm64-v8a" \
..
make
I use 'adb push' to deploy the output of this project on Android phone, but after running it, I get the error:
could you please tell me how to fix it? Thanks!
Versions
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Clang version: 10.0.0-4ubuntu1
CMake version: version 3.30.2
Libc version: glibc-2.31
Python version: 3.9.13 (main, Aug 25 2022, 23:26:10) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.31
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4060 Ti
Nvidia driver version: 551.61
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A
CPU:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
Address sizes: 46 bits physical, 48 bits virtual
CPU(s): 20
On-line CPU(s) list: 0-19
Thread(s) per core: 2
Core(s) per socket: 10
Socket(s): 1
Vendor ID: GenuineIntel
CPU family: 6
Model: 183
Model name: 13th Gen Intel(R) Core(TM) i5-13600K
Stepping: 1
CPU MHz: 3494.399
BogoMIPS: 6988.79
Virtualization: VT-x
Hypervisor vendor: Microsoft
Virtualization type: full
L1d cache: 480 KiB
L1i cache: 320 KiB
L2 cache: 20 MiB
L3 cache: 24 MiB
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Unknown: No mitigations
Vulnerability Retbleed: Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm serialize flush_l1d arch_capabilities
Versions of relevant libraries:
[pip3] executorch==0.3.0a0+7d77d78
[pip3] numpy==2.1.0
[pip3] torch==2.4.0+cpu
[pip3] torchaudio==2.4.0+cpu
[pip3] torchsr==1.0.4
[pip3] torchvision==0.19.0
[conda] executorch 0.3.0a0+7d77d78 pypi_0 pypi
[conda] numpy 2.1.0 pypi_0 pypi
[conda] torch 2.4.0+cpu pypi_0 pypi
[conda] torchaudio 2.4.0+cpu pypi_0 pypi
[conda] torchsr 1.0.4 pypi_0 pypi
[conda] torchvision 0.19.0 pypi_0 pypi