xref: /aosp_15_r20/external/XNNPACK/doc/microkernel-naming-conventions.md (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1*4bdc9457SAndroid Build Coastguard Worker# Microkernel naming conventions
2*4bdc9457SAndroid Build Coastguard Worker
3*4bdc9457SAndroid Build Coastguard WorkerThis documents deciphers XNNPACK's microkernels naming convention.
4*4bdc9457SAndroid Build Coastguard Worker
5*4bdc9457SAndroid Build Coastguard Worker## General conventions
6*4bdc9457SAndroid Build Coastguard Worker
7*4bdc9457SAndroid Build Coastguard WorkerMicrokernel function names follow this convention:
8*4bdc9457SAndroid Build Coastguard Worker
9*4bdc9457SAndroid Build Coastguard Worker`xnn_<datatype>_<microkernel><activation?>_ukernel_<parameters>__<arch>`
10*4bdc9457SAndroid Build Coastguard Worker
11*4bdc9457SAndroid Build Coastguard WorkerWhere `<datatype>` can be:
12*4bdc9457SAndroid Build Coastguard Worker
13*4bdc9457SAndroid Build Coastguard Worker-   `cs16`
14*4bdc9457SAndroid Build Coastguard Worker-   `f16` - 16-bit half precision float
15*4bdc9457SAndroid Build Coastguard Worker-   `f32` - 32-bit single precision float
16*4bdc9457SAndroid Build Coastguard Worker-   `qc8`
17*4bdc9457SAndroid Build Coastguard Worker-   `qs8` - quantized signed 8 bit
18*4bdc9457SAndroid Build Coastguard Worker-   `qu8` - quantized unsigned 8 bit
19*4bdc9457SAndroid Build Coastguard Worker-   `s16`
20*4bdc9457SAndroid Build Coastguard Worker-   `u32`
21*4bdc9457SAndroid Build Coastguard Worker-   `x8`
22*4bdc9457SAndroid Build Coastguard Worker-   `x16`
23*4bdc9457SAndroid Build Coastguard Worker-   `x24`
24*4bdc9457SAndroid Build Coastguard Worker-   `x32`
25*4bdc9457SAndroid Build Coastguard Worker-   `xx`
26*4bdc9457SAndroid Build Coastguard Worker
27*4bdc9457SAndroid Build Coastguard Worker`<microkernel>` is the type of microkernel, such as:
28*4bdc9457SAndroid Build Coastguard Worker
29*4bdc9457SAndroid Build Coastguard Worker-   `gemm`
30*4bdc9457SAndroid Build Coastguard Worker-   `igemm`
31*4bdc9457SAndroid Build Coastguard Worker-   `avgpool`
32*4bdc9457SAndroid Build Coastguard Worker
33*4bdc9457SAndroid Build Coastguard Worker`<activation>` if supported for the microkernel is activation that is fused into
34*4bdc9457SAndroid Build Coastguard Workerthe microkernel:
35*4bdc9457SAndroid Build Coastguard Worker
36*4bdc9457SAndroid Build Coastguard Worker-   `linear`
37*4bdc9457SAndroid Build Coastguard Worker-   `minmax`
38*4bdc9457SAndroid Build Coastguard Worker-   `relu`
39*4bdc9457SAndroid Build Coastguard Worker
40*4bdc9457SAndroid Build Coastguard Worker`<parameters>` are microkernel specific, and can mean different things depending
41*4bdc9457SAndroid Build Coastguard Workeron the microkernel (see below for details).
42*4bdc9457SAndroid Build Coastguard Worker
43*4bdc9457SAndroid Build Coastguard Worker`<arch>` is the architecture the microkernel is optimized for, and can contain
44*4bdc9457SAndroid Build Coastguard Workerfurther subdivisions for additional instruction sets supported on the specified
45*4bdc9457SAndroid Build Coastguard Workerarchitecture, or processor information:
46*4bdc9457SAndroid Build Coastguard Worker
47*4bdc9457SAndroid Build Coastguard Worker-   `scalar`
48*4bdc9457SAndroid Build Coastguard Worker-   `aarch32_neon_cortex_a55`
49*4bdc9457SAndroid Build Coastguard Worker-   `neonv8_mlal`
50*4bdc9457SAndroid Build Coastguard Worker-   `wasm`
51*4bdc9457SAndroid Build Coastguard Worker-   `avx512`
52*4bdc9457SAndroid Build Coastguard Worker-   `avx512skx`
53*4bdc9457SAndroid Build Coastguard Worker
54*4bdc9457SAndroid Build Coastguard Worker## GEMM and IGEMM microkernels
55*4bdc9457SAndroid Build Coastguard Worker
56*4bdc9457SAndroid Build Coastguard WorkerThe `<parameters>` for GEMM and IGEMM microkernels represent the `mr` and `nr`
57*4bdc9457SAndroid Build Coastguard Workerof the microkernel. You can think of it as the number of rows and columns of the
58*4bdc9457SAndroid Build Coastguard Workeroutput calculated by the microkernel.
59*4bdc9457SAndroid Build Coastguard Worker
60*4bdc9457SAndroid Build Coastguard WorkerE.g. `xnn_f32_gemm_minmax_ukernel_4x8__aarch32_neon_cortex_a7` processes 32
61*4bdc9457SAndroid Build Coastguard Workerelements of the output matrix.
62*4bdc9457SAndroid Build Coastguard Worker
63*4bdc9457SAndroid Build Coastguard Worker## Average Pooling and Global Average Pooling
64*4bdc9457SAndroid Build Coastguard Worker
65*4bdc9457SAndroid Build Coastguard WorkerThese microkernels come in 2 varieties, uni-pass and multi-pass.
66*4bdc9457SAndroid Build Coastguard Worker
67*4bdc9457SAndroid Build Coastguard WorkerUni-pass have `Cx` in their name, where `C` is a number. This microkernel
68*4bdc9457SAndroid Build Coastguard Workerprocesses up to and including `C` elements.
69*4bdc9457SAndroid Build Coastguard Worker
70*4bdc9457SAndroid Build Coastguard WorkerMulti-pass have `CpDx` in their name, where `C` and `D` are numbers. This
71*4bdc9457SAndroid Build Coastguard Workermicrokernel processes `D` elements in the first pass, and middle pass (which can
72*4bdc9457SAndroid Build Coastguard Workerrun multiple times), and up to `C` elements in the last pass.
73*4bdc9457SAndroid Build Coastguard Worker
74*4bdc9457SAndroid Build Coastguard WorkerE.g. `xnn_f32_avgpool_minmax_ukernel_9x__neon_c4` can process up to 9 elements.
75