Indexing tensor on cuda

Hi,

I am trying to understand how indexing in cuda works, I noticed that if I have a tensor in CUDA, and then use index_select depending on whether the indices are sorted or unsorted I get different results. if indices are sorted, then I get the correct values. however if they are not, I tend to get zero for some of the values. The code setting is as follows :

device =torch.device(“cuda:0” if torch.cuda.is_available() else “cpu”)
torch.cuda.get_device_name(0)
torch.backends.cudnn.deterministic = True
torch.set_deterministic(True)

The original tensor is created inside a function. I have noticed that if I instead not use a function, this doesn’t occur

Could you post a minimal code snippet to reproduce this issue as well as information about your current setup (PyTorch, CUDA version, used GPU, etc.)?