pub enum Error {
LibraryNotFound(String),
SymbolNotFound(String),
InitFailed(i32),
QueryFailed(i32),
InferenceFailed(i32),
MemAllocFailed,
MemSyncFailed(i32),
SetIoMemFailed(i32),
InvalidModel,
InvalidIndex {
requested: usize,
available: usize,
},
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
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
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl !UnwindSafe for Error
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more