kron¶
- paddle. kron ( x: Tensor, y: Tensor, name: str | None = None ) Tensor [source]
-
Compute the Kronecker product of two tensors, a composite tensor made of blocks of the second tensor scaled by the first. Assume that the rank of the two tensors, X and Y are the same, if necessary prepending the smallest with ones. If the shape of X is [r0, r1, …, rN] and the shape of Y is [s0, s1, …, sN], then the shape of the output tensor is [r0s0, r1s1, …, rNsN]. The elements are products of elements from X and Y. The equation is: output[k0,k1,…,kN]=X[i0,i1,…,iN]∗Y[j0,j1,…,jN] where kt=it∗st+jt,t=0,1,…,N
- Parameters
-
x (Tensor) – the fist operand of kron op, data type: bfloat16, float16, float32, float64, int32 or int64.
y (Tensor) – the second operand of kron op, data type: bfloat16, float16, float32, float64, int32 or int64. Its data type should be the same with x.
name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to Name.
- Returns
-
The output of kron, data type: bfloat16, float16, float32, float64, int32 or int64. Its data is the same with x.
- Return type
-
Tensor
Examples
>>> import paddle >>> x = paddle.to_tensor([[1, 2], [3, 4]], dtype='int64') >>> y = paddle.to_tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype='int64') >>> out = paddle.kron(x, y) >>> out Tensor(shape=[6, 6], dtype=int64, place=Place(cpu), stop_gradient=True, [[1 , 2 , 3 , 2 , 4 , 6 ], [4 , 5 , 6 , 8 , 10, 12], [7 , 8 , 9 , 14, 16, 18], [3 , 6 , 9 , 4 , 8 , 12], [12, 15, 18, 16, 20, 24], [21, 24, 27, 28, 32, 36]])