[prototype] Speed up adjust_sharpness_image_tensor#6930
Merged
datumbox merged 2 commits intopytorch:mainfrom Nov 8, 2022
Merged
[prototype] Speed up adjust_sharpness_image_tensor#6930datumbox merged 2 commits intopytorch:mainfrom
adjust_sharpness_image_tensor#6930datumbox merged 2 commits intopytorch:mainfrom
Conversation
pmeier
approved these changes
Nov 8, 2022
Contributor
pmeier
left a comment
There was a problem hiding this comment.
One question otherwise LGTM if CI is green.
| needs_unsquash = False | ||
|
|
||
| output = _blend(image, _FT._blurred_degenerate_image(image), sharpness_factor) | ||
| kernel_dtype = image.dtype if fp else torch.float32 |
Contributor
There was a problem hiding this comment.
To ease review, here is the old implementation:
Comment on lines
+140
to
+142
| # We speed up blending by minimizing flops and doing in-place. The 2 blend options are mathematically equivalent: | ||
| # x+(1-r)*(y-x) = x + (1-r)*y - (1-r)*x = x*r + y*(1-r) | ||
| view.add_(blurred_degenerate.sub_(view), alpha=(1.0 - sharpness_factor)) |
Contributor
There was a problem hiding this comment.
Can push a change like this to _blend or is this a special case here?
Contributor
Author
There was a problem hiding this comment.
It's a special case :( We can do this only because we are allowed to subtract image1 from image2 in place. In all other cases where _blend() is used, we rely on broadcasting do that's not possible.
adjust_sharpness_image_tensoradjust_sharpness_image_tensor
31 tasks
facebook-github-bot
pushed a commit
that referenced
this pull request
Nov 14, 2022
Summary: * Speed up `adjust_sharpness_image_tensor` * Add a comment Reviewed By: NicolasHug Differential Revision: D41265190 fbshipit-source-id: 4ebbd1d7a4d763a77f4af84b2da710f7a981a843
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.
Related to #6818
Performance optimization for the adjust sharpness kernel:
cc @vfdev-5 @bjuncek @pmeier