diff --git a/ivy/functional/backends/paddle/device.py b/ivy/functional/backends/paddle/device.py index 9360fa702f1cd..3d732ec9ee9af 100644 --- a/ivy/functional/backends/paddle/device.py +++ b/ivy/functional/backends/paddle/device.py @@ -34,7 +34,11 @@ def to_device( device = as_native_dev(device) if device.is_cpu_place() and not x.place.is_cpu_place(): return x.cpu() - elif device.is_gpu_place() and not x.place.is_gpu_place(): + elif (device.is_gpu_place() and not x.place.is_gpu_place()) or ( + x.place.is_gpu_place() + and device.is_gpu_place() + and x.gpu_device_id() != device.gpu_device_id() + ): return x.cuda(device.gpu_device_id()) else: return x