Paddle-Lite icon indicating copy to clipboard operation
Paddle-Lite copied to clipboard

ubuntu20.04编译支持fp16的预测库出错

Open linghusmile opened this issue 11 months ago • 3 comments

./lite/tools/build_android.sh --arch=armv8 --toolchain=clang --with_cv=ON --with_extra=ON --with_opencl=ON --with_arm82_fp16=ON 出现如下报错 In file included from //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/memory:659: //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:189:59: error: invalid operands to binary expression ('float' and 'int') static _LIBCPP_CONSTEXPR const _Tp value = _Tp(_Tp(1) << __digits); ~~~~~~ ^ ~~~~~~~~ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:210:49: note: in instantiation of template class 'std::__ndk1::__libcpp_compute_min<__fp16, 15, true>' requested here static _LIBCPP_CONSTEXPR const type __min = __libcpp_compute_min<type, digits, is_signed>::value; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:443:15: note: in instantiation of template class 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' requested here : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type> ^ /home/xxxxx/Paddle-Lite/lite/backends/arm/math/sequence_pool.cc:159:23: note: in instantiation of template class 'std::__ndk1::numeric_limits<__fp16>' requested here T max = -std::numeric_limits<T>::max(); ^ /home/xxxxx/Paddle-Lite/lite/backends/arm/math/sequence_pool.cc:333:15: note: in instantiation of function template specialization 'paddle::lite::arm::math::seq_pool_max<__fp16>' requested here template void seq_pool_max<float16_t>(const float16_t* din, ^ In file included from /home/xxxxx/Paddle-Lite/lite/backends/arm/math/sequence_pool.cc:15: In file included from /home/xxxxx/Paddle-Lite/lite/backends/arm/math/sequence_pool.h:16: In file included from //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/vector:270: In file included from //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/bit_reference:15: In file included from //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/algorithm:644: In file included from //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/memory:659: //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:446:30: error: 'type' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' typedef typename __base::type type; ^ /home/xxxxx/Paddle-Lite/lite/backends/arm/math/sequence_pool.cc:159:23: note: in instantiation of template class 'std::__ndk1::numeric_limits<__fp16>' requested here T max = -std::numeric_limits<T>::max(); ^ /home/xxxxx/Paddle-Lite/lite/backends/arm/math/sequence_pool.cc:333:15: note: in instantiation of function template specialization 'paddle::lite::arm::math::seq_pool_max<__fp16>' requested here template void seq_pool_max<float16_t>(const float16_t din, ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:202:17: note: declared protected here typedef _Tp type; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:448:66: error: 'is_specialized' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:204:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool is_specialized = true; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:453:58: error: 'digits' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int digits = __base::digits; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:207:41: note: declared protected here static _LIBCPP_CONSTEXPR const int digits = static_cast(sizeof(type) * CHAR_BIT - is_signed); ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:454:60: error: 'digits10' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:208:41: note: declared protected here static _LIBCPP_CONSTEXPR const int digits10 = digits * 3 / 10; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:455:64: error: 'max_digits10' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:209:41: note: declared protected here static _LIBCPP_CONSTEXPR const int max_digits10 = 0; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:456:61: error: 'is_signed' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:206:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool is_signed = type(-1) < type(0); ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:457:62: error: 'is_integer' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:216:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool is_integer = true; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:458:60: error: 'is_exact' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:217:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool is_exact = true; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:459:57: error: 'radix' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int radix = __base::radix; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:218:41: note: declared protected here static _LIBCPP_CONSTEXPR const int radix = 2; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:463:64: error: 'min_exponent' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:222:41: note: declared protected here static _LIBCPP_CONSTEXPR const int min_exponent = 0; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:464:66: error: 'min_exponent10' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:223:41: note: declared protected here static _LIBCPP_CONSTEXPR const int min_exponent10 = 0; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:465:64: error: 'max_exponent' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:224:41: note: declared protected here static _LIBCPP_CONSTEXPR const int max_exponent = 0; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:466:66: error: 'max_exponent10' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:225:41: note: declared protected here static _LIBCPP_CONSTEXPR const int max_exponent10 = 0; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:468:64: error: 'has_infinity' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:227:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool has_infinity = false; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:469:65: error: 'has_quiet_NaN' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:228:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = false; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:470:69: error: 'has_signaling_NaN' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:229:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = false; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:471:76: error: 'has_denorm' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:230:55: note: declared protected here static _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = denorm_absent; ^ //ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:472:67: error: 'has_denorm_loss' is a protected member of 'std::__ndk1::__libcpp_numeric_limits<__fp16, true>' static _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss; ^ /*/ndk-845-r18b/sources/cxx-stl/llvm-libc++/include/limits:231:41: note: declared protected here static _LIBCPP_CONSTEXPR const bool has_denorm_loss = false; ^ fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated. make[3]: *** [lite/api/CMakeFiles/PADDLELITE_OBJS.dir/build.make:1042:lite/api/CMakeFiles/PADDLELITE_OBJS.dir//backends/arm/math/sequence_pool.cc.o] 错误 1 make[3]: *** 正在等待未完成的任务.... make[2]: *** [CMakeFiles/Makefile2:1562:lite/api/CMakeFiles/PADDLELITE_OBJS.dir/all] 错误 2 make[1]: *** [CMakeFiles/Makefile2:802:lite/CMakeFiles/publish_inference.dir/rule] 错误 2 make: *** [Makefile:150:publish_inference] 错误 2

-OS:ubuntu20.04 -Python:3.8.18 -NDK:r18b -Paddle-Lite:v2.13-rc

当使用./lite/tools/build_android.sh --arch=armv8 --toolchain=clang --with_cv=ON --with_extra=ON --with_opencl=ON时则可以正常编译 *之所以没有使用https://github.com/PaddlePaddle/Paddle-Lite/releases/tag/v2.13-rc 中release的版本是因为想要打开opencl加速

linghusmile avatar Mar 08 '24 08:03 linghusmile

本地编译时不打开fp16的开关则不会有上述报错 ./lite/tools/build_android.sh --arch=armv8 --toolchain=clang --with_cv=ON --with_extra=ON --with_opencl=ON

linghusmile avatar Mar 08 '24 08:03 linghusmile

您好,换成 ndk r17c 编译试下呢。

shentanyue avatar Mar 11 '24 05:03 shentanyue

fp16 要求大于 r19 https://www.paddlepaddle.org.cn/lite/v2.12/demo_guides/arm_cpu.html image

hong19860320 avatar Mar 13 '24 07:03 hong19860320