Skip to content

Supporting `count_include_pad` attribute for `AvgPooling`

The attribute count_include_pad is defined as followig:

  • If count_include_pad = 1, the pooling operation includes the padded values when computing the average.
  • If count_include_pad = 0, the pooling operation excludes the padded values from the averaging calculation.

Example:
For Kernel size = 3 and Stride = 1.
If input = [1, 2, 3, 4]
With padding it becomes [0, 1, 2, 3, 4, 0]

  • count_include_pad = 1
    output = [(0+1+2)/3 = 1, (1+2+3)/3 = 2, (2+3+4)/3 = 3, (3+4+0)/3 = 2.33]
  • count_include_pad = 0
    output = [(1+2)/2 = 1.5, (1+2+3)/3 = 2, (2+3+4)/3 = 3,(3+4)/2 = 3.5]

Problem

The issue is that paddedAvgPooling is a metaoperator so padding is separated from pooling which makes supporting this attributes difficult.
We can add a custom metaOp kernel but this is problematic as the custom kernel must not have different behavior than the composed graph of the metaOp.

Edited by Houssem ROUIS