Solved by David_Reiss in post #2 
              
              
                This looks like a bug with the handling of tensor strides.  We should be able to get it fixed in PyTorch 1.5.  In the mean time, if you change your line to a.append(x[i].clone()), it works around the bug.