I defined a function in which there’re temporary variables are defined, for example:
def foo(input_variable):    
    tmp = Variable(torch.zeros(input_variable.size()))    
    return torch.cat((input_variable, tmp), 1)       

This function runs well on CPU, however when run on GPU, it will break because tmp is created on CPU by default.
Is there any elegant way to make it transparent? I.e., tmp will be created on the same device with input_variable?