nnom icon indicating copy to clipboard operation
nnom copied to clipboard

RNN layer (16bit ops) not perform correctly with round (NNOM_TUNCATE undefined)

Open majianjia opened this issue 4 years ago • 1 comments

To use RNN layers, must define NNOM_TUNCATE in nnom_port.h to use 'floor' instead of 'round' in backend ops.

Problem seems related to NNOM_ROUND() in local_mult_q15() and local_fully_connected_mat_q7_vec_q15()

Same as ARM versions, NN_ROUND(). I need to review those shift and round calculation. At the meantime, please define NNOM_TUNCATE in nnom_port.h

majianjia avatar Nov 20 '20 01:11 majianjia

change this line
#define NNOM_ROUND(out_shift) ( (0x1u << out_shift) >> 1 ) to #define NNOM_ROUND(out_shift) ((q31_t)( (0x1u << out_shift) >> 1 )) fix the issue. But how about the arm version? still not working.

https://github.com/ARM-software/CMSIS_5/blob/e42a76a56841fed4dbd182221cc7f3ade753acc9/CMSIS/NN/Include/arm_nnsupportfunctions.h#L652

majianjia avatar Nov 20 '20 02:11 majianjia