<!--
{
  "availability" : [
    "iOS: 18.2.0 -",
    "iPadOS: 18.2.0 -",
    "macCatalyst: 18.2.0 -",
    "macOS: 15.2.0 -",
    "tvOS: 18.2.0 -",
    "visionOS: 2.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/sliceTensor(_:start:sizeTensor:squeezeMask:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)sliceTensor:startTensor:sizeTensor:squeezeMask:name:"
  },
  "title" : "sliceTensor(_:start:sizeTensor:squeezeMask:name:)"
}
-->

# sliceTensor(_:start:sizeTensor:squeezeMask:name:)

Creates a slice operation and returns the result tensor.

```
func sliceTensor(_ tensor: MPSGraphTensor, start startTensor: MPSGraphTensor, sizeTensor: MPSGraphTensor, squeezeMask: UInt32, name: String?) -> MPSGraphTensor
```

## Parameters

`tensor`

The Tensor to be sliced.

`startTensor`

The tensor that specifies the starting points for each dimension.

`sizeTensor`

The tensor that specifies the size of the result for each dimension.

`squeezeMask`

A bitmask that indicates dimensions the operation will squeeze out from the result.

`name`

The name for the operation.

## Return Value

A valid MPSGraphTensor object.

## Discussion

Slices a tensor starting from `startTensor`, stopping short before `startTensor + endTensor` stepping
a single pace between each value. Semantics based on
[TensorFlow Strided Slice Op](https://www.tensorflow.org/api_docs/python/tf/strided_slice).

---

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)