Skip to content

v16.2 — MLPerf® Tiny reference models on a Cortex-M4: blocked SMLAD convolutions, folded padding, TFLite-exact softmax

Choose a tag to compare

@danmcleran danmcleran released this 19 Oct 20:20
· 71 commits to master since this release
2d902ca

v16.2 — MLPerf® Tiny reference models on a Cortex-M4: blocked SMLAD convolutions, folded padding, TFLite-exact softmax

The framework comparison now runs two of the MLPerf Tiny reference int8 models, unmodified, on a NUCLEO-F411RE (Cortex-M4F, 100 MHz) with tinymind and with TFLM. They are keyword spotting (DS-CNN) and image classification (ResNet-8). Every output of every image is bit-exact between the two stacks. The first run lost image classification to CMSIS-NN by 16% and needed more RAM than TFLM. This release closes both gaps with library changes, all bit-exact.

These are not MLPerf results. They were not produced with the MLPerf Tiny benchmark runner or under its rules: there is no accuracy run on the benchmark datasets and no energy measurement, and MLCommons has not verified them. They compare two inference stacks on the same reference models and the same inputs, and should not be compared with published MLPerf Tiny scores. MLPerf® is a registered trademark of MLCommons Association in the United States and other countries; see https://mlcommons.org.

Results (#229)

-O3, 100 MHz, tinymind +SMLAD against TFLM with CMSIS-NN. RAM is static RAM plus peak stack, including TFLM's tensor arena; flash includes the weights.

Model Framework Cycles Flash RAM
Keyword spotting (DS-CNN) tinymind +SMLAD 8,193,064 53,156 17,248
TFLM CMSIS-NN 9,583,099 148,864 24,432
Image classification (ResNet-8) tinymind +SMLAD 26,753,191 108,324 54,424
TFLM CMSIS-NN 37,372,049 191,212 56,608
  • tinymind takes 14.5% fewer cycles on keyword spotting and 28.4% fewer on image classification. It is faster on every layer of both models at -O2 and -O3.
  • It needs a third of TFLM's flash on keyword spotting and 57% of it on image classification, and less RAM on both.
  • The existing benchmark models did not regress. The KWS-style CNN is within 0.3% at -O3 and up to 2% faster at -O2. The MLP and the Cortex-M0+ images are unchanged.

Library changes (#229)

  • Blocked SMLAD convolutions. simd::ConvRows2x2 / int8Dot2x2WithZeroPoint multiply two inputs against two weight rows.
    • On the ARM_DSP backend, the convolution form is an out-of-line SMLAD kernel computing two filters by two output pixels, so each load feeds two multiplies. When it was inlined, its accumulators spilled and the layer cost swung by 30% with unrelated code.
    • Every other backend makes four int8DotWithZeroPoint calls, with unchanged output and speed.
    • QConv2D / QConv2DPerChannel use the kernel on the row path (windows over 64 bytes). QPointwiseConv2D(PerChannel) uses it at 32 or more input channels when the backend has the blocked kernel.
  • Folded SAME padding. QConv2D, QConv2DPerChannel and QDepthwiseConv2D take optional PadTop, PadBottom, PadLeft and PadRight template parameters. Padding uses the input zero point, as TFLite does.
    • Instead of a QPad2D pass and a padded copy of the input, these layers keep a ring of KH padded rows on the stack. The stack band is bounded by TINYMIND_CONV_PAD_BAND_MAX_BYTES.
    • This removes the 12 KB and 18 KB padded copies that had put tinymind's RAM above TFLM's.
  • TFLite-exact softmax. QSoftmaxFixedPoint1D (cpp/qsoftmax_fixedpoint.hpp) reproduces the TFLite int8 softmax bit for bit. buildQSoftmaxFixedPointParams in qcalibration.hpp derives its parameters as TFLite Micro does.

Benchmark harness (#229)

  • SUITE=mlperf builds the MLPerf images.
  • make mlperf-models downloads the reference models at a pinned commit and checks their SHA-256. They are Apache-2.0 (MLCommons) and are not committed to the repository.
  • gen/make_mlperf.py rebuilds each graph from tinymind layers with the model's own weights and requantizer parameters. make host-check-mlperf checks the result on the host.
  • Captures now stop at each image's end marker instead of after a fixed 6 s. TFLM's reference kernels take about 90 s on ResNet-8.
  • TFLM images rebuild when the Makefile changes, so a stale image is never re-measured after an arena-size edit.

Tests (#229)

  • The quantization suite gains these tests:
    • folded padding against QPad2D for convolution and depthwise layers, including a stride larger than the kernel height;
    • wide blocked pointwise against the reference;
    • softmax goldens and a hashed sweep from the TFLite Micro reference kernel.
  • The arm_dsp_qemu gate now also covers the 2×2 kernels, padded convolutions and wide pointwise. Run on the F411 itself, it checked 140,766 cases with 0 mismatches and caught four planted defects.

Docs

  • The benchmark page has a new MLPerf Tiny reference models section, with a per-layer table for ResNet-8 (#229).
  • The benchmark README and the Pages page credit the UCI digits dataset (CC BY 4.0) used by the framework comparison. Its generators emit that credit into the committed data headers (#228).

Documentation, architecture guides, and example gallery: https://danmcleran.github.io/tinymind/

Full changelog: v16.1...v16.2