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

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

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

# diff

[common]\
fun [diff](diff.md)(input: [Tensor](../Tensor/index.md), n: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) = 1, dim: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) = -1L, prepend: [Tensor](../Tensor/index.md)? = null, append: [Tensor](../Tensor/index.md)? = null): [Tensor](../Tensor/index.md)

`diff(input: Tensor, n: Long = 1L, dim: Long = -1L, prepend: Tensor? = null, append: Tensor? = null)`: the `diff` operator. n-th order finite difference along `dim`. Each application shortens the axis by one, so the output's `dim` extent is `size(dim) - n`. `prepend` / `append` are concatenated onto the axis before differencing (they must match `input`'s shape outside `dim`).