Skip to content

make fill defaultdict an implementation detail #7258

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

Merged
merged 5 commits into from
Feb 16, 2023

Conversation

pmeier
Copy link
Collaborator

@pmeier pmeier commented Feb 15, 2023

Towards #7159. For v2 we added more complex handling for fill to enable filling with different values based on the type. Internally this is handled by a defaultdict:

def _setup_fill_arg(fill: Union[FillType, Dict[Type, FillType]]) -> Dict[Type, FillTypeJIT]:

However, there is no need to leak that into a public attribute:

self.fill = _setup_fill_arg(fill)

This PR simply leaves parameter the user passed in the self.fill attribute and moves the defaultdict to self._fill

cc @vfdev-5 @bjuncek

Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

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

Minor comments but LGTM, thanks Philip

@pmeier
Copy link
Collaborator Author

pmeier commented Feb 15, 2023

In the transforms v1 tests we have

vision/test/test_transforms.py

Lines 1871 to 1872 in d805aea

t = transforms.RandomRotation(0, fill=None)
assert t.fill == 0

That will still not be supported by this change. I don't really understand the whole fill=0 vs. fill=None thing. @vfdev can you chime in here?

@NicolasHug NicolasHug mentioned this pull request Feb 15, 2023
49 tasks
@vfdev-5
Copy link
Collaborator

vfdev-5 commented Feb 15, 2023

I don't really understand the whole fill=0 vs. fill=None thing.

This story is certainly a tradeoff between what was supported at that moment supported values (by Pillow, pytorch) and jit, consistency etc.

For RandomRotation fill arg, it seems like the story was like that:

Today there are still few minor issues and inconcistencies for fill arg:

Also check this comment: #6623 (comment)

@pmeier pmeier merged commit efd6bc0 into pytorch:main Feb 16, 2023
@pmeier pmeier deleted the fill-private branch February 16, 2023 17:57
facebook-github-bot pushed a commit that referenced this pull request Mar 28, 2023
Reviewed By: vmoens

Differential Revision: D44416563

fbshipit-source-id: 3ac6e3f6a7b6cfa4766c0a4a50b643d47a35e265
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.

4 participants