osc.utils.fill_diagonal_

fill_diagonal_(x, value=- inf)[source]

Fill diagonal of torch tensor, batched and in-place.

Parameters
  • x (Tensor) – [..., N, M] tensor with leading batch dimensions.

  • value (float) – value to fill the diagonal with.

Return type

Tensor

Returns

The same [..., N, M] input tensor with diagonal entries x[..., i, i] replaced.