---
title: "ClikaRT::ops::unfold"
sidebar_label: "unfold"
description: "im2col: extracts sliding kernel windows from a channels-last input."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## unfold() {#unfold}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`unfold`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `kernel_size`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dilation` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `padding` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `stride` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`PadMode`](./index.md#PadMode) `mode` `=` [`PadMode::Constant`](./index.md#PadMode),<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<double>` `value` `=` `std::nullopt`<br />
)

</div>

im2col: extracts sliding kernel windows from a channels-last input.

Input `[N, spatial.., C]` (1-D/2-D/3-D); output `[N, L, prod(kernel_size), C]` where `L` is the number of window placements; channels-last throughout (window samples sit next to channels).

**Parameters**

- `input`: channels-last input, rank 3/4/5.
- `kernel_size`: per-dim window extents.
- `dilation`: per-dim window dilation; empty (the default) is 1 per dim.
- `padding`: the `(low, high)` zero-padding pairs per spatial axis; empty (the default) pads nothing.
- `stride`: per-dim window step; empty (the default) is 1 per dim.

**Throws**

- `ClikaRT::Error`: when the input's dtype/shape is not served for this operation (the machine-readable reason rides `code_name()`).

**Returns:** `[N, L, prod(kernel_size), C]`.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 2019

</div>
