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
.vmfbas 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 mutto 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
talcallocator, 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 itsInstance. - 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_tis a plain value handle (not refcounted), so this isCopy. - 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§
- Status
Code - 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§
- Library
Query Fn - The
*_library_queryentry point emitted byiree-compile --iree-llvmcpu-static-library-output-path=(declared in the generated header alongside the.o). Declared with opaque pointers so firmware canextern "C"it without naming generated binding types; the shape is ABI-identical toiree_hal_executable_library_query_fn_t(uint32_t, pointer) -> pointer. - Result
- The result type returned by fallible operations in this crate.