Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
majianjia opened this issue Nov 20, 2020 · 1 comment

Comments

@majianjia
Copy link
Owner

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
Copy link
Owner Author

majianjia commented Nov 20, 2020

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 added a commit that referenced this issue Nov 28, 2020
Static memory interface, NNOM_TRUNCATE, versions and others

- Add a new static memory buffer interface. By using this interface, NNoM no longer need dynamic memory allocation from libc
- change default NNOM_TRUNCATE setting to avoid the ROUND issue for 16bit ops. #104, for use with CMSIS-NN, please enable global macro `NN_TRUNCATE` to avoid the same issue in CMSIS-NN. 
- Move script/lib version to 0.4.3
- Fix memory alignment for 64bit system.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant