torch.foreach.add_#
- torch.foreach.add_(inputs: TensorList, other: Scalar, /) tuple[Tensor, ...] | list[Tensor][source]#
- torch.foreach.add_(inputs: TensorList, other: ScalarList, /) tuple[Tensor, ...] | list[Tensor]
- torch.foreach.add_(inputs: TensorList, other: Tensor, /, *, alpha: Scalar) tuple[Tensor, ...] | list[Tensor]
- torch.foreach.add_(inputs: TensorList, other: TensorList, /, *, alpha: Scalar = 1) tuple[Tensor, ...] | list[Tensor]
Applies
torch.add()to every tensor ininputs.This is semantically equivalent to applying
torch.add()independently at every list position. Mutates every tensor ininputsand 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.
A shared
Tensoroperand must be a 0-D scalar tensor.For a shared 0-D tensor, pass
alphaexplicitly, including when its value is1, to select the Tensor overload. Omittingalphamay convert the tensor to a host scalar.- Parameters:
- Returns:
the exact input list or tuple.