zjhellofss / KuiperInfer

校招、秋招、春招、实习好项目!带你从零实现一个高性能的深度学习推理库,支持大模型 llama2 、Unet、Yolov5、Resnet等模型的推理。Implement a high-performance deep learning inference library step by step
MIT License
2.59k stars 295 forks source link

ARM下的精度问题 #61

Open z-learner opened 5 months ago

z-learner commented 5 months ago

我在代码中加入了ARM的编译选项,发现 softmax 测试(其余的测试都可以过)一直因为精度问题过不了,但是里面的实现已经是 std::exp 的实现了,还没有开始增加NEON相关的支持,想问下这里的真值是怎么产生的?

代码 : https://github.com/zjhellofss/KuiperInfer/commit/95b8c8bea772953ba5715e19c6fc7ec69159214f

/root/Documents/code/KuiperInfer/test/test_layer/test_softmax.cpp:59: Failure
Expected: (std::abs(a - b)) <= (1e-5f), actual: 0.000335352495 vs 1e-05
a: 0.018315639346837997 b: 0.017980286851525307

[  FAILED  ] test_layer.forward_softmax_dim1 (22 ms)
[ RUN      ] test_layer.forward_softmax_dim1_minus2
/root/Documents/code/KuiperInfer/test/test_layer/test_softmax.cpp:94: Failure
Expected: (std::abs(a - b)) <= (1e-5f), actual: 0.000335352495 vs 1e-05
a: 0.018315639346837997 b: 0.017980286851525307 i:4

[  FAILED  ] test_layer.forward_softmax_dim1_minus2 (8 ms)
[ RUN      ] test_layer.forward_softmax_dim0
[       OK ] test_layer.forward_softmax_dim0 (29 ms)
[ RUN      ] test_layer.forward_softmax_dim2
/root/Documents/code/KuiperInfer/test/test_layer/test_softmax.cpp:159: Failure
Expected: (std::abs(a - b)) <= (1e-5f), actual: 0.0177284628 vs 1e-05
a: 0.049787066876888275 b: 0.032058604061603546 i:0
Gooddz1 commented 3 months ago

请问怎么在代码中加入了ARM的编译选项,可以分享一下相应的代码吗?

z-learner commented 3 months ago

可以看下这个 commit