mindspore.Tensor.stride

View Source On Gitee
Tensor.stride(dim=None)[source]

The stride to jump from one element to the next in the input dim. When no parameters are passed in, a list of stride for all dimensions is returned.

Parameters

dim (int) – The dim of stride from one element to the next.

Returns

Int, the stride of tensor.

Raises

TypeErrordim is not an int.

Examples

>>> import mindspore as ms
>>> x = ms.Tensor([[1, 2, 3, 4, 5], [6, 7, 8, 9, 10]], dtype=ms.float32)
>>> x.stride()
[5, 1]