Skip to content
fn

kron_op

→TensorImplPtr
int kron_op(const int & a, const int & b)

Python wrappers

Public Python APIs implemented by this engine symbol.

Kronecker (block tensor) product over matching ranks.

Composite over reshape_op + mul_op + reshape_op. Interleaves size-1 placeholders so the multiply broadcasts to a 2⋅ndim2 \cdot \mathrm{ndim}-rank block tensor; the trailing reshape collapses each (sa[i], sb[i]) pair into a single sa[i] * sb[i] axis. Gradient flows through ReshapeBackward and MulBackward.

Math

For rank-2 operands A∈Rm×nA \in \mathbb{R}^{m \times n} and B∈Rp×qB \in \mathbb{R}^{p \times q}:

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

generalised elementwise to arbitrary equal ranks.

See Also

mul_op, reshape_op.

Parameters

a, bTensorImplPtr
Operands sharing the same rank ndim. Shapes need not match dimension-by-dimension.

Returns

TensorImplPtr

Tensor of shape (sa[0] * sb[0], ..., sa[-1] * sb[-1]).

Raises

Failure
If either input is null or the ranks differ.

Examples

``kron`` of two ``(2, 3)`` matrices yields a ``(4, 9)`` matrix.