Closed
Description
Motivation
It would be great to have a helper function that automatically creates a TensorDict
out of a dict
with a predefined set of rules.
This should not be the default way of creating TensorDict instances but it should be used in several other helper functions through the library to make the usage of TensorDict-based classes easier.
Intended usage
The function should work like this:
d = {"a": torch.randn(3, 4, 5), "b": torch.randn(3, 4, 2)}
tensordict = make_tensordict(d)
this should return a tensordict with the maximum batch size (in this case [3, 4]
) and the device (if any) of its content (in this case, "cpu").
It should be possible to parameterize some behaviours, e.g. say how many dimensions should the function look at when determining the batch size, or overriding the device.
This funciton should be implemented in the tensordict utils.py
file.