Skip to content
fn

matmul_op

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

Python wrappers

Public Python APIs implemented by this engine symbol.

Compute ABA B with full NumPy-style batch broadcasting and autograd.

Thin public wrapper that delegates to MatmulBackward::forward.

Math

C[…,i,j]=∑k=0K−1A[…,i,k] B[…,k,j] C[\ldots, i, j] = \sum_{k=0}^{K-1} A[\ldots, i, k]\, B[\ldots, k, j]

See Also

dot_op : Rank-1 / rank-2 specialised dispatch. MatmulBackward : Autograd node implementing the backward pass.

Parameters

aTensorImplPtr
Left operand, rank ≥2\ge 2.
bTensorImplPtr
Right operand, rank ≥2\ge 2.

Returns

TensorImplPtr

Result tensor C=ABC = A B with broadcast batch shape and trailing (M,N)(M, N).

Notes

FLOPs per output element ≈ 2K2K; total ≈2⋅B⋅M⋅N⋅K\approx 2 \cdot B \cdot M \cdot N \cdot K where BB is the broadcast batch size.

Examples

::
    // C++: 2-D × 2-D plain GEMM.
    auto C = matmul_op(A, B);  // A: [M,K], B: [K,N]  → C: [M,N]