I don’t know where the code is coming from and if

But still not sure why i am not able to convert to floatTensor.

is a new issue or related to the device mismatch.
Your current code is unfortunately still not executable.
To debug further, check the stacktrace of the error message and narrow down the line of code which is failing. Once you have it, check the device attribute of all used tensors in this operation and see which one creates the device mismatch. Afterwards track down where this tensor is coming from and how it was created. In case it’s hard-coded as a CPUTensor, use the to(device) method to move it to the device or register it properly as a parameter or buffer, if applicable.