Deeploy.TilingExtension.TilingCodegen.stridesFromShape

Deeploy.TilingExtension.TilingCodegen.stridesFromShape(shape: Sequence[int]) Tuple[int, ...]

Calculate memory strides from a tensor shape.

Computes the stride values for each dimension of a tensor based on its shape. Strides represent the number of elements to skip in memory when moving one position along each dimension.

Parameters:

shape (Sequence[int]) – The shape of the tensor as a sequence of dimension sizes.

Returns:

The stride values for each dimension, where the last dimension has stride 1 and earlier dimensions have progressively larger strides.

Return type:

Tuple[int, …]

Notes

Strides are computed assuming row-major (C-style) memory layout. The stride for dimension i is the product of all dimensions after i.

Examples

>>> stridesFromShape([2, 3, 4])
(12, 4, 1)
>>> stridesFromShape([5, 6])
(6, 1)