Skip to main content

<alp/inference.h> — NPU Dispatcher

A single API for running compiled models — TFLite Micro, Vela, DRP-AI, DXNN, ONNX — on the right silicon-specific NPU back-end, or on the portable CPU floor.

Supported back-ends​

Back-endBuild gateAvailable on
Arm Ethos-U55CONFIG_ALP_TFLM_ETHOS_U55Every E1M-AEN SKU (E3 / E4 / E5 / E6 / E7 / E8) — two instances per SoC
Arm Ethos-U85CONFIG_ALP_TFLM_ETHOS_U85E1M-AEN401 / AEN601 / AEN801 / AEN803 (Alif E4 / E6 / E8 only) — one instance per SoC, Transformer-capable, generative-AI forward path
Renesas DRP-AI3CMake option ALP_SDK_USE_DRPAI_V2N (default OFF) — not a Zephyr Kconfig symbolE1M-X V2N family
DEEPX DX-M1CMake option ALP_SDK_USE_DEEPX_DXM1 (default OFF)E1M-X V2M family (V2N + DX-M1; non-TFLM runtime — DXNN)
CPU(fallback, always available)Any target — TFLM reference kernels on M-class/Zephyr, ONNX Runtime on the A55s under Yocto

Which Ethos-U dispatchers compile in is silicon-determined — the SDK's loader reads the active SoM preset's capabilities: block and emits CONFIG_ALP_SDK_INFERENCE_* for every dispatcher the silicon can drive (TFLM CPU always; Ethos-U per caps). DRP-AI3 and DEEPX DX-M1 are gated by CMake options instead — see Linux-only NPU backends below. The customer's board.yaml does not carry an inference.backend: knob.

Ethos-U65 and the i.MX 93 backend were removed in v0.17.0

E1M-NX9101 support was removed, and with it the Ethos-U65 backend and the Kconfig symbols CONFIG_ALP_TFLM_ETHOS_U65, CONFIG_ALP_SDK_INFERENCE_BACKEND_ETHOS_U_N93 and CONFIG_ALP_SDK_INFERENCE_ETHOS_U_VARIANT_U65.

Apps pick a backend per handle at runtime via alp_inference_open(.backend = ALP_INFERENCE_BACKEND_AUTO | _CPU | _ETHOS_U | _DRPAI | _DEEPX_DXM1). AUTO picks the backend on the active SoM that loads cfg->format — a DRP-AI model goes to DRP-AI, a DXNN model to DX-M1 — and returns ALP_ERR_NOSUPPORT if the SoM has none. On the V2M family the dispatcher set carries both DRP-AI3 and DEEPX DX-M1; give each handle its own model format to use both NPUs (see One job per NPU at a time).

The U55 / U85 split is driven by the loader's requires_cap matcher reading each SoM preset's capabilities: block — pick the SKU, the right CONFIG_* follows automatically.

ALP_INFERENCE_BACKEND_CPU = 1 is no longer TFLM-only​

ALP_INFERENCE_BACKEND_CPU is now the portable CPU floor, and what runs underneath it depends on the OS:

OS / core classCPU-floor runtime
M-class / ZephyrTFLM reference kernels
Cortex-A55 / YoctoONNX Runtime

A real ONNX Runtime CPU inference backend for the Cortex-A55 / Yocto peer shipped in this release. CPU still carries the lowest priority under AUTO — pin it explicitly when you want the CPU floor on a SoM that also has an NPU.

#include <alp/inference.h>

Quick example​

extern const uint8_t my_model_tflite[];
extern const size_t my_model_tflite_len;

static uint8_t arena[256 * 1024];

alp_inference_t *infer = alp_inference_open(&(alp_inference_config_t){
.model_data = my_model_tflite,
.model_size = my_model_tflite_len,
.format = ALP_INFERENCE_MODEL_TFLITE,
.backend = ALP_INFERENCE_BACKEND_AUTO,
.arena_bytes = sizeof(arena),
.arena = arena,
});
if (infer == NULL) {
int err = alp_last_error();
return err;
}

// Get input tensor metadata
alp_inference_tensor_t input;
alp_inference_get_input(infer, 0, &input);
memcpy(input.data, my_image, input.size_bytes);

