<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Metal",
  "identifier" : "/documentation/Metal/MTLTensorDescriptor/strides",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Metal"
    ],
    "preciseIdentifier" : "c:objc(cs)MTLTensorDescriptor(py)strides"
  },
  "title" : "strides"
}
-->

# strides

An array of strides, in elements, one for each dimension of this tensor, if applicable.

```
@NSCopying var strides: MTLTensorExtents? { get set }
```

## Discussion

The stride value of the array’s first element needs to be exactly `1`, because it is the innermost dimension.
The strides for the subsequent dimensions can have different requirements based on the value of other properties.
When the [`usage`](/documentation/Metal/MTLTensorDescriptor/usage) property includes the [`machineLearning`](/documentation/Metal/MTLTensorUsage/machineLearning) option:

- The second element of the array needs to be a multiple of 64 bytes.
- The rest of the elements in the array need to equal the product of the previous stride multiplied with the size of
  the previous dimension. For example: `strides[i] = strides[i - 1] * dimensions[i - 1]`.

When [`dataType`](/documentation/Metal/MTLTensorDescriptor/dataType) is [`MTLTensorDataType.int2`](/documentation/Metal/MTLTensorDataType/int2), [`MTLTensorDataType.uint2`](/documentation/Metal/MTLTensorDataType/uint2),
[`MTLTensorDataType.int4`](/documentation/Metal/MTLTensorDataType/int4), [`MTLTensorDataType.uint4`](/documentation/Metal/MTLTensorDataType/uint4),
[`MTLTensorDataType.metalFloat4e2m1`](/documentation/Metal/MTLTensorDataType/metalFloat4e2m1), [`MTLTensorDataType.metalFloat8e4m3`](/documentation/Metal/MTLTensorDataType/metalFloat8e4m3),
[`MTLTensorDataType.metalFloat8e5m2`](/documentation/Metal/MTLTensorDataType/metalFloat8e5m2), or [`MTLTensorDataType.metalFloat8ue8m0`](/documentation/Metal/MTLTensorDataType/metalFloat8ue8m0),
all elements of the array, except for the first element, need to be a multiple of 128 bytes.

> Tip: You can improve runtime performance by using strides that are multiples of 128, even when it’s not a requirement.

Only set this property when creating tensors from a buffer.

---

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)