pub enum Error {
LibraryNotFound(String),
SymbolNotFound(String),
InitFailed(i32),
QueryFailed(i32),
InferenceFailed(i32),
MemAllocFailed,
MemSyncFailed(i32),
SetIoMemFailed(i32),
InvalidModel,
InvalidIndex {
requested: usize,
available: usize,
},
InvalidFormat {
expected: &'static str,
got: String,
},
IoError(Error),
}Expand description
Everything that can go wrong when using RKNN.
Most variants carry the RKNN error code (a negative i32).
The RKNN SDK doesn’t document specific codes, but common ones are:
-1- generic failure-2- invalid parameter-3- device not found
§Example
use rknn_runtime::{RknnModel, Error};
match RknnModel::load("model.rknn") {
Ok(model) => println!("Loaded!"),
Err(Error::LibraryNotFound(path)) => {
eprintln!("RKNN library not found at: {}", path);
eprintln!("Make sure librknnmrt.so is installed on the device.");
}
Err(e) => eprintln!("Error: {}", e),
}Variants§
LibraryNotFound(String)
librknnmrt.so could not be loaded. Contains the attempted path.
SymbolNotFound(String)
A required function was not found in the loaded library.
InitFailed(i32)
rknn_init() failed. The model file may be corrupt or incompatible.
QueryFailed(i32)
rknn_query() failed when reading tensor metadata.
InferenceFailed(i32)
rknn_run() failed during inference.
MemAllocFailed
NPU memory allocation returned null.
MemSyncFailed(i32)
rknn_mem_sync() failed. Cache sync between NPU and CPU did not complete.
SetIoMemFailed(i32)
rknn_set_io_mem() failed when binding a memory buffer to a tensor.
InvalidModel
The model data is empty or invalid.
InvalidIndex
Output index is out of range.
Fields
InvalidFormat
Tensor format or shape does not match what was expected.
Fields
IoError(Error)
File I/O error (e.g. model file not found).
Trait Implementations§
Source§impl Error for Error
Allow chaining
impl Error for Error
Allow chaining