torchtyping
torchtyping copied to clipboard
Type annotations and dynamic checking for a tensor's shape, dtype, names, etc.
## Setup - `pyright`: 1.1.263 - `pytorch`: 1.12.0+cu113 - `torchtyping`: 0.1.4 ## Code Example ```python from torchtyping import TensorType def example(foo: TensorType["batch"]): pass ``` ## Problem Pyright reports the following...
When I specify a type like `TensorType["batch_size", "num_channels", "x", "y"]`, I get a mypy error like `error: Name "batch_size" is not defined` for each of the named axes. Is this...
Hi all, This library looks very nice :) Is `TensorType` compatible with the TorchScript compiler? As in, are the annotations transparently converted to `torch.Tensor` as far as `torch.jit.script` is concerned,...
Hi, I have recently started using this library, so i might be using it incorrectly, but linting seems to fail in pycharm when assigning the result of `torch.randn` to `TensorType`...
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...
Hi! I just found torchtyping a few days ago, and I am enjoying it so far. However, I am a bit confused when it comes to one particular use-case: checking...
n00b to this very cool project, looking to enforce a broadcast-ability pattern where a dimension in one tensor either matches or can be broadcast to (i.e. equals 1) a dimension...
Hi, I'm new to using torchtyping, and my usecase is the following: I have a data structure that has tensor of size N and another one of size N -...
Is it possible to perform type checking for tensors with grad enabled? I myself am not sure of all the cases necessary to test against to confirm this as I...
That is, classes supporting the `__torch_function__` protocol. This shouldn't be too difficult -- most of the necessary work has already been done. - There's some places where we have `torch.Tensor`...