How gemmlowp performs low-precision GEMM
mastergemmlowp implements low-precision General Matrix Multiplication (GEMM) using a three-stage computation scheme to balance memory efficiency and arithmetic performance.
Because the library uses uint8 inputs/outputs but accumulates in int32 to maintain precision, it must manage the transition between these types. The process follows these steps:
- Pack: Reorder input matrix blocks (LHS/RHS) into a layout optimized for cache locality and SIMD loading.
- Compute: Execute the multiplication using a kernel that operates on the packed blocks and accumulates results into a temporary
int32block. - Unpack: Convert the
int32accumulator block back into theuint8destination matrix.
This approach minimizes the memory footprint of high-precision int32 values by only storing and processing them in small, manageable blocks.
1. Pack lhs/rhs blocks from the input matrices.
2. Compute the product of the packed blocks, using the kernel.
3. Unpack the result block into the output matrix.