Python wrappers
Public Python APIs implemented by this engine symbols.Autograd node for the Unfold (im2col) operation.
Slides a kernel-sized window over each spatial dimension of the input and lays the resulting patches out as columns of a 3-D matrix:
The output column count equals , the same value a
matching convolution would produce. Supports
inferred from kernel.size().
Attributes
schema_v1OpSchemaRegistered op (
"unfold", AmpPolicy::KeepInput).kernel_vector<int>Kernel sizes per spatial axis.
stride_vector<int>Strides per spatial axis.
pad_vector<int>Zero-padding per spatial axis.
dilation_vector<int>Dilations per spatial axis.
Static methods
1static
forward
→TensorImplPtrint forward(const int & x, const int & kernel, const int & stride, const int & pad, const int & dilation)Run the forward im2col extraction.
Parameters
xTensorImplPtrInput of shape
(B, C, S_0, ..., S_{N-1}) where N = kernel.size().kernelvector<int>Per-axis kernel size (length
N).stridevector<int>Per-axis stride.
padvector<int>Per-axis zero-padding.
dilationvector<int>Per-axis dilation.
Returns
TensorImplPtrColumn matrix of shape (B, C * prod(K), prod(O)).
Raises
ShapeMismatchIf the input rank disagrees with
N + 2 or any output extent is non-positive.Methods
1Backward — the fold (col2im) operation that scatters the patches back to spatial positions, summing overlaps.
Parameters
grad_outStorageUpstream gradient shaped like the forward output.
Returns
vector<Storage>Single-element vector containing dx with the original input shape.