pulp-platform / quantlib

A library to train and deploy quantised Deep Neural Networks
Apache License 2.0
17 stars 7 forks source link

Unfolded Add Node in Network Graph related to the rounding #9

Open ahmad-mirsalari opened 1 year ago

ahmad-mirsalari commented 1 year ago

I have noticed an issue in the commit (https://github.com/pulp-platform/quantlib/commit/e8cfc0da8ea6e64774cb6f1bbe1de4613140ed4c), specifically in the graph of the network.

There is an Add node for rounding (0.5), which should ideally be folded together with the other Add node before it. This seems to be causing a discrepancy in the network graph.

Could this be checked and corrected?

Thanks for looking into this. add

Scheremo commented 1 year ago

Hi @ahmad-mirsalari! I believe this is in issue of oversight. For PULP-NN type quantization, the rounding offset (eps/2) is indeed added to the bias of the requantization operator. For CMSIS type quantization, this is not done, since the kernels work differently. I'll look into a fix with @da-gazzi.