pytorch / executorch

On-device AI across mobile, embedded and edge for PyTorch
https://pytorch.org/executorch/
Other
2.19k stars 359 forks source link

Android native crash when running Executorch Demo with ic4_xnnpack_fp32.pte #5264

Open YuHayring opened 2 months ago

YuHayring commented 2 months ago

🐛 Describe the bug

I built the .so file and .pte file, put them into corrent path. And then I edited the AndroidManifest.xml. Moved the main-intent-filter from MainActivity to ClassificationActivity that the app will launch into ClassificationActivity. I clicked the Run button after the image of the dog was loaded. And after 1s the app crashed.

This is the log of android console loged after crashed:

*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  Build fingerprint: 'samsung/q6qzhx/q6q:14/UP1A.231005.007/F9560ZSS1AXHB:user/release-keys'
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  Revision: '11'
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  ABI: 'arm64'
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  Processor: '7'
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  Timestamp: 2024-09-11 20:35:13.623353922+0800
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  Process uptime: 4s
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  Cmdline: com.example.executorchdemo
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  pid: 9157, tid: 9201, name: DefaultDispatch  >>> com.example.executorchdemo <<<
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  uid: 10437
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  pac_enabled_keys: 000000000000000f (PR_PAC_APIAKEY, PR_PAC_APIBKEY, PR_PAC_APDAKEY, PR_PAC_APDBKEY)
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xb40000791d74f000
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x0  b40000791d6b6600  x1  b40000790a6b1960  x2  0000000000004ec4  x3  0000000000000300
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x4  0000000000000011  x5  0000000000000020  x6  00000000000003b4  x7  0000000000000001
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x8  b40000791d74effc  x9  0000000000013b10  x10 fffffffffffffffe  x11 0000000000000002
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x12 0000000000000300  x13 000000793bad9000  x14 000000793b55c6e0  x15 0000000000000000
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x16 0000000000000001  x17 0000007d61acf820  x18 000000793ed84000  x19 b400007b4f8e22e0
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x20 0000000000000000  x21 b400007b4f8e23a8  x22 00000079800e96e0  x23 00000079800e96e0
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x24 000000793eff92f0  x25 b400007c3f8844a0  x26 000000000000206e  x27 000000798007bfb0
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      x28 000000793eff91c0  x29 000000793eff80e0
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A      lr  00000079386c90e0  sp  000000793eff7840  pc  0000007938952224  pst 0000000060001000
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  69 total frames
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A  backtrace:
2024-09-11 20:35:13.763  9265-9265  DEBUG                   crash_dump64                         A        #00 pc 000000000370f224  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (xnn_x32_transposec_ukernel__4x4_aarch64_neon_tbl128+1072) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #01 pc 00000000034860dc  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (xnn_compute_transposec_2d+176) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #02 pc 000000000388b958  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (thread_parallelize_2d_tile_2d+840) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #03 pc 00000000038950e4  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (pthreadpool_parallelize+876) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #04 pc 000000000388b5dc  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (pthreadpool_parallelize_2d_tile_2d+568) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #05 pc 000000000348f9f8  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (xnn_run_operator_with_index+2572) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #06 pc 0000000003482270  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (xnn_invoke_runtime+216) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #07 pc 0000000000c0e6c4  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (torch::executor::xnnpack::delegate::XNNExecutor::forward(executorch::runtime::BackendExecutionContext&)+452) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #08 pc 0000000000c11614  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (torch::executor::XnnpackBackend::execute(executorch::runtime::BackendExecutionContext&, void*, executorch::runtime::EValue**) const+84) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #09 pc 00000000038b13dc  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (executorch::runtime::BackendDelegate::Execute(executorch::runtime::BackendExecutionContext&, executorch::runtime::EValue**) const+52) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #10 pc 00000000038b0e24  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (executorch::runtime::Method::execute_instruction()+1512) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #11 pc 00000000038b1ea0  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (executorch::runtime::Method::execute()+580) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #12 pc 0000000000c39078  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (executorch::extension::Module::execute(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, std::__ndk1::vector<executorch::runtime::EValue, std::__ndk1::allocator<executorch::runtime::EValue> > const&)+244) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #13 pc 0000000000c1f1f4  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (executorch::extension::ExecuTorchJni::execute_method(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> >, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>)+1452) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #14 pc 0000000000c1e8fc  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (executorch::extension::ExecuTorchJni::forward(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>)+104) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #15 pc 0000000000c1ebb8  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (facebook::jni::detail::MethodWrapper<facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator> (executorch::extension::ExecuTorchJni::*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>), &(executorch::extension::ExecuTorchJni::forward(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>)), executorch::extension::ExecuTorchJni, facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*> >::dispatch(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>&&)+256) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #16 pc 0000000000c346f8  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (facebook::jni::detail::CallWithJniConversions<facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator> (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>&&), facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator>, facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*> >::call(facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*, facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*, facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator> (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>&&))+96) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #17 pc 0000000000c1e9b4  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (facebook::jni::detail::FunctionWrapper<facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator> (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>&&), facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*, facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*> >::call(_JNIEnv*, _jobject*, facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*, facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator> (*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::HybridClass<executorch::extension::ExecuTorchJni, facebook::jni::detail::BaseHybridClass>::JavaPart, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>&&))+64) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #18 pc 0000000000c19348  /data/app/~~6NFkIu4a0aUL1DEJ_tuYww==/com.example.executorchdemo-iLhgMzPUpzlRnbULImXrsQ==/lib/arm64/libexecutorch.so (facebook::jni::detail::MethodWrapper<facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator> (executorch::extension::ExecuTorchJni::*)(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>), &(executorch::extension::ExecuTorchJni::forward(facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*>)), executorch::extension::ExecuTorchJni, facebook::jni::basic_strong_ref<facebook::jni::JArrayClass<executorch::extension::JEValue>, facebook::jni::LocalReferenceAllocator>, facebook::jni::alias_ref<facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*> >::call(_JNIEnv*, _jobject*, facebook::jni::detail::JTypeFor<facebook::jni::JArrayClass<facebook::jni::detail::JTypeFor<executorch::extension::JEValue, facebook::jni::JObject, void>::_javaobject*>, facebook::jni::detail::JTypeArray, void>::_javaobject*)+44) (BuildId: d5b67020f0ffaf4cb5136c25b4b6bb2ee5da1205)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #19 pc 0000000000351e30  /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #20 pc 000000000033b3a4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #21 pc 0000000000511590  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+1976) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #22 pc 0000000000490ffc  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+1012) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #23 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #24 pc 0000000000002330  <anonymous:7d83244000> (org.pytorch.executorch.Module.forward+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #25 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #26 pc 000000000051225c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #27 pc 0000000000490ffc  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+1012) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #28 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #29 pc 000000000000352c  <anonymous:7d773bc000> (com.example.executorchdemo.ClassificationActivity$run$className$1.invokeSuspend+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #30 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #31 pc 000000000051225c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #32 pc 0000000000490ffc  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+1012) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #33 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #34 pc 0000000000180fe8  <anonymous:79c28c6000> (kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #35 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #36 pc 000000000051225c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #37 pc 0000000000491eac  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+4772) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #38 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #39 pc 00000000001c663c  <anonymous:79c28c6000> (kotlinx.coroutines.DispatchedTask.run+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #40 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #41 pc 000000000051225c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #42 pc 0000000000490ffc  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+1012) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #43 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #44 pc 00000000002028b0  <anonymous:79c28c6000> (kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #45 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #46 pc 000000000051225c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #47 pc 0000000000490ffc  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+1012) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #48 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #49 pc 00000000002015a0  <anonymous:79c28c6000> (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #50 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #51 pc 000000000051225c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #52 pc 0000000000491434  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+2092) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #53 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #54 pc 00000000002016b8  <anonymous:79c28c6000> (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #55 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #56 pc 000000000051225c  /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall<false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, bool, art::JValue*)+5252) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #57 pc 0000000000491434  /apex/com.android.art/lib64/libart.so (void art::interpreter::ExecuteSwitchImplCpp<false>(art::interpreter::SwitchImplContext*)+2092) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #58 pc 00000000003545d8  /apex/com.android.art/lib64/libart.so (ExecuteSwitchImplAsm+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #59 pc 00000000002016a0  <anonymous:79c28c6000> (kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run+0)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #60 pc 000000000036e6ec  /apex/com.android.art/lib64/libart.so (art::interpreter::Execute(art::Thread*, art::CodeItemDataAccessor const&, art::ShadowFrame&, art::JValue, bool, bool) (.__uniq.112435418011751916792819755956732575238.llvm.9545667076320299271)+232) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #61 pc 000000000036dfe4  /apex/com.android.art/lib64/libart.so (artQuickToInterpreterBridge+964) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #62 pc 0000000000351f68  /apex/com.android.art/lib64/libart.so (art_quick_to_interpreter_bridge+88) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #63 pc 000000000033b3a4  /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #64 pc 000000000023a5d0  /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+144) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #65 pc 0000000000539b2c  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*)+1600) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #66 pc 00000000005394dc  /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallbackWithUffdGc(void*)+8) (BuildId: 7ece79c15d80914c83e60c9e93ac1684)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #67 pc 00000000000c37b4  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+208) (BuildId: 37f537c2ba9dcbb262a0a68f41a21da4)
2024-09-11 20:35:13.764  9265-9265  DEBUG                   crash_dump64                         A        #68 pc 000000000005d084  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+68) (BuildId: 37f537c2ba9dcbb262a0a68f41a21da4)

