Skip to content

[JIT] Fix type annotations of pooling modules#47888

Closed
eellison wants to merge 4 commits intogh/eellison/135/basefrom
gh/eellison/135/head
Closed

[JIT] Fix type annotations of pooling modules#47888
eellison wants to merge 4 commits intogh/eellison/135/basefrom
gh/eellison/135/head

Conversation

@eellison
Copy link
Copy Markdown
Contributor

@eellison eellison commented Nov 13, 2020

Stack from ghstack:

Fix for #45904

All of the pooling modules except MaxUnpool and LPPool return either a Tensor or [Tensor, Tensor]. The current type annotations are inaccurate, and prevent scripting the module if return_indices is set as true in the module.

There's not a great way to make this agree with mypy because the overload is dependent on the value of return_indices, an attribute.

@eellison eellison requested a review from apaszke as a code owner November 13, 2020 01:12
@eellison eellison changed the title Fix type annotations of pooling modules [JIT] Fix type annotations of pooling modules Nov 13, 2020
Fix for #45904

All of the pooling modules except MaxUnpool and LPPool return either a Tensor or a tuple of [Tensor, Tensor]. The current type annotations are inaccurate, and prevent scripting the module if `return_indices` is set as true in the module. 


[ghstack-poisoned]
eellison pushed a commit that referenced this pull request Nov 13, 2020
ghstack-source-id: 5afb56e
Pull Request resolved: #47888
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Nov 13, 2020

🔗 Helpful links

💊 CI failures summary and remediations

As of commit 18ffc48 (more details on the Dr. CI page):


Commit 18ffc48 was recently pushed. Waiting for builds...


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Nov 16, 2020

cc'ing @rgommers and @malfet for visibility

Copy link
Copy Markdown
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

This leaves me a bad taste in my mouth, but that isn't any reason to block landing this particular PR. What is really irritating, though, is that I can't do the less useful type Union[Tensor, Tuple[...]] because JIT will choke on it. There still ought to be a way to mark types to be ignored by JIT.

@rgommers
Copy link
Copy Markdown
Collaborator

rgommers commented Nov 16, 2020

Someone will run into this again when removing the ignore_errors = True in mypy.ini for modules.pooling. And annotating the return as -> Any isn't supported either I think (gh-33844).

Adding a comment above the first def forward in pooling.py would be useful, to avoid the next person re-investigating this and eventually finding this PR.

There still ought to be a way to mark types to be ignored by JIT.

I can't find an existing issue for that so quickly, do you know if there is one?

@eellison
Copy link
Copy Markdown
Contributor Author

@ezyang yea, agreed that would be nice. @rgommers i think this issue ed opened here is related: #39670

@github-actions
Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
Stale pull requests will automatically be closed 30 days after being marked Stale

@github-actions github-actions Bot added the Stale label Jan 29, 2021
@rgommers
Copy link
Copy Markdown
Collaborator

This is about ready to land, modulo adding a comment and a rebase. Could this be landed before the bot closes the PR?

Fix for #45904

All of the pooling modules except MaxUnpool and LPPool return either a `Tensor `or `[Tensor, Tensor]`. The current type annotations are inaccurate, and prevent scripting the module if `return_indices` is set as true in the module. 

There's not a great way to make this agree with mypy because the overload is dependent on the value of `return_indices`, an attribute.


[ghstack-poisoned]
eellison pushed a commit that referenced this pull request Feb 16, 2021
ghstack-source-id: 86fa519
Pull Request resolved: #47888
@ezyang ezyang removed the Stale label Feb 21, 2021
Fix for #45904

All of the pooling modules except MaxUnpool and LPPool return either a `Tensor `or `[Tensor, Tensor]`. The current type annotations are inaccurate, and prevent scripting the module if `return_indices` is set as true in the module. 

There's not a great way to make this agree with mypy because the overload is dependent on the value of `return_indices`, an attribute.


[ghstack-poisoned]
eellison pushed a commit that referenced this pull request Mar 15, 2021
ghstack-source-id: c2a2e0a
Pull Request resolved: #47888
@gmagogsfm
Copy link
Copy Markdown
Contributor

Cleaning my github dashboard, doesn't seem this PR is needed due to inactivity, removing myself as reviewer.

@gmagogsfm gmagogsfm removed request for apaszke and gmagogsfm May 22, 2021 01:51
@jbschlosser jbschlosser removed their request for review July 22, 2021 16:08
@garymm
Copy link
Copy Markdown
Collaborator

garymm commented Aug 16, 2021

@eellison any reason this hasn't been merged yet?

@garymm
Copy link
Copy Markdown
Collaborator

garymm commented Sep 29, 2021

I rebased this and fixed some issues in tests: #65847

If a FB employee would please review and import I'd appreciate it.

@ezyang
Copy link
Copy Markdown
Contributor

ezyang commented Sep 30, 2021

@eellison is an fb employee 😂

@eellison
Copy link
Copy Markdown
Contributor Author

Hi @garymm i moved projects and this sort of slipped out under me. as you see, it's pretty close, if you don't mind rebasing/getting CI to pass i'll review and land, thanks for your help!

@garymm
Copy link
Copy Markdown
Collaborator

garymm commented Sep 30, 2021

Closing this in favor of #65847

@garymm garymm closed this Sep 30, 2021
@facebook-github-bot facebook-github-bot deleted the gh/eellison/135/head branch October 31, 2021 14:27
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.

6 participants