Skip to content
fn

kron

→Tensor
kron(input: Tensor, other: Tensor | Scalar)

Implementing kernel

C++ engine symbols that back this Python API.

Kronecker product of two tensors.

Computes the Kronecker (tensor) product A⊗BA \otimes B. For 2-D inputs of shapes (m, n) and (p, q) the result has shape (m * p, n * q); for higher-rank inputs each pair of axes is multiplied in turn.

Parameters

inputTensor
Left operand.
otherTensor or scalar
Right operand. Broadcasts against input following the standard broadcasting rules; Python scalars are promoted to a tensor of matching dtype.

Returns

Tensor

Element-wise result with shape broadcast(input.shape, other.shape) and dtype determined by the usual type-promotion rules.

Notes

Mathematical definition:

(A⊗B)ip+r, jq+s=Aij Brs(\mathbf{A} \otimes \mathbf{B})_{ip + r,\,jq + s} = \mathbf{A}_{ij}\,\mathbf{B}_{rs}

The Kronecker product is bilinear and associative but not commutative.

Examples

>>> import lucid
>>> a = lucid.tensor([1.0, 2.0, 3.0])
>>> b = lucid.tensor([4.0, 5.0, 6.0])
>>> lucid.kron(a, b)
Tensor([...])