Some tensor operations, like transpose, do not perform memory copy and only change the strides of the tensor (and pixel shuffle is one of this cases)
tensor.contiguous() will make sure that the data is contiguous in memory, and if not will perform a copy so that it becomes contiguous. This is necessary for some functions to work (for example, .view only accepts contiguous tensors).