Thanks! It seems hard to find a real ‘inplace’ function to make ‘x, y’ contiguous. Now I use the outputs to overlap inputs, which behaves like ‘inplace’:
import torch

def set_contiguous(*args):
    ret = []
    for item in args:
        ret.append(item.contiguous())
    return ret
device = 'cuda:0'
x = torch.rand([2, 3, 4], device=device).transpose(0, 2)
y = torch.zeros_like(x)
x, y = set_contiguous(x, y)
print(x.is_contiguous())