Hmm I’m afraid there is not.
Once again I doubt that if the code is properly done it can fall in issues like that. I imagine that original authors also used a gpu. Therefore it should be somehow adapted to a gpu allocation.
Anyway if you plan to use that code, reformating to be adapted to cpu/gpu/multi-gpu is not a loss of time.
In the end, you are creating a new tensor there (which is the only case in which you have to choose allocation device)