NNAPIBackend<T>

Models & Types · AiDotNet.Deployment.Mobile.Android

NNAPI (Neural Networks API) backend for Android deployment. Provides hardware acceleration on Android devices when libneuralnetworks.so is loadable; falls back to managed CPU execution otherwise.

Implements: IDisposable

For Beginners

NNAPI is the Android-side API that exposes hardware accelerators (GPU / DSP / NPU) for neural network inference. This backend binds to the native libneuralnetworks.so via P/Invoke; if the library is not present, the backend reports unavailability and routes execution through a managed CPU fallback when one has been configured.

How It Works

Default values follow the Android NNAPI guidance: relaxed FP32, optional FP16, and CPU fallback support. The CpuExecutor hook lets callers plug in a real managed inference path for fallback execution.

Constructors

Constructor Summary
NNAPIBackend(NNAPIConfiguration config, INNAPIGraphBuilder graphBuilder)

Methods

Method Summary
List<string> GetSupportedDevices() Gets the supported acceleration devices on this Android device.
NNAPIPerformanceInfo GetPerformanceInfo() Gets NNAPI performance information for the current device.
T[] Execute(T[] input) Executes inference using NNAPI or the managed CPU fallback.
Task<T[]> ExecuteAsync(T[] input) Executes inference asynchronously.
bool IsNNAPIAvailable() Checks if NNAPI is available on the current device.
void Dispose()
void Initialize() Initializes the NNAPI backend.
void LoadModel(string modelPath) Loads a model for NNAPI execution.