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

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

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

# flatten

[common]\
fun [flatten](flatten.md)(input: [Tensor](../Tensor/index.md), startDim: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) = 0, endDim: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) = -1L): [Tensor](../Tensor/index.md)

`flatten(input: Tensor, startDim: Long = 0L, endDim: Long = -1L)`: the `flatten` operator. Collapse the INCLUSIVE dim range `[start_dim, end_dim]` into one dim; the defaults collapse everything to 1-D. Returns a view sharing storage when the input's stride layout factors into the merged shape (contiguous inputs always do); copies into a fresh dense tensor otherwise.