Skip to content
fn

max_pool2d_forward_f32

void max_pool2d_forward_f32(const float * x, float * y, int * argmax, 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)

Single-precision 2-D max-pool forward over an NCHW input.

For every output cell the kernel scans the corresponding KH × KW window and writes both the maximum into y and the flat H*W index of the winning input position into argmax. Pad positions contribute -inf (an all-pad window yields the first pad slot as the argmax).

Shape

OH=⌊(H+2⋅pad_h−KH)/stride_h⌋+1\text{OH} = \lfloor (H + 2\cdot\text{pad\_h} - \text{KH})/\text{stride\_h}\rfloor + 1, analogously for OW\text{OW}.

Parameters

xconst float*
Input tensor of shape (B, C, H, W).
yfloat*
Output tensor of shape (B, C, OH, OW).
argmaxint32_t*
Per-output winning input position, encoded as h*W + w within the 2-D spatial slice; shape (B, C, OH, OW).
B, C, H, Wint
Layout extents of x.
KH, KWint
Window height and width.
OH, OWint
Output spatial extents.
stride_h, stride_wint
Window stride along H and W.
pad_h, pad_wint
Symmetric zero-pad on each spatial axis.