Batch: Agnostic Ops

Batch: Agnostic Ops#

Batch-agnostic versions of PyTorch operations that do not work with batched and non-batched tensors out of the box.

tad_mctc.batch.agnostic.eye(shape, value=1.0, device=None, dtype=None)[source]#

Create an identity tensor. This version handles a possible batch dimension.

Parameters:
  • tensor (Tensor) – Tensor shape to create the identity tensor from.

  • value (float, optional) – Value to fill the diagonal with. Defaults to 1.0.

  • device (torch.device | None, optional) – Device to create the tensor on. If None, the device of the input

  • dtype (torch.dtype | None, optional) – Data type of the tensor. If None, the data type of the input.

Returns:

Possibly batched identity tensor.

Return type:

Tensor