What is the source code of torch.Tensor.cpu()

Recently I have found that as the amount of communication increases in torch.Tensor.cpu(), the bus bandwidth (is calculated by amount of communication / latency) will increase accordingly, but when the amount of communication is 16MB, there will be a sudden drop in bus bandwidth (the latency increases largely), so I want to see the implementation. But where can I find the source code of torch.Tensor.cpu()

https://pytorch.org/docs/stable/generated/torch.Tensor.cpu.html#torch.Tensor.cpu

The document only describe the function of torch.Tensor.cpu, but this document doesn’t give the source code of this method.

True, couldn’t find it either.

Actually I think I find some source code related to this function:pytorch/aten/src/ATen/core/Tensor.cpp at main · pytorch/pytorch · GitHub. This function will be called when calling cpu(), but this function will call another function that may be generated by code generation. So we cannot view the source code.

1 Like