fangwei123456:

contiguous


Thanks! I have another question, which is how to set contiguous for some tensors? For example:

import torch

def set_contiguous(args_list: list):
    for i in range(args_list.__len__()):
        args_list[i] = args_list[i].contiguous()

device = 'cuda:0'
x = torch.rand([2, 3, 4], device=device).transpose(0, 2)
y = torch.zeros_like(x)
args_list = [x, y]
set_contiguous(args_list)
print(x.is_contiguous())

The outputs are:
False
As you said, args_list[i] = args_list[i].contiguous() creates new tensor, and x, y are not set to contiguous tensors. How can I define a correct set_contiguous function?