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

Fixed typing exception throwing issues with JIT #3029

Merged
merged 3 commits into from
Nov 19, 2020

Conversation

frgfm
Copy link
Contributor

@frgfm frgfm commented Nov 19, 2020

As per #3027, some JIT issues were introduced in #2860 with typing, that weren't caught initially by tests.
This PR addresses the issues related to the densenet module.

This PR should close #3027

@frgfm
Copy link
Contributor Author

frgfm commented Nov 19, 2020

I'm still getting the following error with mypy:

torchvision/models/densenet.py:74: error: Name 'forward' already defined on line 70  [no-redef]
        @torch.jit._overload_method  # noqa: F811
         ^
torchvision/models/densenet.py:80: error: Name 'forward' already defined on line 70  [no-redef]
        def forward(self, input: Tensor) -> Tensor:  # noqa: F811
        ^

But I'm not very knowledgeable on JIT overlead decorator. Should we accept that some mypy tests fail? Or is there a way around this without having JIT issues? @fmassa @pmeier

@pmeier
Copy link
Collaborator

pmeier commented Nov 19, 2020

Should we accept that some mypy tests fail?

Sort of. I suggest we simply exclude densenet.py from the type check for now and only re-enable it if the issue with torchscript is fixed.

You can include

[mypy-torchvision.models.densenet.*]
ignore_errors=True

into the mypy.ini file.

@frgfm
Copy link
Contributor Author

frgfm commented Nov 19, 2020

Alright, it should be good to go now 👌

@frgfm frgfm requested a review from pmeier November 19, 2020 11:28
@pmeier pmeier requested a review from fmassa November 19, 2020 11:35
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

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

Thanks!

@fmassa fmassa merged commit 585ce2c into pytorch:master Nov 19, 2020
@frgfm frgfm deleted the densenet-typingfix branch November 19, 2020 14:49
bryant1410 pushed a commit to bryant1410/vision-1 that referenced this pull request Nov 22, 2020
* refactor: Fixed typing exception throwing issues with JIT

* style: Added back mypy typing to forward

* chore: Added back densenet module as mypy exception
vfdev-5 pushed a commit to Quansight/vision that referenced this pull request Dec 4, 2020
* refactor: Fixed typing exception throwing issues with JIT

* style: Added back mypy typing to forward

* chore: Added back densenet module as mypy exception
@pmeier
Copy link
Collaborator

pmeier commented Feb 9, 2021

@frgfm Do you want to have another go at this as pytorch/pytorch#51675 fixed the behavior of type: ignore comments for torch.jit?

@frgfm
Copy link
Contributor Author

frgfm commented Feb 9, 2021

@pmeier Thanks for the mention! Yes, it would be bad karma for me to leave this unfinished haha

@frgfm
Copy link
Contributor Author

frgfm commented Feb 14, 2021

@pmeier Here it is #3395 !

@frgfm frgfm mentioned this pull request Oct 26, 2022
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.

#2860 regressed torch.jit.script(densenet161).save
4 participants