ncnn fp32结果异常

64jmpszr  于 2022-11-19  发布在  其他
关注(0)|答案(1)|浏览(199)

error log | 日志或报错信息 | ログ

context | 编译/运行环境 | バックグラウンド

  • 设备:华为P40 Kirin 990
  • ndk 版本:r20b
  • ncnn版本:20220420

编译

cmake \
  -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \
  -DANDROID_NDK=$ANDROID_NDK_HOME \
  -DCMAKE_ANDROID_SDK=$ANDROID_SDK \
  -DANDROID_ABI=arm64-v8a \
  -DANDROID_ARM_NEON=ON \
  -DANDROID_STL=c++_shared \
  -DANDROID_PLATFORM=24 \
  -DCMAKE_BUILD_TYPE=Release \
  -DNCNN_VULKAN=ON \
  -DNCNN_DISABLE_RTTI=OFF \
  -DNCNN_DISABLE_EXCEPTION=OFF \
  -DNCNN_VERSION=20220420 \
  -DCMAKE_INSTALL_PREFIX=/root/Environments/Android/ncnn/1.0.20220420-r20b-api24/arm64-v8a \
  ..

转换工具Linux端编译脚本

cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DNCNN_DISABLE_RTTI=OFF \
  -DNCNN_DISABLE_EXCEPTION=OFF \
  -DNCNN_VERSION=20220420 \
  -DCMAKE_INSTALL_PREFIX=/root/Environments/Linux/ncnn/1.0.20220420/ \
  ..

how to reproduce | 复现步骤 | 再現方法

  1. 使用 onnx2ncnn转换
  2. 指定输入维度 0=640 1=640 2=3
  3. 使用ncnnoptimize 优化 得到 fp16 和 fp32 的模型 (使用65535)
  4. 编译相应的demo,option中指定了num_threads 和 lightmode,其他未做修改
  5. adb shell中运行
  6. 使用fp16模型时,能得到正确的结果
  7. 使用fp32模型时,网络输出nan

运行log

