Skip to content
fn

avg_pool2d_forward_f32

void avg_pool2d_forward_f32(const float * x, float * y, int B, int C, int H, int W, int KH, int KW, int OH, int OW, int stride_h, int stride_w, int pad_h, int pad_w, bool count_include_pad)

Single-precision 2-D average-pool forward with count-include-pad semantics.

Every output cell is the mean of its KH × KW window with divisor fixed at KH * KW regardless of how many positions fall on padding; padded positions contribute 0 to the sum but still count toward the divisor.

Math

yb,c,oh,ow=1KH KW∑kh,kwxb,c,ih,iw,y_{b,c,oh,ow} = \frac{1}{\text{KH}\,\text{KW}} \sum_{kh, kw} x_{b, c, ih, iw}, with ih=oh⋅stride_h+kh−pad_hih = oh\cdot\text{stride\_h} + kh - \text{pad\_h}, similarly for iwiw.

Parameters

xconst float*
Input tensor of shape (B, C, H, W).
yfloat*
Output tensor of shape (B, C, OH, OW).
B, C, H, Wint
Layout extents of x.
KH, KWint
Window height and width. KH * KW is the (count-include-pad) divisor.
OH, OWint
Output spatial extents.
stride_h, stride_w, pad_h, pad_wint
Window stride and symmetric zero-pad on each axis.