// Run
alp_inference_invoke(infer);

// Read output
alp_inference_tensor_t output;
alp_inference_get_output(infer, 0, &output);
// process output.data ...

alp_inference_close(infer);

Opening a handle​

alp_inference_open() error set​

alp_inference_open() returns NULL on failure and stamps alp_last_error() with one of:

ALP_ERR_INVAL, ALP_ERR_NOT_PRESENT_ON_THIS_SOC, ALP_ERR_NOT_IMPLEMENTED, ALP_ERR_NOSUPPORT, ALP_ERR_NOMEM, ALP_ERR_IO, ALP_ERR_BUSY (a fourth distinct DX-M1 core set in one process, or DRP-AI3 already open from another process).

Choosing accelerator units: accel_unit_mask​

New in v0.17.0 ([ABI-EXPERIMENTAL]), alp_inference_config_t.accel_unit_mask picks which accelerator unit(s) of the selected backend run the model. 0 is the backend's default (every unit it can use); bit n selects unit n. A mask the backend cannot honour makes alp_inference_open() return NULL with ALP_ERR_NOSUPPORT — it is never silently ignored or narrowed.

BackendValid masks
DEEPX DX-M1Bits 0..2 are NPU cores 0..2; any non-empty subset (0x1..0x7). 0 and 0x7 both mean all three cores. At most three distinct core sets can be live in one process; a fourth returns ALP_ERR_BUSY.
Renesas DRP-AI3One unit: 0 or 0x1.
Arm Ethos-U (Alif)The NPU instance visible to the calling core: only bit 0, on single-NPU cores. Multi-NPU parts are unverified — do not rely on bits above 0 there.
TFLM, ONNX Runtime, CPUOnly 0.

Tensors with rank above 4​

alp_inference_tensor_t.shape has exactly four slots (rank is 0..4, and shape is valid through rank - 1). Since v0.17.0 the ONNX Runtime, DEEPX and TFLM backends refuse a model whose tensor rank exceeds 4 instead of reporting a silently truncated shape: alp_inference_open() fails with ALP_ERR_NOSUPPORT, as do alp_inference_get_input() / alp_inference_get_output() for such a tensor.

arena == NULL is rejected for Ethos-U models​

A model that dispatches to Ethos-U with cfg->arena == NULL now returns ALP_ERR_INVAL at open, instead of a silent bus abort. A hard, named failure at open() beats an unexplained abort later.

The dispatch decision is op-driven: the backend looks for the ethos-u custom op in the model flatbuffer. It does not key off cfg->format. So a model you assumed was a plain CPU TFLite blob will still take the Ethos-U path — and still require an arena — if the ethos-u custom op is present in it.

Per-invoke latency​

ABI-EXPERIMENTAL

alp_inference_last_invoke_latency_us() is [ABI-EXPERIMENTAL]. The file-level marker for <alp/inference.h> stays [ABI-STABLE] — this one accessor is the mixed-tier exception.

alp_status_t alp_inference_last_invoke_latency_us(alp_inference_t *inf, uint64_t *out_us);

Wall-clock duration of the most recent successful alp_inference_invoke() call, in microseconds.

It brackets the backend's synchronous invoke. Every shipped backend — TFLM/Ethos-U, DRP-AI3, DEEPX DX-M1, ONNX Runtime — blocks the calling thread until the result lands, so this is a real per-invoke measurement taken by the dispatcher itself, not an estimate a backend opts into. There is no backend that "can't" report it.

It reports only the last successful invoke. No accumulation, no history, no ring buffer: a caller building a distribution (mean / p95 / run count) calls this once per alp_inference_invoke() and keeps the samples itself. A failed invoke — any return other than ALP_OK — does not update the stored value; reading after a failed invoke still returns the last value a successful invoke produced.

Units are MICROSECONDS — divide by 1000 for the benchmark schema

The tier-2 benchmark recipe schema's latency_ms_mean / latency_ms_p95 fields are in MILLISECONDS. This accessor performs no unit conversion. A missed division by 1000 publishes a number 1000x too large.

out_us is rounded to nearest, not floored — a sub-microsecond invoke reports 0 only when it truly rounds to 0, not by truncation bias.

Overlapping invokes are last-STORE-wins​

Two threads calling alp_inference_invoke() on the same handle concurrently is a real interleaving the SDK permits: the handle's op counting is a drain counter, not a mutex. When invokes overlap, the stored value is whichever invoke's atomic store instruction executes last — not largest-duration-wins and not largest-finish-time-wins. A scheduler can preempt between an invoke's compute finishing and its store running, so the last store is not necessarily the invoke that finished last in wall-clock time.

The accessor makes no attempt to attribute a reading to a specific invoke call when more than one is in flight. Read it only when you know at most one alp_inference_invoke() is outstanding on the handle, or treat the reading as "some recent invoke's duration", not "this specific call's".

Ceilings (Zephyr / M-class only)​

The Zephyr/M-class dispatcher stores the value in a 32-bit field. A naturally-aligned uint32_t load/store is lock-free on every Cortex-M this SDK targets, unlike the uint64_t the field used to be — M-profile has no 64-bit atomic instruction, so GCC lowered a 64-bit __atomic_store_n / __atomic_load_n to a libatomic call, and the Zephyr SDK's arm-zephyr-eabi toolchain ships no libatomic, so every Cortex-M app failed to link.

A duration exceeding UINT32_MAX - 1 microseconds (4294967294 us, just under ~71.58 minutes) therefore SATURATES at UINT32_MAX - 1 rather than wrapping. Raw UINT32_MAX is reserved as the "no successful invoke yet" sentinel and is never returned as a measured duration, so the ceiling sits one microsecond short of the field's true numeric range. Saturating is implausible for one invoke in practice, but it is the honest, observable ceiling: the caller reads ALP_OK plus the saturated value, not ALP_ERR_NOT_READY.

A tighter, silent limit sits in front of that one

On a target without CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER, the underlying hardware cycle counter itself wraps modulo 2^32 cycles first (it depends on CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC), and this accessor cannot detect that wrap.

Unlike the 32-bit storage ceiling, which fails safe (a saturated value that reads back as implausibly huge), a wrapped cycle-counter delta produces a plausible-looking, too-small duration reported with ALP_OK, not an error.

Zephyr's CORTEX_M_SYSTICK_64BIT_CYCLE_COUNTER defaults to y only when CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC exceeds 60 MHz, so under stock Kconfig the 32-bit-counter fallback only compiles in at 60 MHz or below, where the wrap ceiling is >= ~71.58 s (2^32 cycles / 60 MHz). A 400 MHz target left at Kconfig defaults selects the 64-bit counter instead and never hits this wrap — "~10.74 s at 400 MHz" is a naive 2^32-cycles-at-400 MHz calculation and not a combination stock Kconfig produces.

On CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER targets — e.g. the E1M-AEN801 M55 cores, and any target with an ARM architected/GIC timer, which selects the Kconfig unconditionally — the wrap limit does not apply and the 32-bit storage ceiling above is the binding one.

The Yocto / A-class dispatcher has neither limit: native 64-bit atomics on x86-64 / aarch64, and a 64-bit CLOCK_MONOTONIC nanosecond delta. It has no ceiling to saturate against at all.

Cross-OS ceiling contract. On both OSes, once alp_inference_invoke() has completed with ALP_OK at least once, this accessor reports ALP_OK with a real duration — never ALP_ERR_NOT_READY merely because the duration was long. Zephyr's UINT32_MAX - 1 clamp is what makes that true there: without it, a duration landing exactly on the field's raw numeric ceiling would collide with the "no successful invoke yet" sentinel.

Returns​

CodeMeaning
ALP_OKout_us holds the last successful invoke's duration in whole microseconds.
ALP_ERR_INVALout_us is NULL.
ALP_ERR_NOT_READYinf is NULL/closed, or no alp_inference_invoke() has completed with ALP_OK on this handle yet. Never "the invoke was too slow to report."
ALP_ERR_NOSUPPORTThe stub build only — no inference backend compiled in at all, so there is no timing mechanism that could ever have been populated.

