microsoft / onnxruntime

ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator
https://onnxruntime.ai
MIT License
14.05k stars 2.83k forks source link

build rknpu backend error #11738

Open XiaotaoChen opened 2 years ago

XiaotaoChen commented 2 years ago

Describe the bug

1. I'm build rknpu backend with cross compiling on linux;
2. build arm linux without rknpu is ok;
3. it also met the incompatibility issue between vector<int32_t> and vector<uint32_t> , And i modify the code to avoid that issue, Finally, encounter ‘KernelRegistry’ issue as below:
4. this error also shows in: https://github.com/microsoft/onnxruntime/issues/7614

error info

/host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc: In function 'void onnxruntime::RegisterRknpuKernels(onnxruntime::KernelRegistry&)':
/host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc:553:5: error: invalid use of incomplete type 'class onnxruntime::KernelRegistry'
     kernel_registry.Register(function_table_entry());
     ^~~~~~~~~~~~~~~
In file included from /host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.h:10,
                 from /host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc:10:
/host/repositories/onnxruntime/include/onnxruntime/core/framework/execution_provider.h:21:7: note: forward declaration of 'class onnxruntime::KernelRegistry'
 class KernelRegistry;
       ^~~~~~~~~~~~~~
In file included from /opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/stl_tree.h:69,
                 from /opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/set:60,
                 from /host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc:5:
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/ext/aligned_buffer.h: In instantiation of 'struct __gnu_cxx::__aligned_buffer<onnxruntime::KernelRegistry>':
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/shared_ptr_base.h:533:35:   required from 'class std::_Sp_counted_ptr_inplace<onnxruntime::KernelRegistry, std::allocator<onnxruntime::KernelRegistry>, (__gnu_cxx::_Lock_policy)2>::_Impl'
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/shared_ptr_base.h:594:13:   required from 'class std::_Sp_counted_ptr_inplace<onnxruntime::KernelRegistry, std::allocator<onnxruntime::KernelRegistry>, (__gnu_cxx::_Lock_policy)2>'
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/shared_ptr_base.h:674:43:   required from 'std::__shared_count<_Lp>::__shared_count(_Tp*&, std::_Sp_alloc_shared_tag<_Alloc>, _Args&& ...) [with _Tp = onnxruntime::KernelRegistry; _Alloc = std::allocator<onnxruntime::KernelRegistry>; _Args = {}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]'
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/shared_ptr_base.h:1342:71:   required from 'std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<onnxruntime::KernelRegistry>; _Args = {}; _Tp = onnxruntime::KernelRegistry; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2]'
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/shared_ptr.h:359:59:   required from 'std::shared_ptr<_Tp>::shared_ptr(std::_Sp_alloc_shared_tag<_Tp>, _Args&& ...) [with _Alloc = std::allocator<onnxruntime::KernelRegistry>; _Args = {}; _Tp = onnxruntime::KernelRegistry]'
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/shared_ptr.h:705:14:   required from 'std::shared_ptr<_Tp> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = onnxruntime::KernelRegistry; _Alloc = std::allocator<onnxruntime::KernelRegistry>; _Args = {}]'
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/bits/shared_ptr.h:721:39:   required from 'std::shared_ptr<_Tp> std::make_shared(_Args&& ...) [with _Tp = onnxruntime::KernelRegistry; _Args = {}]'
/host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc:559:40:   required from here
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/ext/aligned_buffer.h:91:28: error: invalid application of 'sizeof' to incomplete type 'onnxruntime::KernelRegistry'
     : std::aligned_storage<sizeof(_Tp), __alignof__(_Tp)>
                            ^~~~~~~~~~~
/opt/rk-owl/RV1126_RV1109_SDK/prebuilts/gcc/linux-x86/arm/gcc-arm-8.3-2019.03-x86_64-arm-linux-gnueabihf/arm-linux-gnueabihf/include/c++/8.3.0/ext/aligned_buffer.h:91:28: error: invalid application of 'sizeof' to incomplete type 'onnxruntime::KernelRegistry'
CMakeFiles/onnxruntime_providers_rknpu.dir/build.make:103: recipe for target 'CMakeFiles/onnxruntime_providers_rknpu.dir/host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc.o' failed
make[2]: *** [CMakeFiles/onnxruntime_providers_rknpu.dir/host/repositories/onnxruntime/onnxruntime/core/providers/rknpu/rknpu_execution_provider.cc.o] Error 1
CMakeFiles/Makefile2:1782: recipe for target 'CMakeFiles/onnxruntime_providers_rknpu.dir/all' failed
make[1]: *** [CMakeFiles/onnxruntime_providers_rknpu.dir/all] Error 2
Makefile:165: recipe for target 'all' failed
make: *** [all] Error 2

build arm linux script it build arm linux normally

./build.sh --skip_tests --arm --parallel --build_shared_lib --build_dir build_arm --config MinSizeRel --cmake_extra_defines CMAKE_TOOLCHAIN_FILE=/host/thirdParty/rv11xx_toolchain.cmake ONNX_CUSTOM_PROTOC_EXECUTABLE=/host/thirdParty/protoc-3.18.1/bin/protoc

build arm rknpu script it build failed

./build.sh --use_rknpu --skip_tests --arm --parallel --build_shared_lib --build_dir build_arm_rknpu --config MinSizeRel --cmake_extra_defines CMAKE_TOOLCHAIN_FILE=/host/thirdParty/rv11xx_toolchain.cmake ONNX_CUSTOM_PROTOC_EXECUTABLE=/host/thirdParty/protoc-3.18.1/bin/protoc RKNPU_DDK_PATH=/host/repositories/rknpu_ddk

System information

analysis there is KernelRegistry class in onnxruntime/core/providers/shared_library/provider_wrappedtypes.h , Is it caused with uncorrect config ?

tyrius02 commented 2 months ago

RKNPU EP build failure is already reported in #7614.