ARM-software / CMSIS-DSP

CMSIS-DSP embedded compute library for Cortex-M and Cortex-A
https://arm-software.github.io/CMSIS-DSP
Apache License 2.0
454 stars 122 forks source link

Issues with log implementation for Neon #151

Open christophe0606 opened 5 months ago

christophe0606 commented 5 months ago

vlogq_f32 is used directly to implement the arm_vlog_f32. But vlogq_f32 being based on Taylor expansion for Neon, it can be used only for a limited range of the argument. So arm_vlog_f32 should not use it directly but apply some scaling when the argument is not in the right range.

Gao-HaoYuan commented 5 months ago

I've conducted some tests, and when the value is very close to 1, there are significant differences in the calculation results. It might be beneficial to pay attention to values close to 1, such as 1.000000119, 1.00000119, and 0.9999911.

This critical issue : I extracted the code for vlogq_f32 from CMSIS-DSP, When calculating log(1.000000119), the result is -0 instead of +0.

christophe0606 commented 5 months ago

@Gao-HaoYuan I think we should do something like computing log(1.000000119/2) + log(2)

I need to study the Taylor expansion used to find the right bounds for the argument.

Gao-HaoYuan commented 5 months ago

Log_test.zip

@christophe0606 This is a code example that requires modification of the IP and NDK addresses.

I attempted to understand the coefficients of the Taylor expansion in the log, but I couldn't figure out the source of the coefficients in the code. It might be a special value from (x-n) of the Taylor expansion. If I have the time, I will also try to solve this issue.

Gao-HaoYuan commented 2 weeks ago

I found a similar solution that can refer to the log calculation logic of OpenCV. However, I haven't organized the code for individual execution yet. If you have time, please you refer to it.

mathfuncs

@christophe0606

christophe0606 commented 2 weeks ago

@Gao-HaoYuan Thank you. Sorry for being slow at looking at this issue ...