Concurrency and NPU sharing​

One job per NPU at a time​

Each NPU runs one job at a time. Invokes on different handles that sit on the same NPU take turns: DRP-AI3 jobs are serialised by the SDK with a process-wide lock (the driver rejects a concurrent job rather than queueing it), and the DX-M1 time-shares between engines. For real concurrency, run one model per NPU — give each handle its own model format (so AUTO picks that format's NPU) and invoke from one thread per NPU. The v2n-two-models example shows the pattern.

DRP-AI3 is one process per board​

The first DRP-AI3 handle in a process takes an exclusive lock on /run/alp/drpai.lock and holds it until the process's last DRP-AI3 handle closes. A DRP-AI3 alp_inference_open() from a second process returns NULL with ALP_ERR_BUSY; several handles inside one process are fine. The image creates the directory at boot; if the lock file cannot be opened, the open fails with ALP_ERR_IO. The DX-M1 has no such limit.

DRP-AI3 job failures are not reported

The DRP-AI3 runtime's Run() returns void, so a job the driver rejected or that timed out still makes alp_inference_invoke() return ALP_OK. Check the output tensors if that matters to your application.

Backend registry​

Ethos-U registers per silicon, not once globally:

BackendSilicon refPriority
Ethos-Ualif:ensemble:e3, e4, e5, e6, e7, e8100 each
CPU / TFLM"*"50

The CPU/TFLM fallback matches everything at priority 50, so an SoC with no NPU entry still resolves. That table is the Zephyr registry (ALP_BACKEND_REGISTER); on Yocto, ALP_INFERENCE_BACKEND_CPU resolves to ONNX Runtime on the A55s instead — see ALP_INFERENCE_BACKEND_CPU = 1 is no longer TFLM-only.

Ethos-U accelerator sizing​

Accelerator sizing is derived from SoC metadata, per target core — not from the SoC maximum. The build picks the most capable NPU variant present (U85 > U55) and reads MAC/cycle from the SoC metadata, preferring the NPU entry whose paired_core matches the slice being built.

That last clause matters on a multi-core SoM: two cores on the same SoC can legitimately build against different accelerator configurations, because each is paired with a different NPU instance.

Valid accelerator configurations:

VariantConfigurations
Ethos-U55ETHOS_U55_64, ETHOS_U55_128, ETHOS_U55_256
Ethos-U85ETHOS_U85_128, ETHOS_U85_256, ETHOS_U85_512, ETHOS_U85_1024, ETHOS_U85_2048

Linux-only NPU backends (DRP-AI3 / DEEPX DX-M1)​

Both are real backends and both are opt-in (default OFF). DEEPX DX-M1 is verified on silicon; DRP-AI3 is not yet.

Renesas DRP-AI3 (RZ/V2N)​

The RZ/V2N DRP-AI3 backend runs against the real MERA DRP-AI TVM runtime (MeraDrpRuntimeWrapper).

It is gated by a CMake option, not a Zephyr Kconfig symbol — DRP-AI3 is A55/Linux-only, so a Zephyr symbol would be the wrong mechanism:

OptionDefaultEffect
ALP_SDK_USE_DRPAI_V2NOFFCompiles in the DRP-AI3 backend.
ALP_SDK_DRPAI_REQUIREDOFFTurns a missing DRP-AI stack from a warning into a hard configure error.

The orchestrator emits -DALP_SDK_USE_DRPAI_V2N=ON automatically when the board declares capabilities.drp_ai, so you do not normally set it by hand.

Not run on silicon

The DRP-AI3 backend has NOT run on silicon. It is header-checked against the real runtime surface only. Treat every result from it as unverified until it has been on a bench.

DEEPX DX-M1​

DEEPX DX-M1 mirrors this: CMake option ALP_SDK_USE_DEEPX_DXM1, default OFF, a real backend against dxrt::InferenceEngine. As of v0.17.0 it is verified on DX-M1 silicon, with outputs matching an ONNX Runtime CPU reference.

caution
libdxrt installs fatal-signal handlers

Linking libdxrt — which libalp_sdk does on V2M — installs SIGSEGV / SIGBUS / SIGABRT handlers that call exit(1).

<alp/ext/deepx/inference.h> — core binding and telemetry​

The DEEPX escape hatch was reworked in v0.17.0 and is now implemented on the Yocto DX-M1 backend. On a Zephyr build every call returns ALP_ERR_NOT_PRESENT_ON_THIS_SOC after argument checks, since the DX-M1 hangs off the A55's PCIe.

alp_status_t alp_deepx_inference_bind_cores(alp_inference_t *inf, uint32_t mask);
alp_status_t alp_deepx_inference_get_status(alp_inference_t *inf,
alp_deepx_device_status_t *status_out);
  • alp_deepx_inference_bind_cores() rebuilds the handle's engine on a different set of the ALP_DEEPX_NPU_CORE_COUNT (3) NPU cores, using the same mask meaning as accel_unit_mask. The model_data passed at open must still be valid; output tensors fetched earlier are invalid afterwards (input buffers stay valid); it blocks until any in-flight invoke on the handle finishes. It returns ALP_ERR_NOSUPPORT for a bit above 2, ALP_ERR_BUSY if the new set would be the process's fourth distinct core set, and ALP_ERR_IO / ALP_ERR_NOMEM if libdxrt cannot build the new engine — in every failure case the handle keeps its old binding. Prefer accel_unit_mask at open: this call holds both the old and new set while it swaps.
  • alp_deepx_inference_get_status() fills an alp_deepx_device_status_t with per-core temperature_c[], npu_clock_mhz[] and npu_voltage_mv[], plus memory_bytes (the on-card DRAM size). It is safe to call while another thread invokes on the handle. The values are libdxrt's own and match dxrt-cli -s — on DX-M1 firmware v2.4.0, NPU 0's voltage reads 2779096 mV, so treat a value far outside the 0.75 V rail as a firmware reading, not a fault.
Breaking: slot and DRAM-tile calls removed

alp_deepx_inference_slot_pin(), alp_deepx_inference_dram_tile_reserve(), alp_deepx_inference_slot_t, ALP_DEEPX_INFERENCE_SLOT_COUNT and the alp_deepx_inference_status_t flags are gone, and alp_deepx_inference_get_status() now takes an alp_deepx_device_status_t * instead of a uint32_t * flag mask.

Never more than three distinct core sets on one DX-M1

At most three distinct core sets can be live on one DX-M1 (all three cores — mask 0 or 0x7 — counts as a set; same-set engines share a queue). A fourth makes dx-rt abort the process or kill dxrtd. The SDK refuses it with ALP_ERR_BUSY within one process only — nothing guards it across processes. Two processes on dx-rt 3.2.0 need the dxrtd service.

Vendor escape-hatch headers​

The per-vendor escape hatches moved out of <alp/vendors/...> and into the <alp/ext/<vendor>/...> tree that the rest of the SDK's vendor extensions already use:

VendorHeaderWas
Renesas<alp/ext/renesas/inference.h><alp/vendors/renesas/drpai.h>
DEEPX<alp/ext/deepx/inference.h><alp/vendors/deepx/dxm1.h>

The old paths no longer exist — update any #include that still names them.

board.yaml​

cores:
m55_hp:
inference:
default_arena_kib: 256 # the only inference knob —
# dispatcher set is silicon-determined (SoM preset's
# capabilities:), app picks the runtime backend
# per handle via alp_inference_open().

There is no inference.backend: field — the build compiles in every dispatcher the SoM's capabilities: block declares (TFLM CPU always; Ethos-U per silicon, via CONFIG_ALP_SDK_INFERENCE_*). DRP-AI3 and DEEPX DX-M1 are the exception: they are compiled in by the CMake options ALP_SDK_USE_DRPAI_V2N / ALP_SDK_USE_DEEPX_DXM1 (both default OFF), which the orchestrator turns on from the board's declared capabilities — capabilities.drp_ai drives -DALP_SDK_USE_DRPAI_V2N=ON. Apps still select per-handle at runtime via alp_inference_open(.backend = ...).

Model formats​

alp_inference_model_format_t — each backend supports a subset; AUTO does not sniff the model buffer's magic bytes. On Zephyr / RTOS builds the backend registry picks by silicon ref and priority; on Yocto, AUTO resolves from cfg->format:

MemberValueMeaning
ALP_INFERENCE_MODEL_TFLITE0.tflite flatbuffer.
ALP_INFERENCE_MODEL_VELA1Vela-compiled .tflite.
ALP_INFERENCE_MODEL_DRPAI2Renesas DRP-AI binary.
ALP_INFERENCE_MODEL_DXNN3DEEPX DXNN binary.
ALP_INFERENCE_MODEL_EXECUTORCH4ExecuTorch program. Producible, not runnable — see below.
ALP_INFERENCE_MODEL_ONNX5Raw .onnx graph (ONNX Runtime CPU backend).
  • TFLite Micro — the universal input format. Vela-compiled for Ethos-U backends.
  • DRP-AI binary — Renesas DRP-AI3 path consumes models converted via the DRP-AI Translator toolchain.
  • DXNN — DEEPX path consumes .dxnn files compiled from ONNX by the DEEPX compiler.
  • ONNX — a raw .onnx graph runs on the ONNX Runtime CPU backend (Cortex-A55 / Yocto).

The build system invokes the right compiler for the active backend.

ALP_INFERENCE_MODEL_EXECUTORCH = 4 is producible but not invocable​

Producible but not invocable on device

The write side is live: board.yaml's models[].source accepts a .pte ExecuTorch program, and the ExecuTorch adapter produces an ALP_INFERENCE_MODEL_EXECUTORCH blob from it into the .alpmodel package. No backend runtime consumes it yet.

Backend selection reads silicon ref and priority, never cfg->format, so what happens on open depends on which backend wins: on a TFLM-linked build the CPU/TFLM backend's flatbuffer verify rejects the raw .pte bytes with ALP_ERR_INVAL (not a deliberate format check); with no TFLM linked, the priority-0 software fallback fails with ALP_ERR_NOSUPPORT. Do not ship a .pte model expecting it to execute.

Portable model packages (.alpmodel)​

ABI-EXPERIMENTAL

<alp/model.h> and alp_inference_open_alpmodel() are [ABI-EXPERIMENTAL] — pin your SDK to a commit if you depend on them.

tan model build compiles a source model for every NPU back-end the SoM declares into one fat multi-backend .alpmodel package — a 24-byte header + CBOR manifest + per-backend blobs + a capability requires envelope. At runtime alp_inference_open_alpmodel() loads the package, a selection engine picks the blob that matches the active SoM, and the handle dispatches through the same backend registry as alp_inference_open(). One model, portable across NPUs with no source changes.

alp_inference_t *alp_inference_open_alpmodel(const alp_model_open_opts_t *opts);

typedef struct {
const void *data; // package bytes, or NULL to use `path`
size_t size; // byte count when `data` is set
const char *path; // storage path (Linux), or NULL
alp_inference_backend_t backend; // AUTO, or a forced backend
size_t arena_bytes; // 0 = size from the manifest
void *arena; // caller arena, or NULL for backend default
} alp_model_open_opts_t;
extern const uint8_t detector_alpmodel[];
extern const size_t detector_alpmodel_len;

// MCU: embed the package bytes; AUTO lets the loader pick the best blob.
alp_inference_t *infer = alp_inference_open_alpmodel(&(alp_model_open_opts_t){
.data = detector_alpmodel,
.size = detector_alpmodel_len,
.backend = ALP_INFERENCE_BACKEND_AUTO,
});
if (infer == NULL) {
int err = alp_last_error(); // ALP_ERR_NO_FIT / _NO_BACKEND / _NOT_FOUND / _VERSION / _INVAL
return err;
}
// The returned handle works with every alp_inference_* accessor unchanged
// (get_input / invoke / get_output / close — see Quick example above).

On Linux, point at a storage path instead of embedding the bytes:

.path = "/lib/firmware/detector.alpmodel",

Selection. The loader picks the blob whose backend is available on the active SoC, whose silicon_ref is compatible, and that fits the device NPU arena envelope (ALP_SOC_NPU_ARENA_SRAM_KIB); ties break by the SoM's preferred backend. backend = AUTO falls back to a CPU blob if present; pinning an explicit NPU backend bypasses CPU fallback. Failure stamps alp_last_error():

CodeValueMeaning
ALP_ERR_VERSION-11Package container version is newer than this loader supports.
ALP_ERR_NO_BACKEND-12No blob for any backend available on this SoM (and no CPU fallback).
ALP_ERR_NO_FIT-13A backend matched but no blob fits the device NPU envelope, and no CPU fallback.
ALP_ERR_NOT_FOUND-14An explicitly-requested backend is absent from the package.

A bad magic / truncated / corrupt package returns ALP_ERR_INVAL.

Building a package​

For the full build-and-package walkthrough — per-backend compile: config, partial-coverage packages, arena sizing, and the read-side parser — see the AI Model Packaging guide.

tan model build reads the models: block of your board.yaml, derives the target back-ends from som.sku, and emits one .alpmodel per model:

tan model build --board board.yaml --out build/models
OptionDefaultWhat it picks
--boardboard.yamlPath to the board.yaml.
--outbuild/modelsOutput directory for the .alpmodels.
--metadata-rootthe SDK's metadata/Path to the metadata/ root.

Read-side parser (standalone firmware)​

Hand-written firmware that wants to inspect a package without the loader uses <alp/model.h> directly — gated on CONFIG_ALP_SDK_MODEL_READER:

#include <alp/model.h>

alp_model_t m;
alp_status_t rc = alp_model_parse(detector_alpmodel, detector_alpmodel_len, &m);
// rc == ALP_OK; ALP_ERR_INVAL (bad magic / truncated / CBOR error);
// ALP_ERR_VERSION (container newer than this reader).

alp_model_parse() decodes the manifest once into a bounded, stack-friendly alp_model_t view (no heap; the blobs reference the source buffer, which must outlive the view). It carries the model identity plus up to ALP_MODEL_MAX_TARGETS (8) per-backend target entries (backend, silicon_ref, blob_format, arena/SRAM requirements, and the blob slice). The container magic is ALP_MODEL_MAGIC ("ALPM"), container version 1.

Tensor arena​

arena_bytes (with an optional caller-owned arena) reserves working memory for the interpreter. Right-size this against the model's arena_size reported by Vela or the equivalent. Too small and alp_inference_open returns NULL with ALP_ERR_IO (the backend's tensor-arena allocation failed); too large just wastes RAM.

