mr2.utils.TensorList

class mr2.utils.TensorList[source]

Bases: Module, Sequence[Tensor]

Holds tensors in a list, correctly registering buffers.

Mimics PyTorch ParameterList, but registers tensors as buffers if they do not require gradients and are not Parameters. Tensors requiring gradients are registered as standard attributes.

__init__(tensors: Iterable[Tensor] | None = None) None[source]

Initialize TensorList.

Parameters:

tensors (Iterable[Tensor] | None, default: None) – An iterable of tensors to add to the list.

__call__(*_args: object, **_kwargs: object) Never[source]

TensorList should not be called.

append(value: Tensor) Self[source]

Append a tensor to the end of the list.

Parameters:

value (Tensor) – Tensor to append.

extend(values: Iterable[Tensor]) Self[source]

Append tensors from an iterable to the end of the list.

Parameters:

values (Iterable[Tensor]) – Iterable of tensors to append.