mindspore.Tensor.stride
- 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, optional) – The dim of stride from one element to the next. Default:
None
.- Returns
Int, returns the step size necessary to jump from one element to the next in the specified dimension.
- Raises
TypeError – dim 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]