I have such a simple method in my model
def get_normal(self, std):
if <here I need to know which device is used> :
eps = torch.cuda.FloatTensor(std.size()).normal_()
eps = torch.FloatTensor(std.size()).normal_()
To work efficiently, it needs to know which device is currently used (CPU or GPU).
I was looking for something like
model.is_cuda - but different tensors can be placed on different devices, so probably there is something like
std.device_context, but I haven’t found such method either.
What is recommended to handle such situations?