Fix QuantAvgPool - #1
Conversation
|
I am not sure I fully understand the pooling situation: We have average pooling and quantized average pooling - at least here in the backend - as |
|
This was the case before, when the QuantAvgPool in reality implemented a SumPool+Truc instead of an AvgPool+Trunc. This behavior was changed with Xilinx/brevitas#1042. Now a QuantAvgPool implements an AvgPool with an appended truncation node. In the case where input_bits=output_bits, AvgPool and QuantAvgPool implement the exact same behavior. But yes, it could be worth it to discuss combining these two implementations into a single one and adding a seperate trunc node that implements just the shifting. (Or at least reuse the AvgPool implementation inside the QuantAvgPool implementation.) |
Changed the implementation of the QuantAvgPool to conform to Xilinx/brevitas#1042.
The QuantAvgPool implementation was changed from a SumPool + Trunc to AvgPool + Trunc. As a result, an additional division is needed. As the accumulated values of the layer are divided by the the kernel size, this division cannot necessarily be implemented by a bit shift. After the division the bit shift of the truncation is still needed like before this fix.