Rate this Page

torch.Tensor.stride#

Tensor.stride(dim)tupleorint#

Returns the stride ofself tensor.

Stride is the jump necessary to go from one element to the next one in thespecified dimensiondim. A tuple of all strides is returned when noargument is passed in. Otherwise, an integer value is returned as the stride inthe particular dimensiondim.

Parameters

dim (int,optional) – the desired dimension in which stride is required

Example:

>>>x=torch.tensor([[1,2,3,4,5],[6,7,8,9,10]])>>>x.stride()(5, 1)>>>x.stride(0)5>>>x.stride(-1)1