Contents

strides

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

Declaration

@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 property includes the 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 is MTLTensorDataType.int2, MTLTensorDataType.uint2, MTLTensorDataType.int4, MTLTensorDataType.uint4, MTLTensorDataType.metalFloat4e2m1, MTLTensorDataType.metalFloat8e4m3, MTLTensorDataType.metalFloat8e5m2, or MTLTensorDataType.metalFloat8ue8m0, all elements of the array, except for the first element, need to be a multiple of 128 bytes.

Only set this property when creating tensors from a buffer.