RuntimeError: input is not contiguous

It means that your tensor is not a single block of memory, but a block with holes. view can be only used with contiguous tensors, so if you need to use it here, just call .contiguous() before.

You can find some more details on the memory layout in numpy docs. Torch uses the same representation.

27 Likes