For A with shape M × K and B with shape K × N, the product C = AB has shape M × N. Each C[i,j] is the dot product of row i of A and column j of B; the shared K dimension must match. section 5.5
C[i, j] = sum over p in [0, K) of A[i, p] * B[p, j]
Each output entry sums pairwise products across the shared K dimension. section 5.5
A scalar-output kernel computes each entry independently, repeating reads of input values. A tiled kernel computes several outputs together, reuses loaded tiles of A and B, and uses tl.dot to contract their K dimensions. Masks handle incomplete edge tiles; grouped program ordering and autotuning can improve performance. section 5.10 section 5.6.1
A small product
For A = [[1, 2, 3], [4, 5, 6]] and B = [[7, 8], [9, 10], [11, 12]], the result is [[58, 64], [139, 154]]. For example, the first row’s second output is 1 × 8 + 2 × 10 + 3 × 12 = 64. section 5.5
Matrix products recur in neural-network linear layers, attention projections, and training gradients. GEMM generalizes the operation to C ← αAB + βC, scaling both the new product and any existing output values. section 5.5 section 5.5.1












