Average pooling result_t
Quick summary
Currently all poolings set the result_t to the input precision if auto. While this makes sense for MaxPooling, I think it would be preferrable if result_t is made to match accum_t for AvgPooling, which is suitably widened. Currently, average pooling can introduce an unexpected truncation. (I would at least use rounding by default if you wanted to keep the same precision.)
I am hitting this issue with avgppool. Which rounding mode would you suggest? ap_fixed<16,6,AP_RND_ZERO>? Is there a change I can make locally to achieve result_tmatching accum_t?
config = hls4ml.utils.config_from_keras_model(model, granularity='name')
config['LayerName']['watever_name_of_your_avg_pool_layer_is']['Precision']['accum'] = 'ap_whatever<...>'
config['LayerName']['watever_name_of_your_avg_pool_layer_is']['Precision']['result'] = 'ap_whatever<...>'
@jmitrevs Will such result_t have an impact on the subsequent layers having a bitwidth potentially too wide? accum_t should be wide enough to to store the sum of elements in the pool window, but after averaging the integer component does not need to be as wide, though fractional part probably does.
Ideally one would just increase the fractional component but not the integer component, with rounding left to the user if they want to reduce the width.