As an example shown below, I don’t move index to the GPU but the code still runs. My question is: Will adding index = index.cuda() help improve performance? and why?
class MyModule(nn.Module):
    def __init__(self):
        super(MyModule, self).__init__()
        self.linear = nn.Linear(1000, 200)
        
    def forward(self, data):
        index = torch.randint(1000, (1000,))  # should I add index = index.cuda()?
        return self.linear(data[:, index])
    
a = MyModule().cuda()
b = torch.randn(1000, 1000).cuda()
a(b)