fn
im2col_f32
void im2col_f32(const float * x, float * cols, 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, int dilation_h, int dilation_w)Single-precision 2-D im2col unfold.
Unfolds the 2-D feature map of shape into a matrix where
each column is a receptive-field patch flattened across
channels. The output column matrix has shape so that conv2d = sgemm(W_reshape, cols).
Out-of-bounds positions (those reaching outside the input due to padding, stride, or dilation) are written as zero.
Math
For each output position , kernel offset and
channel , the corresponding input position is
and cols[c \cdot K_H K_W + k_h K_W + k_w, o_h \cdot O_W + o_w] = x[c, i_h, i_w] (zero if OOB).
Parameters
xconst float*Input tensor, shape row-major.
colsfloat*Output column matrix, shape .
CintChannel count.
H, WintInput spatial dimensions.
KH, KWintKernel height and width.
OH, OWintOutput spatial dimensions.
stride_h, stride_wintPer-axis stride.
pad_h, pad_wintPer-axis zero-padding.
dilation_h, dilation_wintPer-axis dilation.
Notes
Memory layout is NCHW (channel-first) — the batch dimension is iterated at the caller, with one im2col per batch element.