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

# stack(_:axis:name:)

Creates a stack operation and returns the result tensor.

## Declaration

```swift
func stack(_ inputTensors: [MPSGraphTensor], axis: Int, name: String?) -> MPSGraphTensor
```

## Parameters

- `inputTensors`: The input tensors.
- `axis`: The dimension to stack tensors into result. Must be in range: -rank + 1 <= dimension < rank + 1.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object.

## Discussion

Discussion Stacks all input tensors along axis into a result tensor of rank + 1. Tensors must be broadcast compatible along all dimensions except axis, and have the same type.
