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

extend equalize to all integer and floating dtypes #6851

Merged
merged 3 commits into from
Oct 27, 2022

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Oct 27, 2022

Addresses #6840 for equalize. Unfortunately, I need to walk back on my comment #6847 (comment): although it is possible to extend the algorithm to the other integer dtypes, it is unfeasible in practice since it blows up memory for anything larger than torch.int16. Thus, I opted to convert to torch.uint8 unconditionally. Fortunately, that also eliminates the decision which integer dtype we convert floating point inputs to and whether we expose this choice to the user.

Since there is no change to the algorithm, I didn't benchmark this change. The only thing the benchmark will measure is how fast the conversion to and from torch.uint8 happens. If you want to see some numbers, please let me know what exactly.

cc @vfdev-5 @datumbox @bjuncek

):
image_loader = ImageLoader(
fn, shape=(get_num_channels(color_space), *spatial_size), dtype=torch.uint8, color_space=color_space
fn, shape=(get_num_channels(color_space), *spatial_size), dtype=dtype, color_space=color_space
Copy link
Collaborator Author

@pmeier pmeier Oct 27, 2022

Choose a reason for hiding this comment

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

Although there is a quite a diff in this file, the only functional change is to also test torch.float32 next to torch.uint8. The rest is just refactoring to account for that.

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, some non-blocking nits.

torchvision/prototype/transforms/functional/_color.py Outdated Show resolved Hide resolved
torchvision/prototype/transforms/functional/_color.py Outdated Show resolved Hide resolved
@pmeier pmeier merged commit b522aca into pytorch:main Oct 27, 2022
@pmeier pmeier deleted the equalize-dtypes branch October 27, 2022 15:28
facebook-github-bot pushed a commit that referenced this pull request Oct 31, 2022
Summary:
* extend equalize to all integer and floating dtypes

* address nits

Reviewed By: datumbox

Differential Revision: D40851020

fbshipit-source-id: 63b36f02e630b9c230431527b359876fedc52f3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants