chickadee » array-morphisms » morph-matmul

morph-matmul A Bprocedure

Matrix-matrix multiply morphism: (M,K) x (K,N) -> (M,N).

morph-matmul also multiplies batches. When an operand has rank 3 or more, its leading axes are a frame and its last two axes are the matrices (the cells):

(morph-matmul A B)   ; A [F.. M K], B [F.. K N] -> [F.. M N]
(morph-matmul A W)   ; A [F.. M K], W [K N]     -> [F.. M N]  (W shared by every cell)
(morph-matmul W B)   ; W [M K],     B [F.. K N] -> [F.. M N]

Both operands must have the same frame, unless one of them is a plain matrix shared by every cell. Each cell of the result has exactly the values that the 2-D product of that cell would have, because it runs the same GEMM kernel.