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

Make RandomApply torchscriptable in V2 #7256

Merged
merged 2 commits into from
Feb 15, 2023

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Feb 15, 2023

We missed it before

cc @vfdev-5 @bjuncek @pmeier

Comment on lines +45 to +46
def _extract_params_for_v1_transform(self) -> Dict[str, Any]:
return {"transforms": self.transforms, "p": self.p}
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't understand why, but the transforms key was missing when using _extract_params_for_v1_transform() from the base class.

Copy link
Collaborator

Choose a reason for hiding this comment

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

nn.Module overwrites __setattr__. One of the things it is doing is to not assign other nn.Module's into self.__dict__, but rather into self._modules. Since we only go through self.__dict__, we don't pick up self.transforms since isinstance(nn.ModuleList(...), nn.Module).

Copy link
Member Author

Choose a reason for hiding this comment

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

wow, good catch! thanks for the explanation

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks Nicolas!

@NicolasHug NicolasHug merged commit 3080082 into pytorch:main Feb 15, 2023
@github-actions
Copy link

Hey @NicolasHug!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

@NicolasHug NicolasHug mentioned this pull request Feb 15, 2023
49 tasks
facebook-github-bot pushed a commit that referenced this pull request Mar 28, 2023
Reviewed By: vmoens

Differential Revision: D44416608

fbshipit-source-id: 1e8afbc880dacacacbd2f3e543d21cb4b90e5fdf
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