hash-grid-encoding
hash-grid-encoding copied to clipboard
RuntimeError,data type
Hi there, Thanks for your great work, I tried your example,but it occurred: x1 = (x0 + 1).clamp(max=shape[1]-1) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument max in method wrapper_CUDA_clamp_Tensor)
Same problem
The shape[1] is on cpu, while x0 on gpu. Hence, a possible fix is,
max_val = torch.tensor(shape[1]-1, dtype=x0.dtype, device=x0.device)
x1 = (x0 + 1).clamp(max=max_val)
max_val = torch.tensor(shape[0]-1, dtype=y0.dtype, device=y0.device)
y1 = (y0 + 1).clamp(max=max_val)
Alternatively, casting to integer is also fine,
x1 = (x0 + 1).clamp(max=int(shape[1]-1))
I assume the newly added warning doesn't matter here.