Repository navigation
v18.2 — int8 residual adds at a third of CMSIS-NN's cycles, and the Cortex-M0+ dense speed restored
v18.2 — int8 residual adds at a third of CMSIS-NN's cycles, and the Cortex-M0+ dense speed restored
Performance
QAddrescales each input in one rounding (#273). TFLite ADD rescales both inputs with a two-step rounding and a branch on the shift's sign. When the parameters allow it, which covers every int8 input at TFLite'sleft_shiftof 20,QAddnow composes the two roundings into one 64-bit multiply-add and a shift, and requantizes the sum with the single-rounding requantizer the convolutions already use. Other parameters take the reference loop, kept out of line with a newTINYMIND_NOINLINEmacro so thatforward()stays small enough to inline and aconstlayer keeps its parameters folded as constants. On the NUCLEO-F411RE the three residual adds of the MLPerf Tiny ResNet-8 take 21%, 37% and 42% fewer cycles, a third of CMSIS-NN's, and the whole model 1.2% fewer, bit-exact. AQAddwhose parameters sit in RAM runs in about half the cycles, and on the Cortex-M0+QAddis 10% faster.- Cortex-M0+ dense layers get their speed back (#275). The L031 MLP benchmark had been running 36% slower at
-O2since #230 (35,637 to 48,619 cycles). The dense layers call the requantizer once per output, and its rarely taken saturating path, though never executed, kept GCC from giving the dot product the registers it needed on Thumb-1. Under the newTINYMIND_SPLIT_REQUANTIZER_FORMS, on by default for GCC on Thumb-1 only,QDenseand the single-pixel pointwise layers check once per layer whether every requantizer takes the one-rounding path (Requantizer::oneRounding()) and then run a copy of the loop that callsapplyOneRounding(). The MLP now takes 33,010 cycles at-O2and 32,644 at-O3, faster than before #230 at both levels, bit-exact. Other compilers and cores measured slower with the split and compile to the same code as before. - Member reads hoisted out of store loops (#272). An
int8_tstore may alias the layer object itself, so a member read inside such a loop is reloaded on every element.QAdd,QPad2DandQEmbeddingnow copy their fields into locals first, as the convolutions already did: with the layer in RAM,QPad2Dis 10% faster andQEmbedding20% faster. The same change was measured and dropped where it gained nothing, and forQAvgPool2D, where it made the layer 7% slower.
Verification
- The CBMC requantizer proof gains 32 jobs proving
QAdd's one-rounding input step free of undefined behaviour and equal to the gemmlowp reference for every input, zero point, left shift and multiplier in its domain, with two new planted defects that must be caught (#273). - The quantization suite compares
QAddwith the reference arithmetic over all 65,536 input pairs for 480 parameter sets, and builds with the split dense loops on, so every dense test runs them; new tests checkapplyOneRounding()againstapply()for four storage types (#273, #275).
Benchmarks
- Every table on the benchmarks page is re-measured on both boards. With the SMLAD backend, tinymind takes 16.4% fewer cycles than TFLM with CMSIS-NN on the MLPerf Tiny keyword-spotting model and 29.4% fewer on image classification (#274).
make TOOLCHAIN=clangbuilds the tinymind images with Clang through a newclang-arm-cxxwrapper, which adds-munaligned-access(without it the SMLAD backend's word loads become byte loads) and-fshort-enums. Every Clang image is bit-exact with the GCC build; GCC is 3–45% faster, and the page says so (#274).- The bench harness's idle loops were undefined behaviour in C++ (an empty infinite loop), which Clang deleted; they now hold an empty
asm volatile, and the GCC images compile to identical code (#274).
Docs and CI
- The agent instructions are split into one
AGENTS.mdper area, withCLAUDE.mdimporting them (#270), and thehar_activityseed statistic is corrected (#269). - The CI apt installer falls back to mirrors outside Canonical's network when the default archive is unreachable (#271).
- README, the Pages site and the architecture notes describe
QAdd's one-rounding inputs and the Thumb-1 dense split (#276).
Documentation, architecture guides, and example gallery: https://danmcleran.github.io/tinymind/
Full changelog: v18.1...v18.2