Thank you. Argument device=input.device is not what I tried before. So, I hope it’ll work.
For other readers as additional information,
I guess input is for example tensor I got from the model, and should I also use .cuda() to perform operation with cuda tensor and new tensor like this?
new_tensor = torch.tensor([1.0], device=input.device).cuda()