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

Requantize INT_32 to INT8 using arm_nn_requantize #53

Closed
Theoo1997 opened this issue Mar 24, 2023 · 2 comments
Closed

Requantize INT_32 to INT8 using arm_nn_requantize #53

Theoo1997 opened this issue Mar 24, 2023 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@Theoo1997
Copy link

Hi,
I am using this FC s8 CMSIS layer for a project. After we invoke a FC s8 kernel we have Int32 output that we need to dequantize-requantize (Int32->FP->Int8). For example if we have this FC layer in the image to dequantize-requantize the 32-bit output of the FC layer we need to apply this equation: Output_Int8 = (0.0039215669967234135*Weight_mult/0.14308570325374603) *Output_Int32 + 69. => Multiplier * Output_Int32 + shifter
image

CMSIS-NN has arm_nn_requantizefunction that takes as input Int32 Multiplier and shifter and returns (val * multiplier)/(2 ^ shift). Can you explain me how to map the above FP Multiplier and Int32 shifter into the requantize function?

@felix-johnny
Copy link
Contributor

@Theoo1997 Tanks for the question!
I am assuming this is a tflite network. If you use the TFLM framework then multiplier/shift is calculated by the framework. Is there a reason for not using the framework? It is quite some overhead for the non-framework approach.
If for some reason you do not want to use the framework, then the closest I can point you to is https://github.com/ARM-software/CMSIS-NN/blob/main/Tests/UnitTest/generate_test_data.py#L843 .. Or look in the code base of https://github.com/tensorflow/tflite-micro ..

Hope that helps and let me know if you have any follow ups..

Felix

@felix-johnny felix-johnny self-assigned this Mar 24, 2023
@Theoo1997
Copy link
Author

Theoo1997 commented Mar 24, 2023

@Theoo1997 Tanks for the question! I am assuming this is a tflite network. If you use the TFLM framework then multiplier/shift is calculated by the framework. Is there a reason for not using the framework? It is quite some overhead for the non-framework approach. If for some reason you do not want to use the framework, then the closest I can point you to is https://github.com/ARM-software/CMSIS-NN/blob/main/Tests/UnitTest/generate_test_data.py#L843 .. Or look in the code base of https://github.com/tensorflow/tflite-micro ..

Hope that helps and let me know if you have any follow ups..

Felix

Thank you very much for your response.

@felix-johnny felix-johnny added the question Further information is requested label Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants