-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add device check to io.decode_image
#7406
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
Conversation
It only works for CPU tensors, so raise an error if called with non-CPU tensor
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/7406
Note: Links to docs will display an error until the docs builds have been completed. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
NicolasHug
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @malfet , some suggestion below but I'll approve to unblock the cherry-picking
Co-authored-by: Nicolas Hug <[email protected]>
| @needs_cuda | ||
| def test_decode_image_cuda_raises(): | ||
| data = torch.randint(0, 127, size=(255,), device="cuda", dtype=torch.uint8) | ||
| exception_raised = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this can be removed now
| exception_raised = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be a nit, since (amongst other things) it breaks the lint workflow: https://app.circleci.com/jobs/github/pytorch/vision/1851401
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Hey @malfet! You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py |
Summary: Co-authored-by: Nicolas Hug <[email protected]> Reviewed By: vmoens Differential Revision: D44416571 fbshipit-source-id: 9009b4353c3b5a18df8fb7688a92614e49f7a661
It only works for CPU tensors, so raise an error if called with non-CPU tensor
Add unit test to validate for that
Followups: one also needs to check that tensors passed to this function is contiguous
Fixes #7391