---
title: flattened()
framework: coreml
role: symbol
role_heading: Instance Method
path: coreml/mltensor/flattened()
---

# flattened()

Reshape to a one-dimensional tensor.

## Declaration

```swift
func flattened() -> MLTensor
```

## Discussion

Discussion note: Flattening a zero-dimensional tensor will return a one-dimensional tensor. For example: let x = MLTensor(shape: [2, 2], scalars: [1, 2, 3, 4], scalarType: Float.self) let y = x.flattened() y.shape // is [4]

## See Also

### Reshaping the tensor

- [reshaped(to:)](coreml/mltensor/reshaped(to:).md)
