Neural network
How Xila loads models and runs inference through neural-network devices.
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).
Context
Section titled “Context”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.
How it works
Section titled “How it works”The following diagram shows the loader descriptor lifecycle.
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.
Design choices and trade-offs
Section titled “Design choices and trade-offs”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.
Limits
Section titled “Limits”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.
API reference
Section titled “API reference”neural_networkcrate: inference contracts.drivers_neural_network::NeuralNetworkDevice: fixed-model adapter.drivers_neural_network::LoaderDevice: runtime loader adapter.-
LoadRequest: model loading request.