Rate this Page

torch.foreach.copy_#

torch.foreach.copy_(inputs: TensorList, src: TensorList, /, *, non_blocking: bool = False) tuple[Tensor, ...] | list[Tensor][source]#

Copies each tensor in src into the corresponding tensor in inputs, following torch.Tensor.copy_().

This is semantically equivalent to applying torch.Tensor.copy_() independently at every list position. Mutates every tensor in inputs and returns the exact input container object.

Tensor-list arguments must be non-empty. Corresponding tensor or scalar lists must have the same length. An accelerated multi-tensor implementation is used only when supported by the inputs; otherwise the operation falls back to per-tensor execution.

There is no functional torch.foreach.copy operation.

Parameters:
  • inputs (list or tuple of Tensor) – destination tensors.

  • src (list or tuple of Tensor) – source tensors.

  • non_blocking (bool, optional) – allows asynchronous host/device copies when supported. Default: False.

Returns:

the exact inputs list or tuple.