Indexing cuda tensor with cpu tensor

What is the difference between using cuda tensor and cpu tensor when indexing cuda tensor?
For example,

if use_cuda:
index = torch.randperm(batch_size).cuda()
else:
index = torch.randperm(batch_size)

mixed_x = lam * x + (1 - lam) * x[index, :]
y_a, y_b = y, y[index]

Above code is from https://github.com/facebookresearch/mixup-cifar10
Is it faster? (I see no difference between them when training)

Depending how much computation u r doing u might not see the difference but if u r performing heavy computations then u’ll see that it’s faster

1 Like