Python and C++ source code for moving tensors from CPU to GPU

I’m trying to find the source code of the operation to move tensors from CPU to GPU in PyTorch:

data = data.to(device) 

However, I’ve checked for many places on Github, but cannot find both the Python code and C++ code for this operation. Does anyone know where the function calls and interfaces for moving tensors between devices are defined? Any help would be appreciated!

You can find the implementation of to() here, which should eventually call this for a device to device copy and this for a host to device or vice versa copy.