embassy-stm32

Crates

git

Versions

stm32n657i0

Flavors

Skip to main content

Module epoch

Module epoch 

Source
Expand description

CPU-side software epochs for the tail of a network (softmax, dequantization, argmax). Requires the npu-nn feature. Software epochs: the CPU-side tail of a network, running embedded-nn kernels.

ST Edge AI does not emit a purely hardware network. The tail of a compiled network is normally a run of software epochs — softmax, dequantization, argmax — that the Cortex-M55 executes once the NPU’s hardware epochs have finished. EpochBlock models that shape (blob: None is a pure software epoch), but its start/end are bare fn() pointers and so cannot carry the buffers a kernel needs. These types are therefore used directly, alongside the hardware epochs rather than inside an EpochBlock.

Each one is a thin wrapper over the equivalent [embedded-nn] kernel, so the CPU half of a network runs the same integer arithmetic as the rest of that runtime.

ⓘ
use embassy_stm32::npu::epoch::{ArgMaxEpoch, SoftmaxEpoch, SoftwareKernel};

// Logits written by the NPU's hardware epoch.
let logits: &[i8] = /* ... */;

let mut probabilities = [0i8; 5];
SoftmaxEpoch::new_1d(logits, &mut probabilities, mult, shift, diff_min).run().unwrap();

let (mut class, mut score) = (0usize, 0i8);
ArgMaxEpoch::new(logits, &mut class, &mut score).run().unwrap();

Enabled by the npu-nn feature, which brings in the embedded-nn dependency.

Structs§

ArgMaxEpoch
Finds the index and value of the largest element of a logit slice.
DequantizeEpoch
Dequantizes int8 NPU output to f32 using a scale and zero-point.
SoftmaxEpoch
Applies [embedded-nn]’s fixed-point softmax over a row of logits.

Enums§

EpochError
Error returned by a software epoch.

Traits§

SoftwareKernel
A step of a network that runs on the Cortex-M55 rather than on the NPU.