title: pytorch tensor stride - how it works
body: <p>PyTorch doesn't seem to have documentation for <code>tensor.stride()</code>.
  Can someone confirm my understanding?</p>
  <p>My questions are three-fold.</p>
  <ol>
  <li><p>Stride is for accessing an element in the storage. So stride size will be the same as the dimension of the tensor. Correct?</p>
  </li>
  <li><p>For each dimension, the corresponding element of stride tells how much it takes to move along the 1-dimensional storage. Correct?</p>
  </li>
  </ol>
  <p>For example:</p>
  <pre><code>In [15]: x = torch.arange(1,25)
  
  In [16]: x
  Out[16]:
  tensor([ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18
  , 19, 20, 21, 22, 23, 24])
  
  In [17]: a = x.view(4,3,2)
  
  In [18]: a
  Out[18]:
  tensor([[[ 1,  2],
           [ 3,  4],
           [ 5,  6]],
  
          [[ 7,  8],
           [ 9, 10],
           [11, 12]],
  
          [[13, 14],
           [15, 16],
           [17, 18]],
  
          [[19, 20],
           [21, 22],
           [23, 24]]])
  
  In [20]: a.stride()
  Out[20]: (6, 2, 1)
  </code></pre>
  <ol start="3">
  <li>How does having this information help perform tensor operations efficiently? Basically this is showing the memory layout. So how does it help?</li>
  </ol>