Skip to content
heliaAOT
Examples
HELIA HUB

Float and FP16

Compile a float32 graph and a float16 graph for the same target, and see what the FP16 platform gate does when the hardware cannot serve it. Qualify your model, kernel build and target before deployment.

Field Value
Model one SQRT node, built in float32 and in float16
Target apollo510_evb
Shows Float kernel selection, the FP16 platform gate, and the ns-cmsis-nn build switches a float module needs
CI Conversion and host compilation are declared in the examples CI job, both precisions

The models are built by make_model.py. Each is a small SQRT fixture with matching input/output dtype, so it isolates conversion’s float path without depending on a downloaded model. It is not a general test of mixed precision, quantized weights or every float operator.

Use a repository checkout and activate its environment after uv sync --frozen --group ci. The model-building script imports the repository’s Python helpers; an isolated CLI installation alone is not enough. See Running examples.

Terminal window
./run.sh

A second run stops with Output path ... already exists, because the first run’s module is still in out/. Run ./run.sh --force to replace it.

The two configurations, config-float32.yaml and config-float16.yaml, select the corresponding model and retain separately named output modules. Nothing in the configuration selects a float kernel: the tensor dtypes do.

apollo510_evb declares both a single-precision FPU and the FP16 capability, so both conversions resolve. Ask for float16 on a target without it and the conversion stops before emitting anything:

Terminal window
helia-aot convert --model.path models/sqrt_float16.tflite --model.name sqrt_float16 \
--module.path ./out --module.name gate --module.type cmake --platform.name apollo4p_evb
Error: f16 kernels require a Cortex-M55-class/FP16 platform; got 'apollo4p_evb'
(cpu=cortex-m4)
hint: Target a Cortex-M55-class/FP16 platform, or re-export the model without
float16 tensors.

This is a separate negative check; run.sh performs the two positive conversions. FP32 does not use the FP16 platform gate, but still needs supported operator contracts and a compatible library/toolchain build. Neither conversion nor host compilation proves numerical SQRT behavior or device FP16 execution.

The float kernel objects exist only if ns-cmsis-nn was built with them, so the switch belongs on the library rather than on the generated module. For the CMake and NSX packagings set ARM_NN_ENABLE_F32 or ARM_NN_ENABLE_F16 before adding the ns-cmsis-nn subdirectory; for Zephyr the symbols are CONFIG_NS_CMSIS_NN_ENABLE_F32 and CONFIG_NS_CMSIS_NN_ENABLE_F16 in the application’s prj.conf. The module asks the library what it was built with, and a mismatch fails at configure time rather than at run time.

  • Float support for the precision table, the hardware requirements and the mixed-graph rules.
  • Operator catalog for which operators have float kernels and which kernel-library floor they need.