fill_diagonal_tensor_¶
- paddle.Tensor. fill_diagonal_tensor_ ( x, y, offset=0, dim1=0, dim2=1, name=None )
-
- Notes:
-
This API is ONLY available in Dygraph mode
This function fill the source Tensor y into the x Tensor’s diagonal inplace.
- Parameters
-
x (Tensor) –
x
is the original Tensory (Tensor) –
y
is the Tensor to filled in xdim1 (int,optional) – first dimension with respect to which to fill diagonal. Default: 0.
dim2 (int,optional) – second dimension with respect to which to fill diagonal. Default: 1.
offset (int,optional) – the offset to the main diagonal. Default: 0 (main diagonal).
name (str,optional) – Name for the operation (optional, default is None)
- Returns
-
Tensor with diagonal filled with y.
- Return type
-
Tensor
- Returns type:
-
list: dtype is same as x Tensor
Examples
import paddle x = paddle.ones((4, 3)) * 2 y = paddle.ones((3,)) x.fill_diagonal_tensor_(y) print(x.tolist()) #[[1.0, 2.0, 2.0], [2.0, 1.0, 2.0], [2.0, 2.0, 1.0], [2.0, 2.0, 2.0]]