Rate this Page

torch.foreach.sub_#

torch.foreach.sub_(inputs: TensorList, other: Scalar, /) tuple[Tensor, ...] | list[Tensor][source]#
torch.foreach.sub_(inputs: TensorList, other: ScalarList, /) tuple[Tensor, ...] | list[Tensor]
torch.foreach.sub_(inputs: TensorList, other: TensorList, /, *, alpha: Scalar = 1) tuple[Tensor, ...] | list[Tensor]

Applies torch.sub() to every tensor in inputs.

This is semantically equivalent to applying torch.sub() 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.

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

  • other (Number, list or tuple of Number, or list or tuple of Tensor) – operand shared across positions or supplied per position.

  • alpha (Number, optional) – supported only when other is a tensor list. Default: 1.

Returns:

the exact input list or tuple.