TensorDictBase.as_tensor#
- TensorDictBase.as_tensor() Self#
Returns a tensordict whose leaves are converted with their
as_tensor()method, if they have one.The leaves without an
as_tensor()method,torch.TensorandMemoryMappedTensorincluded, are kept as they are. No tensordict leaf type definesas_tensor(), so the result holds the same leaves as the tensordict. A locked tensordict gives a locked result.A tensordict with
MemoryMappedTensorleaves also emits aFutureWarning. Starting with TensorDict 0.17, the default will change to returning those leaves as plaintorch.Tensorover the same storage, withas_subclass(torch.Tensor), without a copy.
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.