Pytorch Typing, for Tensor type annotations #73359
Labels
module: typing
Related to mypy type annotations
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
🚀 The feature, motivation and pitch
Doing something like https://numpy.org/devdocs/reference/typing.html#numpy.typing.NDArray would be cool, to allow people to see read the dtype of tensors in the signature, and possibly something like Beartype to do runtime type checking to make sure that the tensors are of the correct dtype, would be great. Number of dimensions could also be informative and would be runtime testable.
Allowing to name the dimensions (eg "batch_size" x "sequence_length" x "hidden_state_size") would also be great.
Some inspiration is https://github.com/patrick-kidger/torchtyping
In-depth discussion beartype/beartype#96
Alternatives
No response
Additional context
https://numpy.org/devdocs/reference/typing.html#numpy.typing.NDArray
beartype/beartype#96
https://github.com/patrick-kidger/torchtyping
cc @ezyang @malfet @rgommers @xuzhao9 @gramster
The text was updated successfully, but these errors were encountered: