[BYOC] how to link extern .so files

Hi, I followed the BYOC tutorial and inserted some op functions of my compute library. When my op can run without any extern .so files, I found it works well. But if a op function relays on an extern .so library, TVM reports this error:

python: symbol lookup error: /home/.../dense.so: undefined symbol: extern_func_symbol

I have tried to add compile flags in lib.export_library("./dense.so", options = "-std=c++11 -Lxxxxx") , but TVM reports g++: error: unrecognized command line option ‘-std=c++11 -Lxxxxx’

How can I fix it?

You can take a look at how we integrate DNNL (aka oneDNN). I think you need to link your *.so file to libtvm.so or libtvm_runtime.so. cc @comaniac

The way you use is for static link for the generated code why the error is for dynamic link. As @masahi pointed out, you should link your .so to TVM, which means you may need to add this library to the TVM building process.

try add the following line to CMakeLists.txt:

target_link_libraries(tvm PRIVATE ${PATH_TO_YOUR_SHARED_LIBRARY})
target_link_libraries(tvm_runtime PRIVATE ${PATH_TO_YOUR_SHARED_LIBRARY})

and rebuild TVM.

Thanks for your all, I solved this problem by linking my .so to TVM.

你好,我的CMakeLists.txt文件中已经有关于TVM的target_link_libraries(tvm PRIVATE ${PATH_TO_YOUR_SHARED_LIBRARY}) target_link_libraries(tvm_runtime PRIVATE ${PATH_TO_YOUR_SHARED_LIBRARY}),添加进去自己的.so文件,会产生冲突嘛,如何解决这种冲突。