Skip to content
fn

im2col_1d_f32

void im2col_1d_f32(const float * x, float * cols, int C, int L, int KL, int OL, int stride_l, int pad_l, int dilation_l)

Single-precision 1-D im2col unfold.

Unfolds each length-KLKL receptive field of a 1-D feature map into a column of a 2-D matrix so that conv1d can be expressed as a single GEMM. Out-of-bounds positions (from padding or dilation) are written as zero.

Math

For each output index o∈[0,OL)o \in [0, OL), channel cc and kernel offset kk: cols[c⋅KL+k,o]=x[c,o⋅stride+k⋅dilation−pad]\text{cols}[c \cdot KL + k, o] = x[c, o \cdot \text{stride} + k \cdot \text{dilation} - \text{pad}] with zero for out-of-bounds positions.

Parameters

xconst float*
Input tensor, shape (C,L)(C, L) (row-major).
colsfloat*
Output column matrix, shape (C⋅KL,OL)(C \cdot KL, OL).
Cint
Channel count.
Lint
Input spatial length.
KLint
Kernel length.
OLint
Output spatial length.
stride_l, pad_l, dilation_lint
Convolution stride / zero-padding / dilation along the spatial axis.

Notes

Memory layout assumes the standard NCHW-style channel-first convention, with the batch dimension handled at the caller (loop over NN).