Unwrap features before passing them into a kernel#6807
Merged
pmeier merged 8 commits intopytorch:mainfrom Oct 21, 2022
Merged
Conversation
pmeier
commented
Oct 20, 2022
datumbox
reviewed
Oct 21, 2022
Contributor
|
@pmeier can you provide time measurements on a datapipeline (e.g. image classification + AA + RandomErasing, #6681 (comment)) |
Contributor
Author
The diff that we are interested in: - 16747 0.206 0.000 0.255 0.000 /home/philip/git/pytorch/torchvision/torchvision/prototype/features/_feature.py:63(__torch_function__)
- 14487 0.022 0.000 0.022 0.000 {method 'as_subclass' of 'torch._C._TensorBase' objects}
+ 18896 0.032 0.000 0.032 0.000 {method 'as_subclass' of 'torch._C._TensorBase' objects}Meaning we are looking at a |
Contributor
|
@pmeier by time measurements I meant torch benchmarks and not cprofile (which may be less reliable) |
facebook-github-bot
pushed a commit
that referenced
this pull request
Oct 21, 2022
Summary: * unwrap features before calling the kernels * revert double unwrapping * cleanup * remove debug raise * more cleanup Reviewed By: YosuaMichael Differential Revision: D40588165 fbshipit-source-id: 3ce277bbe4f47124f572ca8cd185795b5917fe3e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6781 by going with the
self.as_subclass(torch.Tensor)proposal. After this PR, there are no more__torch_function__calls in the whole pipeline.In fact, it almost renders #6681 obsolete:
ndim,device, anddtypeare no longer accessed. Evenshapeis only accessed 4 times:vision/torchvision/prototype/transforms/functional/_meta.py
Lines 19 to 22 in 246de07
vision/torchvision/prototype/transforms/functional/_meta.py
Lines 40 to 41 in 246de07
vision/torchvision/prototype/transforms/functional/_meta.py
Lines 78 to 79 in 246de07
vision/torchvision/prototype/transforms/functional/_meta.py
Lines 91 to 92 in 246de07
Since they all only indirectly access
.shapethrough properties we have anywayvision/torchvision/prototype/features/_image.py
Lines 105 to 111 in 246de07
vision/torchvision/prototype/features/_video.py
Lines 57 to 67 in 246de07
we could also opt to move the
with DisableTorchFunction()context manager there and completely removevision/torchvision/prototype/features/_feature.py
Lines 132 to 152 in 246de07
cc @vfdev-5 @datumbox @bjuncek