Skip to main content

Crate iree_embedded

Crate iree_embedded 

Source
Expand description

A safe, no_std Rust API for machine-learning inference on Cortex-M microcontrollers, built on IREE’s bare-metal C runtime.

The runtime half of IREE (loading a compiled model and invoking it) is wrapped in six RAII types (Arena, Instance, Device, Context, Tensor, Error) so leaks and double-frees are compile-time impossibilities and every fallible call returns a Result carrying the real IREE status message. See the repository for a complete firmware example and the model-compilation workflow.

Macros§

include_vmfb
Embed a compiled .vmfb as a 64-byte-aligned &'static [u8].
libc_stubs
Provide the libc stubs a bare-metal newlib link expects, sized for this crate’s allocation model.
link_kernels
Declare the query entry point of a statically linked IREE executable library and yield it as a LibraryQueryFn.
singleton
Hand out a unique &'static mut to a static, at most once per call site.

Structs§

Arena
A fixed-size memory pool backing every IREE allocation. Built over a static byte buffer the caller provides; IREE’s runtime allocates and frees objects inside it through a talc allocator, so it behaves like a heap of a compile-time-constant size.
Context
A loaded model: the HAL module plus the bytecode module from a .vmfb, ready to resolve and invoke functions. Borrows its Instance.
Device
A synchronous, single-threaded local CPU device that executes a model’s kernels. Created with either the static-library loader (local_sync_static) or the embedded-ELF loader (local_sync).
Error
An IREE failure: a classified StatusCode, the raw code, and the formatted status message (source location and annotations).
Function
A resolved entry-point function. iree_vm_function_t is a plain value handle (not refcounted), so this is Copy.
Instance
The IREE VM instance: the top-level runtime object shared across sessions.
Tensor
A device buffer with shape and element type: an input to or output from Context::invoke.

Enums§

StatusCode
A coarse classification of an IREE failure, mapped from the raw status code.

Statics§

LAST_ALLOC_FAIL_SIZE
Byte length of the most recent allocation the arena could not satisfy (0 if none). Useful for diagnosing on-device out-of-memory failures.

Type Aliases§

LibraryQueryFn
The *_library_query entry point emitted by iree-compile --iree-llvmcpu-static-library-output-path= (declared in the generated header alongside the .o). Declared with opaque pointers so firmware can extern "C" it without naming generated binding types; the shape is ABI-identical to iree_hal_executable_library_query_fn_t (uint32_t, pointer) -> pointer.
Result
The result type returned by fallible operations in this crate.