This is the top 10 backtrace which was the output of using addr2line program in NDK

xnn_x32_transposec_ukernel__4x4_aarch64_neon_tbl128
<path-to-executorch>/executorch/backends/xnnpack/third-party/XNNPACK/src/amalgam/gen/neon-aarch64.c:431
xnn_compute_transposec_2d
<path-to-executorch>/executorch/backends/xnnpack/third-party/XNNPACK/src/operator-run.c:39
thread_parallelize_2d_tile_2d
<path-to-executorch>/executorch/backends/xnnpack/third-party/pthreadpool/src/portable-api.c:447
pthreadpool_parallelize
<path-to-executorch>/executorch/backends/xnnpack/third-party/pthreadpool/src/pthreads.c:387
pthreadpool_parallelize_2d_tile_2d
<path-to-executorch>/executorch/backends/xnnpack/third-party/pthreadpool/src/portable-api.c:2040
xnn_run_operator_with_index
<path-to-executorch>/executorch/backends/xnnpack/third-party/XNNPACK/src/operator-run.c:3121
xnn_invoke_runtime
<path-to-executorch>/executorch/backends/xnnpack/third-party/XNNPACK/src/runtime.c:1017
_ZN5torch8executor7xnnpack8delegate11XNNExecutor7forwardERN10executorch7runtime23BackendExecutionContextE
<path-to-executorch>/executorch/backends/xnnpack/runtime/XNNExecutor.cpp:154
_ZNK5torch8executor14XnnpackBackend7executeERN10executorch7runtime23BackendExecutionContextEPvPPNS3_6EValueE
<path-to-executorch>/executorch/backends/xnnpack/runtime/XNNPACKBackend.cpp:110
_ZNK10executorch7runtime15BackendDelegate7ExecuteERNS0_23BackendExecutionContextEPPNS0_6EValueE
<path-to-executorch>/executorch/runtime/executor/method.cpp:127
_ZN10executorch7runtime6Method19execute_instructionEv
<path-to-executorch>/executorch/runtime/executor/method.cpp:1110

