-
-
Notifications
You must be signed in to change notification settings - Fork 39
Description
First off - I've been thinking of almost the same idea as this library for a while because I see runtime errors from tensor shape/dtype mismatches all the time, so glad that there's already something in place!
My initial approach was going to be parsing docstrings of various formats (with an existing library like docstring_parser) and performing validation on these, rather than type annotations. Is that a feature you'd consider accepting into your library? I'd be interested in writing a PR for it with some guidance
For example, I currently write Sphinx style docstrings like this
def forward(self, imgs, tokens):
"""Combine multimodal input features
:param torch.FloatTensor[N, C, H, W] imgs: Batch of image pixels
normalized in range of 0-1
:param torch.LongTensor[N, L] tokens: Vocabularly tokens in sequence
of length ``L``
:return torch.FloatTensor[N, C] pred: Predicted probabilities for
each class
"""I realize the [N, C, H, W] notation is not quite as rigid as what this project proposes, and that's one reason I've been looking for a more structured approach. But regardless, I do find it nice sometimes to have this information in the docstrings instead of type annotations, particularly for functions with many parameters