130|HWELS:/data/local/tmp/xyzhao/ncnn_debug $ ./correct_object_test ./correct_objects_ncnn_220427_fp16.am ../zj_orig/ ./test/
[2022/04/27 20:03:10.780][4820][I][ncnn_engine.cpp,Init:20]: Init
[2022/04/27 20:03:11.311][4820][I][ncnn_engine.cpp,Init:37]: Init success
[2022/04/27 20:03:11.507][4820][I][correct_object_test.cpp,main:68]: File num: 93
[2022/04/27 20:03:11.507][4820][I][correct_object_test.cpp,main:75]: file = ../zj_orig/DJI_0001.JPG
[2022/04/27 20:03:12.051][4820][I][ncnn_engine.cpp,Inference:157]: ---------- Layer 807 start ------------
0.076904 -1.036133 -0.700195 -0.147583 -0.330566 -0.080566 0.155396 -0.182617 -0.159546 0.269775 0.381348 -0.721191 -0.308350 -0.168091 0.309082 -0.478760 0.141968 0.513184 0.508301 -0.175171
0.101074 -0.754395 -0.895996 -0.288574 0.002901 0.327148 0.407471 0.179077 -0.011833 0.038849 0.193359 -1.246094 -0.840820 0.054321 0.325195 0.079956 0.309326 0.723145 0.479492 -0.038300
0.059387 -0.396240 -0.762207 -0.323975 0.354004 0.135010 0.473389 0.286133 -0.012970 -0.182617 -0.749512 -0.491699 -0.393555 0.211914 0.322266 0.345215 0.270508 0.712891 0.539062 0.060883
-0.100769 -0.346924 -0.486084 -0.377686 0.350586 0.180298 0.703613 0.209961 0.090576 -0.179932 -0.691895 0.294189 -0.075867 -0.096924 0.248291 0.173706 0.188354 0.592285 0.688965 0.051453
-0.071228 -0.410156 -0.548828 -0.276855 0.334473 0.714844 0.498535 0.086060 0.147949 -0.077820 -0.507812 0.294922 0.118958 -0.466553 -0.035034 -0.003492 0.248779 0.562500 0.776855 0.100586
-0.070129 -0.415771 -0.554688 -0.254883 0.507812 1.000977 0.540527 0.036743 0.081482 -0.090332 -0.869141 -0.147095 0.134033 -0.121887 0.144653 -0.227417 0.596680 0.217163 0.758789 0.182983
-0.101624 -0.261719 -0.504883 -0.330566 0.662109 1.044922 0.771484 0.000677 0.082275 -0.238037 -0.788574 -0.484863 0.154053 0.717285 0.500977 -1.152344 0.579102 -0.144897 0.807617 0.159424
-0.091492 -0.015564 -0.392334 -0.269775 0.646484 1.040039 0.695312 0.019699 0.035828 -0.561035 -0.518066 -0.469971 -0.057556 0.301025 0.506348 -0.415039 0.355469 -0.046539 0.611816 0.181763
-0.003538 -0.281738 -0.244507 0.207031 0.593262 1.011719 0.448730 -0.016907 -0.097595 -0.554688 -0.722168 -0.364014 -0.068848 0.176880 0.415283 0.685059 -0.081482 -0.133911 0.401123 0.218384
0.053467 -0.432373 -0.001884 0.240845 0.652832 0.648926 0.473145 0.050873 -0.099060 -0.477539 -1.054688 -0.554199 -0.057220 0.615234 0.427246 0.554199 -0.052216 -0.325684 0.241821 0.276123
0.115234 -0.352295 -0.354248 0.075867 0.742676 0.877441 0.390381 0.096130 -0.037109 -0.579102 -1.038086 -0.329590 0.088928 0.692871 0.370850 0.539062 0.202759 -0.335938 0.131104 0.277588
0.292236 -0.395996 -0.705078 -0.066284 0.546387 1.511719 0.329590 0.001436 -0.108032 -0.132324 -0.955566 -0.185303 0.114014 0.429199 0.662109 0.779785 0.126465 -0.403809 0.046722 0.250977
0.379883 -0.140625 -0.845703 0.017395 1.063477 0.850586 0.177002 0.472656 -0.050690 -0.315918 -1.052734 0.206665 -0.193726 0.477539 0.427734 0.630859 -0.263428 -0.642090 0.008095 0.302002
0.568359 -0.058105 -0.674805 0.337402 0.653809 0.608398 0.481934 0.193604 0.025894 -0.443848 -1.206055 0.130249 0.006809 0.281006 0.781738 0.151855 -0.577637 -0.182861 0.090332 0.276367
0.691406 -0.046234 -0.206177 0.290283 -0.139893 0.657227 1.041992 0.272461 0.141846 -0.553711 -1.185547 -0.311768 0.534180 -0.049683 0.234619 -0.095703 -0.300781 0.177490 0.111023 0.153931
0.904297 -0.291260 -1.006836 0.270508 0.522949 0.343994 1.267578 0.576660 0.171021 -0.874023 -1.230469 -0.279541 0.910156 -0.177856 -0.333984 -0.107666 -0.264648 0.194458 0.252930 0.035980
0.750488 -0.455078 -1.030273 0.559082 0.938477 -0.190918 0.667480 0.638672 0.414307 -0.810059 -1.272461 -0.155396 0.936523 -0.130615 -0.456787 -0.360840 -0.246704 0.396973 0.503418 -0.038940
0.464355 -0.356934 -0.409668 0.622070 0.916016 -0.119385 -0.047241 0.410645 0.260010 -0.603516 -0.952148 -0.016968 0.514160 -0.167725 -0.130249 -0.521973 -0.394775 0.420898 0.433594 -0.128174
0.400879 -0.366699 -0.396729 0.420898 0.442383 -0.037598 -0.138306 0.243408 0.212524 -0.564941 -0.480469 0.091736 0.149292 0.288574 0.413574 -0.726562 -0.870605 0.183350 0.401123 -0.270996
0.417725 -0.420410 -0.341553 0.344482 0.229736 0.096436 0.015221 -0.002790 0.389648 -0.160400 -0.151123 -0.152466 0.032776 0.718262 0.635742 -0.751465 -0.684082 0.075195 0.145142 -0.378906

[2022/04/27 20:03:12.052][4820][I][ncnn_engine.cpp,Inference:171]: ---- dims = 3 : 1, 45, 20, 20
[2022/04/27 20:03:12.052][4820][I][ncnn_engine.cpp,Inference:172]: ---------- Layer 807 end ------------
^C
130|HWELS:/data/local/tmp/xyzhao/ncnn_debug $ ./correct_object_test ./correct_objects_ncnn_220427_fp32.am ../zj_orig/ ./test/
[2022/04/27 20:03:19.660][4978][I][ncnn_engine.cpp,Init:20]: Init
[2022/04/27 20:03:20.172][4978][I][ncnn_engine.cpp,Init:37]: Init success
[2022/04/27 20:03:20.563][4978][I][correct_object_test.cpp,main:68]: File num: 93
[2022/04/27 20:03:20.563][4978][I][correct_object_test.cpp,main:75]: file = ../zj_orig/DJI_0001.JPG
[2022/04/27 20:03:21.105][4978][I][ncnn_engine.cpp,Inference:157]: ---------- Layer 807 start ------------
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan
-nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan -nan

[2022/04/27 20:03:21.105][4978][I][ncnn_engine.cpp,Inference:171]: ---- dims = 3 : 1, 45, 20, 20
[2022/04/27 20:03:21.105][4978][I][ncnn_engine.cpp,Inference:172]: ---------- Layer 807 end ------------
^C
130|HWELS:/data/local/tmp/xyzhao/ncnn_debug $

more | 其他 | その他

debug.param.zip

kqqjbcuj

kqqjbcuj1#

使用fp32 模型,指定以下 Option

net_->opt.use_fp16_packed = false;
  net_->opt.use_fp16_storage = false;
  net_->opt.use_fp16_arithmetic = false;

结果依旧nan

相关问题