Rate this Page

torch.foreach.zero_#

torch.foreach.zero_(inputs: TensorList, /) tuple[Tensor, ...] | list[Tensor][source]#

Fills every tensor in inputs with zero.

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

Tensor-list arguments must be non-empty. 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.zero operation.

Parameters:

inputs (list or tuple of Tensor) – tensors to zero.

Returns:

the exact inputs list or tuple.