Skip to content
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

[proto] Speed improvement for autocontrast op #6811

Merged
merged 3 commits into from
Oct 24, 2022

Conversation

vfdev-5
Copy link
Collaborator

@vfdev-5 vfdev-5 commented Oct 21, 2022

Results:

[---------------- Autocontrast cpu torch.uint8 ---------------]
                     |  autocontrast stable  |  autocontrast v2
1 threads: ----------------------------------------------------
      (3, 400, 400)  |          969          |        844      
6 threads: ----------------------------------------------------
      (3, 400, 400)  |          320          |        274      

Times are in microseconds (us).

[--------------- Autocontrast cuda torch.uint8 ---------------]
                     |  autocontrast stable  |  autocontrast v2
1 threads: ----------------------------------------------------
      (3, 400, 400)  |          200          |        150      
6 threads: ----------------------------------------------------
      (3, 400, 400)  |          201          |        149      

Times are in microseconds (us).

[--------------- Autocontrast cpu torch.float32 --------------]
                     |  autocontrast stable  |  autocontrast v2
1 threads: ----------------------------------------------------
      (3, 400, 400)  |          529          |        418      
6 threads: ----------------------------------------------------
      (3, 400, 400)  |          201          |        157      

Times are in microseconds (us).

[-------------- Autocontrast cuda torch.float32 --------------]
                     |  autocontrast stable  |  autocontrast v2
1 threads: ----------------------------------------------------
      (3, 400, 400)  |          166          |        115      
6 threads: ----------------------------------------------------
      (3, 400, 400)  |          165          |        114      

Times are in microseconds (us).

cc @datumbox @bjuncek @pmeier

Comment on lines +231 to +232
minimum = image.amin(dim=(-2, -1), keepdim=True).to(dtype)
maximum = image.amax(dim=(-2, -1), keepdim=True).to(dtype)
Copy link
Collaborator Author

@vfdev-5 vfdev-5 Oct 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use torch.aminmax here as it does not support tuple of dims. Reshaping the input does not improve runtime.

Copy link
Contributor

@datumbox datumbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Just one question:

@datumbox datumbox merged commit 3dd2e3d into pytorch:main Oct 24, 2022
facebook-github-bot pushed a commit that referenced this pull request Oct 27, 2022
Summary:
* WIP

* Updates to speed up autocontrast

Reviewed By: YosuaMichael

Differential Revision: D40722901

fbshipit-source-id: 9bcf2acd0399bac541cf56a40771971b9ebaba79

Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
@vfdev-5 vfdev-5 deleted the proto-improve-autocontrast branch January 30, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants