Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to be used with tensordict? #263

Open
RuiWang1998 opened this issue Nov 5, 2024 · 3 comments
Open

Is it possible to be used with tensordict? #263

RuiWang1998 opened this issue Nov 5, 2024 · 3 comments
Labels
question User queries

Comments

@RuiWang1998
Copy link

RuiWang1998 commented Nov 5, 2024

I find jaxtyping a blast to use, as is tensordict(https://github.com/pytorch/tensordict). If I could have it both ways, that would be even more amazing!

Thanks for the great work!

@patrick-kidger
Copy link
Owner

Hmm, so it's not clear to me how we'd go about annotating a TensorDict, in the same way that it's not obvious to me how to annotate the shapes and dtypes of the values of a regular dict.

But... have you tried the @tensorclass decorator that tensordict also provides? As that explicitly annotates the contained elements then I think that should be exactly what you need?

@patrick-kidger patrick-kidger added the question User queries label Nov 5, 2024
@Mxbonn
Copy link

Mxbonn commented Nov 6, 2024

Can confirm that tensorclass works

@tensorclass
class CameraIntrinsics:
    fx: Float[Tensor, " *num_cameras"]
    fy: Float[Tensor, " *num_cameras"]
    cx: Float[Tensor, " *num_cameras"]
    cy: Float[Tensor, " *num_cameras"]
...    
def some_other_fun(intrinsics: Shaped[CameraIntrinsics, " *num_cameras"])

@RuiWang1998
Copy link
Author

Great! Thanks for the advice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User queries
Projects
None yet
Development

No branches or pull requests

3 participants