Skip to content

Whether/how to add functionality (and create pull requests) #612

Answered by vmoens
sunsibar asked this question in Q&A
Discussion options

You must be logged in to vote

We don't have recipies (yet!) but that's a great idea.
Here's how it generally works:

  • Usually we will want to have a function that works recursively, either on tensors or on tensordict items. A plain tensordict.apply(func) will only be called on the tensors, which does not fit the purpose. (If you want to understand why this approach is better, think of a TensorDictBase subclass -- call it MyTensorDict -- with a dedicated torch.repeat_interleave. If we call a plain apply, we won't be treating this class accurately if it's nested within a regular TensorDict).
  • Instead, we want to call TensorDict._fast_apply(func, call_on_nested=True). This will call your func on tensors and tensordicts, re…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@sunsibar
Comment options

@vmoens
Comment options

Answer selected by sunsibar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants