Returns the jump necessary to go from one element to the next one in the
specified dimension dim
. Example:
> x = torch.Tensor(4,5):zero() > print(x) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 [torch.Tensor of dimension 4x5] --- elements in a column are contiguous in memory > return x:stride(1) 1 --- to go from one element to the next one in a row --- we need here to jump the size of the column > return x:stride(2) 4
Note also that in Torch
elements in the same column [elements along the first dimension]
are contiguous in memory for a matrix [tensor].