-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] Support for type annotations instead of torch.jit.annotate() #21390
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
Conversation
This adds support for PEP 526 style annotations in place of `torch.jit.annotate()`, so ```python a = torch.jit.annotate(List[int], []) a : List[int] = [] ```
|
Haven't looked very closely yet but could you add a test case for |
|
Added a test, mypy doesn't allow casting though so I don't think it's going to be expected |
I've answered a question before where some one tried to do that, you'd be surpised |
| const Expr& rhs) { | ||
| return Assign(Compound::create(TK_ASSIGN, range, {lhs, rhs})); | ||
| } | ||
| static Assign create( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be Assign(Expr lhs, Expr rhs, Maybe<Expr> type) instead of two different constructors.
Also can you update the big comment at the top of the file with the new form?
|
This PR likely broke |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@driazati is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
|
This change appears to have broken CC @yf225 |
This adds support for PEP 526 style annotations on assignments in place of
torch.jit.annotate(), soturns into
Differential Revision: D15706021