lshift and rshift in nn_quantizer

Discussion related to "under the hood" OpenMV topics.
kidswong999
Posts: 24
Joined: Sun Apr 02, 2017 1:12 pm

lshift and rshift in nn_quantizer

Postby kidswong999 » Sun Jul 29, 2018 10:09 pm

Hi,
When quantifying my own model, I was confused about what l_shift and r_shift.

I have converted the float32 number to an 8-bit q format fix-number.
and get int_bits and dec_bits of weights and bias.
maybe 2 numbers is enough: weights_dec_bits and bias_dec_bits. (weights_int_bits = 7-weights_dec_bits; and bias_int_bits = 7-bias_dec_bits;)

However, OpenMV's network stores l_shift and r_shift:
https://github.com/openmv/openmv/blob/m ... /nn.c#L150
OpenMV read l_shift and r_shift in CONV and IP layers.

I saw the code in https://github.com/openmv/openmv/blob/m ... er.py#L564
But I don't know what l_shift and r_shift are, and how to calculate it.
Could you help me? :D
User avatar
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: lshift and rshift in nn_quantizer

Postby kwagyeman » Sun Jul 29, 2018 10:23 pm

This is unbelievably complex. Basically, just read the ARM quantizer script. We basically did not get anywhere until they released it. https://github.com/openmv/openmv/blob/m ... antizer.py
Nyamekye,
kidswong999
Posts: 24
Joined: Sun Apr 02, 2017 1:12 pm

Re: lshift and rshift in nn_quantizer

Postby kidswong999 » Sun Jul 29, 2018 10:45 pm

I will study this code again, in fact, it is really difficult to understand.

I also read the paper:
Efficient Neural Network Kernels for Arm Cortex-M CPUs
Https://arxiv.org/abs/1801.06601

But it seems that I don't not find the answer.
User avatar
iabdalkader
Posts: 497
Joined: Sun May 24, 2015 3:53 pm

Re: lshift and rshift in nn_quantizer

Postby iabdalkader » Sun Jul 29, 2018 11:21 pm

kidswong999
Posts: 24
Joined: Sun Apr 02, 2017 1:12 pm

Re: lshift and rshift in nn_quantizer

Postby kidswong999 » Mon Jul 30, 2018 12:02 am

Thanks. :D

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests