---
title: "sliceTensor(_:dimension:start:length:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/slicetensor(_:dimension:start:length:name:)"
---

# sliceTensor(_:dimension:start:length:name:)

Creates a slice operation and returns the result tensor.

## Declaration

```swift
func sliceTensor(_ tensor: MPSGraphTensor, dimension dimensionIndex: Int, start: Int, length: Int, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: The tensor to be sliced.
- `dimensionIndex`: The dimension to slice.
- `start`: The starting index of the slice, can be negative to count from the end of the tensor dimension.
- `length`: The length of the slice.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object.
