Overview of Apple AMX (Apple Matrix Extensions)
mainApple AMX is a set of undocumented and unsupported instructions used on M1, M2, M3, and M4 series chips to perform heavy matrix and vector computations via a special accelerator execution unit. It is distinct from Intel's AMX.
Hardware Model
AMX operates on a grid of compute units (e.g., a 32x32 grid) that can perform multiply-accumulate operations. It uses two pools of registers:
- X registers: Contain 32 16-bit elements, 16 32-bit elements, or 8 64-bit elements.
- Y registers: Contain 32 16-bit elements, 16 32-bit elements, or 8 64-bit elements.
A single instruction can perform a full outer product by multiplying every element of an X register with every element of a Y register and accumulating the result into a Z element.
Supported Data Types
- IEEE754:
f16,f32, orf64(operands must have the same width). - Mixed Precision:
f16multiplicands accumulating ontof32. - M2 Specific:
bf16multiplicands accumulating ontobf16orf32. - Integer: 8-bit or 16-bit multiplicands accumulating onto 16-bit or 32-bit integers (various signednesses).