Skip to content
fn

unfold_dim_op

→TensorImplPtr
int unfold_dim_op(const int & a, int dim, int size, int step)

Sliding-window view of a along a single dimension.

Shape

Adds a trailing size-sized axis; the original dim is replaced by the number of windows L.

Parameters

aTensorImplPtr
Input tensor.
dimint
Axis along which to unfold.
sizeint
Window width.
stepint
Stride between successive windows.

Returns

TensorImplPtr

Tensor whose shape is (*in_shape[:dim], L, *in_shape[dim+1:], size) where L=⌊(in_shape[dim]−size)/step⌋+1L = \lfloor (\text{in\_shape}[\text{dim}] - \text{size}) / \text{step} \rfloor + 1.

Notes

Behaves as a view; backward passes through a gather that accumulates overlapping windows back into the input.