Solved by ptrblck in post #2 
              
              
                The posted error is raised, if the tensor it not contiguous in memory and thus view will fail. 
You could either use .reshape instead as suggested in the error message or .contiguous().view(...) alternatively.