This is my build script which is user to generate .pte file:

python3 -m examples.xnnpack.aot_compiler --model_name="ic4" --delegate

This is my build script which is used to build .so file:

export ANDROID_ABI=arm64-v8a 
export ANDROID_NDK=<path-to-android-sdk>/ndk/27.1.12297006
rm -rf cmake-android-out && mkdir cmake-android-out 
conda init zsh
source ~/.zshrc
conda activate executorch              
cmake . -DCMAKE_INSTALL_PREFIX=cmake-android-out \
  -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
  -DANDROID_ABI="${ANDROID_ABI}" \
  -DEXECUTORCH_BUILD_XNNPACK=ON \
  -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
  -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
  -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
  -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
  -Bcmake-android-out
cmake --build cmake-android-out -j16 --target install 
cmake extension/android \
  -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}"/build/cmake/android.toolchain.cmake \
  -DANDROID_ABI="${ANDROID_ABI}" \
  -DCMAKE_INSTALL_PREFIX=cmake-android-out \
  -Bcmake-android-out/extension/android
cmake --build cmake-android-out/extension/android -j16
mkdir -p examples/demo-apps/android/ExecuTorchDemo/app/src/main/jniLibs/arm64-v8a
cp cmake-android-out/extension/android/libexecutorch_jni.so \
   examples/demo-apps/android/ExecuTorchDemo/app/src/main/jniLibs/arm64-v8a/libexecutorch.so

