TensorDictBase.copy_at#
- TensorDictBase.copy_at_(tensordict: T, idx: None | int | slice | str | Tensor | List[Any] | Tuple[Any, ...], non_blocking: bool = False, *, fast: bool = True) Self#
Copies values from
tensordictintoselfat the specified index.copy_at_is an explicit copy-oriented variant ofupdate_at_(). Unlikeupdate_at_, it may use optimized tensor-only copy paths and is intended for hot paths where the source and destination structures are known to match.- Parameters:
tensordict (TensorDictBase) – input data to be copied in
self.idx (int, Tensor, iterable, slice) – index of the tensordict where the copy should occur.
non_blocking (bool, optional) – if
Trueand this copy is between different devices, the copy may occur asynchronously with respect to the host.
- Keyword Arguments:
fast (bool, optional) –
controls whether
copy_at_may fall back toupdate_at_(). IfTrue, only the optimized tensor-only path is used and aRuntimeErroris raised when the fast path is not available. IfFalse, this method delegates directly toupdate_at_. Defaults toTrue.Changed in version 0.15:
fast=None, deprecated in 0.14, is no longer accepted.- Returns:
self
Every tensordict class and every tensorclass has this method. For the other methods, see Methods by task.