A classical way to obtain this bug is to use transposition. If you do
x = torch.Tensor(5,2)
y = x.t()

Then, the storage of y is still the same than the one of x. You can check:
x.fill_(0)
 0  0
 0  0
 0  0
 0  0
 0  0
[torch.FloatTensor of size 5x2]

y
 0  0  0  0  0
 0  0  0  0  0
[torch.FloatTensor of size 2x5]

That way, y[0,4] exists, but it does not exist in the storage of y, that is the storage of x. So y is not contiguous (y[0,4] is missing in the storage). If you try:
y.view(-1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: input is not contiguous at /b/wheel/pytorch-src/torch/lib/TH/generic/THTensor.c:231

So you have to make y contiguous with tensor.contiguous()