Versions

PyTorch version: 2.5.0.dev20240901 Is debug build: False CUDA used to build PyTorch: None ROCM used to build PyTorch: N/A

OS: macOS 14.6.1 (arm64) GCC version: Could not collect Clang version: 15.0.0 (clang-1500.3.9.4) CMake version: version 3.30.2 Libc version: N/A

Python version: 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 10:07:17) [Clang 14.0.6 ] (64-bit runtime) Python platform: macOS-14.6.1-arm64-arm-64bit Is CUDA available: False CUDA runtime version: No CUDA CUDA_MODULE_LOADING set to: N/A GPU models and configuration: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Apple M3

Versions of relevant libraries: [pip3] executorch==0.4.0a0+32d83b0 [pip3] numpy==1.26.4 [pip3] torch==2.5.0.dev20240901 [pip3] torchaudio==2.5.0.dev20240901 [pip3] torchsr==1.0.4 [pip3] torchvision==0.20.0.dev20240901 [conda] executorch 0.4.0a0+32d83b0 pypi_0 pypi [conda] numpy 1.26.4 pypi_0 pypi [conda] torch 2.5.0.dev20240901 pypi_0 pypi [conda] torchaudio 2.5.0.dev20240901 pypi_0 pypi [conda] torchsr 1.0.4 pypi_0 pypi [conda] torchvision 0.20.0.dev20240901 pypi_0 pypi

davidlin54 commented 2 months ago

cc @kirklandsign

kirklandsign commented 2 months ago

This IC4 XNNPACK model runs on linux x86_64 xnn_executor_runner, but not on android arm64-v8a. Something specific to android arm64-v8a

cc @mcr229 @digantdesai

mcr229 commented 2 months ago

@kirklandsign do you have a repro binary/file to test with?

kirklandsign commented 2 months ago

Export model

python3 -m examples.xnnpack.aot_compiler --model_name="ic4" --delegate
export  ANDROID_ABI=arm64-v8a
export ANDROID_NDK=<path-to-ndk>
export CMAKE_OUT="cmake-out-android-${ANDROID_ABI}"
  cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
    -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
    -DANDROID_ABI="${ANDROID_ABI}" \
    -DANDROID_PLATFORM=android-23 \
    -DEXECUTORCH_ENABLE_LOGGING=ON \
    -DEXECUTORCH_LOG_LEVEL=Info \
    -DEXECUTORCH_BUILD_XNNPACK=ON \
    -DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON \
    -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
    -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
    -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
    -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
    -B"${CMAKE_OUT}"

  cmake --build "${CMAKE_OUT}" -j 10 --target install

And you will find cmake-out-android-arm64-v8a/backends/xnnpack/xnn_executor_runner

adb push cmake-out-android-arm64-v8a/backends/xnnpack/xnn_executor_runner /data/local/tmp
adb shell chmod +x /data/local/tmp/xnn_executor_runner
adb push ic4_xnnpack_fp32.pte /data/local/tmp
adb shell /data/local/tmp/xnn_executor_runner --model_path /data/local/tmp/ic4_xnnpack_fp32.pte
kirklandsign commented 1 month ago

FP32 only. Not Q8