<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/depth(toSpace2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)depthToSpace2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:"
  },
  "title" : "depth(toSpace2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:)"
}
-->

# depth(toSpace2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:)

Creates a depth-to-space2D operation and returns the result tensor.

```
func depth(toSpace2DTensor tensor: MPSGraphTensor, widthAxisTensor: MPSGraphTensor, heightAxisTensor: MPSGraphTensor, depthAxisTensor: MPSGraphTensor, blockSize: Int, usePixelShuffleOrder: Bool, name: String?) -> MPSGraphTensor
```

## Parameters

`tensor`

The input tensor.

`widthAxisTensor`

A scalar tensor that contains the axis that defines the fastest running dimension within the block.

`heightAxisTensor`

A scalar tensor that contains the axis that defines the 2nd fastest running dimension within the block.

`depthAxisTensor`

A scalar tensor that contains the axis that defines the destination dimension, where to copy the blocks.

`blockSize`

The size of the square spatial sub-block.

`usePixelShuffleOrder`

A parameter that controls the layout of the sub-blocks within the depth dimension.

`name`

The name for the operation.

## Return Value

A valid MPSGraphTensor object.

## Discussion

This operation outputs a copy of the input tensor, where values from the
`depthAxisTensor` dimension are moved in spatial blocks of size `blockSize` to the
`heightAxisTensor` and `widthAxisTensor` dimensions.  Use the `usePixelShuffleOrder` parameter
to control how the data within spatial blocks is ordered in the
`depthAxisTensor` dimension: with `usePixelShuffleOrder = YES` MPSGraph stores the values
of the spatial block contiguosly within the `depthAxisTensor` dimension, whereas
without it they are stored interleaved with existing values in the `depthAxisTensor` dimension.
This operation is the inverse of [`space(toDepth2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:)`](/documentation/MetalPerformanceShadersGraph/MPSGraph/space(toDepth2DTensor:widthAxisTensor:heightAxisTensor:depthAxisTensor:blockSize:usePixelShuffleOrder:name:)).

---

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)