diagonalEmbedding

abstract fun diagonalEmbedding(diagonalEntries: Tensor<T>, offset: Int = 0, dim1: Int = -2, dim2: Int = -1): Tensor<T>

Creates a tensor whose diagonals of certain 2D planes (specified by dim1 and dim2) are filled by diagonalEntries. To facilitate creating batched diagonal matrices, the 2D planes formed by the last two dimensions of the returned tensor are chosen by default.

The argument offset controls, which diagonal to consider:

  1. If offset = 0, it is the main diagonal.

  2. If offset 0, it is above the main diagonal.

  3. If offset < 0, it is below the main diagonal.

The size of the new matrix will be calculated to make the specified diagonal of the size of the last input dimension. For more information: https://pytorch.org/docs/stable/generated/torch.diag_embed.html

Return

tensor whose diagonals of certain 2D planes (specified by dim1 and dim2) are filled by diagonalEntries

Parameters

diagonalEntries

the input tensor. Must be at least 1-dimensional.

offset

which diagonal to consider. Default: 0 (main diagonal).

dim1

first dimension with respect to which to take diagonal. Default: -2.

dim2

second dimension with respect to which to take diagonal. Default: -1.

Sources

common source
Link copied to clipboard