I want to deploy an object detection model in C++ with .so exported from TVM.
First i tried to import ONNX’s model assuming TVM can support it very well but soon to find non-success because TVM relay has not supported some operators from ONNX yet.
So i use the SSD model which is in MXNet format from official doc url: https://tvm.apache.org/docs/tutorials/frontend/deploy_ssd_gluoncv.html, and assume: If TVM can import a DL model(from any format), then it should be able to export .so (target=“llvm --system-lib”)
The .so file is exported(with 2 other .params and .json files), and then i use C++ code to try to use it, but failed due to a C++ exception when code trying to get a PackedFunction from model:
‘’’ build % lldb ./TVMCppDeployTest … Process 48178 stopped
- thread #1, queue = ‘com.apple.main-thread’, stop reason = signal SIGABRT
frame #0: 0x00007fff6c5e133a libsystem_kernel.dylib
__pthread_kill + 10 libsystem_kernel.dylib
__pthread_kill: -> 0x7fff6c5e133a <+10>: jae 0x7fff6c5e1344 ; <+20> 0x7fff6c5e133c <+12>: movq %rax, %rdi 0x7fff6c5e133f <+15>: jmp 0x7fff6c5db629 ; cerror_nocancel 0x7fff6c5e1344 <+20>: retq
(lldb) bt - thread #1, queue = ‘com.apple.main-thread’, stop reason = signal SIGABRT
- frame #0: 0x00007fff6c5e133a libsystem_kernel.dylib
__pthread_kill + 10 frame #1: 0x00007fff6c69de60 libsystem_pthread.dylib
pthread_kill + 430 frame #2: 0x00007fff6c568808 libsystem_c.dylibabort + 120 frame #3: 0x00007fff697c7458 libc++abi.dylib
abort_message + 231 frame #4: 0x00007fff697b88a7 libc++abi.dylibdemangling_terminate_handler() + 238 frame #5: 0x00007fff6b2f35b1 libobjc.A.dylib
_objc_terminate() + 104 frame #6: 0x00007fff697c6887 libc++abi.dylibstd::__terminate(void (*)()) + 8 frame #7: 0x00007fff697c91a2 libc++abi.dylib
__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 27 frame #8: 0x00007fff697c9169 libc++abi.dylib__cxa_throw + 113 frame #9: 0x00000001000117bc TVMCppDeployTest
std::__1::__throw_bad_function_call() at functional:1431:5 frame #10: 0x000000010001171c TVMCppDeployTeststd::__1::__function::__value_func<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator(this=0x00007ffeefbff5f0, __args=0x00007ffeefb3f070, __args=0x00007ffeefb3f050)(tvm::runtime::TVMArgs&&, tvm::runtime::TVMRetValue*&&) const at functional:1872:13 frame #11: 0x00000001000115a1 TVMCppDeployTest
std::__1::function<void (tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>::operator(this=0x00007ffeefbff5f0, __arg=TVMArgs @ 0x00007ffeefb3f070, __arg=0x00007ffeefb3f448)(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*) const at functional:2548:12 frame #12: 0x0000000100006118 TVMCppDeployTesttvm::runtime::TVMRetValue tvm::runtime::PackedFunc::operator(this=0x00007ffeefbff5f0, args=0x00007ffeefb3f508)<DLContext&>(DLContext&) const at packed_func.h:1192:3 frame #13: 0x000000010000542a TVMCppDeployTest
main at tvm_cpp_deploy_test.cpp:40:33 frame #14: 0x00007fff6c499cc9 libdyld.dylibstart + 1 frame #15: 0x00007fff6c499cc9 libdyld.dylib
start + 1 ‘’’
- frame #0: 0x00007fff6c5e133a libsystem_kernel.dylib