Function calculate_unfold_shape

pub fn calculate_unfold_shape<S>(
    shape: S,
    dim: usize,
    size: usize,
    step: usize,
) -> Vec<usize>
where S: Into<Shape>,
Expand description

Calculate the output shape for an unfold operation.

The operation yields a view with all complete windows of size size in dimension dim; where windows are advanced by step at each index.

The number of windows is max(0, (shape[dim] - size).ceil_div(step)).

§Arguments

  • shape - The input shape to unfold; of shape [pre=..., dim shape, post=...]
  • dim - the dimension to unfold.
  • size - the size of each unfolded window.
  • step - the step between each window.

§Returns

A shape with [pre=..., windows, post=..., size].