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()
index = torch.randperm(batch_size)

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

Above code is from
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