latest (dev)
Copy
Latest development documentation · Updated 2026-10-15
tensorplay.functional.kron
- tensorplay.functional.kron(input, other, *, out=None) Tensor[source]
Computes the Kronecker product, denoted by , of
inputandother.If
inputis a tensor andotheris a tensor, the result will be a tensor with the following entries:where for . If one tensor has fewer dimensions than the other it is unsqueezed until it has the same number of dimensions.
Supports real-valued and complex-valued inputs.
Note
This function generalizes the typical definition of the Kronecker product for two matrices to two tensors, as described above. When
inputis a matrix andotheris a matrix, the result will be a block matrix:where
inputis andotheris .- Parameters:
- Keyword Arguments:
out (Tensor, optional) – The output tensor. Ignored if
None. Default:None
Examples:
>>> mat1 = tensorplay.eye(2) >>> mat2 = tensorplay.ones(2, 2) >>> tensorplay.kron(mat1, mat2) tensor([[1., 1., 0., 0.], [1., 1., 0., 0.], [0., 0., 1., 1.], [0., 0., 1., 1.]]) >>> mat1 = tensorplay.eye(2) >>> mat2 = tensorplay.arange(1, 5).reshape(2, 2) >>> tensorplay.kron(mat1, mat2) tensor([[1., 2., 0., 0.], [3., 4., 0., 0.], [0., 0., 1., 2.], [0., 0., 3., 4.]])
Help improve this page
Found an error, an unclear step, or a missing example?

