Clamp_ not working on GPU

For some reason, clamp_ and clamp don’t work on GPU.
torch version: 0.4.1

import torch
tensor = torch.tensor([[205.6188, 99.7265, 300.2824, 320.4083, 0.9999, 1.0000, 0.0000],[165.0100, 305.5398, 266.4070, 330.8875, 0.9962, 0.9998, 36.0000]]).to(‘cuda’)
img_dim = torch.tensor([3.8942, 2.5938, 3.8942, 2.5938]

Why does this fail on GPU

tensor[:, :4] = tensor[:, :4].clamp_(0, 416) * img_dim
Traceback (most recent call last):
File “”, line 1, in
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #2 ‘other’

But this works just fine:

tensor = tensor.to(‘cpu’)
tensor[:, :4] = tensor[:, :4].clamp_(0, 416) * img_dim

Because img_dim is not a cuda tensor, it’s a cpu tensor.

Thanks…