<!--
{
  "availability" : [
    "iOS: 15.4.0 -",
    "iPadOS: 15.4.0 -",
    "macCatalyst: 15.4.0 -",
    "macOS: 12.3.0 -",
    "tvOS: 15.4.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/stack(_:axis:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)stackTensors:axis:name:"
  },
  "title" : "stack(_:axis:name:)"
}
-->

# stack(_:axis:name:)

Creates a stack operation and returns the result tensor.

```
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

A valid MPSGraphTensor object.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)