Skip to content
Xila

Neural network

How Xila loads models and runs inference through neural-network devices.

Last updatedEdit page

The Core neural_network library defines the contract between inference backends and device adapters. It lets a runtime expose model inference through the virtual file system (VFS).

A neural_network::Backend represents a prepared model and creates independent execution storage. The Core neural-network driver adapts a backend to character-device operations. A neural_network::Loader can prepare a backend from model bytes.

The following diagram shows the loader descriptor lifecycle.

Loader descriptor lifecycleStartStagingReadyEnd openwrite modelLOAD succeedsCOMPUTEcloseclose

The descriptor starts in staging. The caller writes model bytes sequentially and sends LOAD with a LoadRequest. After a successful load, the caller queries input information, selects an input, seeks to zero, and writes tensor bytes. COMPUTE runs inference. The caller then selects an output, seeks to zero, and reads its bytes. Closing releases the model and execution state.

The native runtime mounts a CPU loader at /devices/nn/cpu when its neural-network feature is enabled. See examples/native/src/main.rs for its registration.

The backend supplies views directly into execution or model storage. The adapter does not stage tensors. Each loader defines its maximum model size. A fixed-model device can expose an already prepared backend without the loading stage.

Inference commands before a successful load return InvalidContext. A second load on a ready descriptor also returns InvalidContext. Model writes must be contiguous. The version-one tensor metadata supports a maximum rank of six.