patrick-kidger / torchtyping

Type annotations and dynamic checking for a tensor's shape, dtype, names, etc.
Apache License 2.0
1.41k stars 34 forks source link

Dimension size as expression of another dimension #24

Open ikamensh opened 3 years ago

ikamensh commented 3 years ago

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 - 1. Is there a way to specify this? Naive attempt of using TensorType["time" - 1] failed.

Thanks!

patrick-kidger commented 3 years ago

Currently the best way to specify this is just TensorType["time - 1"]. This will just define another dimension name though. So it's good for documentation purposes but won't be able to check that "time" - 1 = "time" - 1, so to speak.

Having this work is something I'd like to add; see issue #2. It should be possible to make work at a technical level; I just haven't found the time to implement it.