Closed smorad closed 3 years ago
How can I type check an empty tensor? E.g.
import torch from torchtyping import TensorType, patch_typeguard from typeguard import typechecked patch_typeguard() a = torch.zeros(3,4,0) def my_fn(a: TensorType["batch", "temporal", -1]): return torch.cat((a, torch.zeros(3,4,10), dim=-1)
Using None, -1, or 0 for the last dimension gives me
None
-1
0
TypeError: argument "a" must be of type TensorType['batch', 'temporal', -1], got type NoneType instead.
Whoops my mistake, this is already handled correctly! Issue was in my code.
How can I type check an empty tensor? E.g.
Using
None
,-1
, or0
for the last dimension gives me