To index an Aten tensor properly, you need to take into account it’s size, stride and storageOffset (not sure about the exact name of the last in Aten).
At the moment, your cuda kernel only considers the size and assume storageOffset=0 and stride is the one of a contiguous tensor.
You can either adapt your kernel to take all of them into account, or add a .clone() before your kernel to make sure that your assumptions will be verified.