---
title: "fold"
sidebar_label: "fold"
description: "Kotlin binding reference: fold."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.runtime](../index.md)/[Ops](index.md)/[fold](fold.md)

# fold

[common]\
fun [fold](fold.md)(input: [Tensor](../Tensor/index.md), outputSize: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html), kernelSize: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html), dilation: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) = longArrayOf(), padding: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) = longArrayOf(), stride: [LongArray](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long-array/index.html) = longArrayOf(), mode: [PadMode](../PadMode/index.md) = PadMode.CONSTANT, value: [Double](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-double/index.html)? = null): [Tensor](../Tensor/index.md)

`fold(input: Tensor, outputSize: LongArray, kernelSize: LongArray, dilation: LongArray = longArrayOf(), padding: LongArray = longArrayOf(), stride: LongArray = longArrayOf(), mode: PadMode = PadMode.CONSTANT, value: Double? = null)`: the `fold` operator. col2im: the inverse of `unfold`; it sums overlapping windows back into a channels-last image. Input `[N, L, prod(kernel_size), C]`; overlapping window contributions ADD (so `fold(unfold(x))` multiplies overlapped elements by their coverage count).