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

[FX] Fix NoneType annotation in generated code #50777

Closed
wants to merge 1 commit into from

Conversation

jamesr66a
Copy link
Collaborator

@jamesr66a jamesr66a commented Jan 20, 2021

Stack from ghstack:

Previously, when trying to symbolically trace some Modules that had--for example--Union[Tensor, NoneType] as a parameter, execution would fail because the repr for NoneType doesn't map to any name in Python (NoneType is only directly exposed on the types namespace in Python 3.10+). This change makes it so that NoneType is available in the global namespace and ensures that we do not have any collisions with that name.

Old error:

  File "<eval_with_key_0>", line 3, in <module>
    def forward(self, input : torch.Tensor, offsets : typing.Union[torch.Tensor, NoneType] = None, per_sample_weights : typing.Union[torch.Tensor, NoneType] = None) -> torch.Tensor:
NameError: name 'NoneType' is not defined

Differential Revision: D25966026

jamesr66a pushed a commit that referenced this pull request Jan 20, 2021
ghstack-source-id: 0423f8eba3d0a9c8b6ac3e4d6f2030be83015c10
Pull Request resolved: #50777
Copy link
Contributor

@Chillee Chillee left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov
Copy link

codecov bot commented Jan 20, 2021

Codecov Report

Merging #50777 (b733da1) into gh/jamesr66a/355/base (526659d) will increase coverage by 4.93%.
The diff coverage is 100.00%.

@@                    Coverage Diff                    @@
##           gh/jamesr66a/355/base   #50777      +/-   ##
=========================================================
+ Coverage                  75.74%   80.68%   +4.93%     
=========================================================
  Files                       1913     1913              
  Lines                     208155   208155              
=========================================================
+ Hits                      157666   167945   +10279     
+ Misses                     50489    40210   -10279     

@facebook-github-bot
Copy link
Contributor

@jamesr66a merged this pull request in 5205cc1.

@facebook-github-bot facebook-github-bot deleted the gh/jamesr66a/355/head branch January 23, 2021 15:16
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.

None yet

4 participants