For a model that dispatches to Ethos-U, cfg->arena == NULL is rejected outright with ALP_ERR_INVAL — see arena == NULL is rejected for Ethos-U models.

Off-device training​

The SDK is inference-only. Train your model offline in TensorFlow or PyTorch, export to TFLite (or ONNX — for the DEEPX compiler, or to run directly on the ONNX Runtime CPU backend under Yocto), then deploy through <alp/inference.h>.

A .pte ExecuTorch export is accepted as a models[].source and packaged, but cannot be invoked on device — see ALP_INFERENCE_MODEL_EXECUTORCH = 4 is producible but not invocable.

Reference applications​

AppStack
examples/aen/edgeai-vision-aencamera → ISP → Ethos-U inference → OLED overlay
examples/connectivity/iot-connected-cameracamera → DRP-AI inference → MQTT publish

Default-initialiser macro​

Unlike the peripheral macros, ALP_INFERENCE_CONFIG_DEFAULT(id) (v0.10) takes the model blob pointer as its identity argument:

alp_inference_config_t cfg = ALP_INFERENCE_CONFIG_DEFAULT(model_blob);
cfg.model_size = model_blob_len; // mandatory — the default 0 is invalid

It sets model_data from id plus: model_size = 0, format = ALP_INFERENCE_MODEL_TFLITE, backend = ALP_INFERENCE_BACKEND_AUTO (let the dispatcher pick), arena_bytes = 0 and arena = NULL (SDK-managed arena), and accel_unit_mask = 0 (backend default).

You must still set model_size — a zero size is never valid.

See the shared macro contract for the C++ compound-literal caveat that applies to every ALP_*_CONFIG_DEFAULT.

See also​

Questions about this page? Email contact@alplab.ai