-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[docs] Unclear if to_pil_image / to_tensor copy or zero-copy for CPU<->CPU #3783
Comments
I believe these two methods copy. This is because they go from one backend to a completely different one (say from PIL to PyTorch Tensor stored on GPU or vice-versa). |
This is worth double-checking but in theory a no-copy should be possible, and I agree it would be valuable info to explicitly document this. PIL images implement |
I'm meaning CPU<-> CPU conversions of course, where zero-copy conversion theoretically is possible, e.g. identically to NumPy <-> PyTorch conversion If PIL implements |
Those functions could be zero-copy, except that we perform multiplication / division by 255, which means there will be overhead involved. If you want zero-overhead, I would recommend using |
Some relevant discussion about copying or not here: #3813 (review) |
It currently uses a vague language "convert". It's not sure if "conversion" incurs a copy or not
cc @vfdev-5
The text was updated successfully, but these errors were encountered: