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

# flatten2D(_:axis:name:)

Creates a flatten2D operation and returns the result tensor.

## Declaration

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

## Parameters

- `tensor`: The tensor to be flattened.
- `axis`: 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.
