---
title: "flatten2D(_:axisTensor:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/flatten2d(_:axistensor:name:)"
---

# flatten2D(_:axisTensor:name:)

Creates a flatten2D operation and returns the result tensor.

## Declaration

```swift
func flatten2D(_ tensor: MPSGraphTensor, axisTensor: MPSGraphTensor, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: The tensor to be flattened.
- `axisTensor`: A scalar tensor that contains the axis around which to flatten.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object.

## Discussion

Discussion Flattens dimensions before axis to result[0] and dimensions starting from axis to result[1] and returns a rank-2 tensor as result.
