68 lines
1.5 KiB
Rust
68 lines
1.5 KiB
Rust
//! ONNX Runtime error types
|
|
|
|
use thiserror::Error;
|
|
|
|
/// ONNX Runtime specific errors
|
|
#[derive(Error, Debug)]
|
|
pub enum OnnxError {
|
|
/// Failed to load ONNX model
|
|
#[error("Failed to load ONNX model: {0}")]
|
|
ModelLoad(String),
|
|
|
|
/// Failed to create ONNX Runtime session
|
|
#[error("Failed to create session: {0}")]
|
|
SessionCreation(String),
|
|
|
|
/// Failed to run inference
|
|
#[error("Inference failed: {0}")]
|
|
Inference(String),
|
|
|
|
/// Input tensor error
|
|
#[error("Input tensor error: {0}")]
|
|
InputTensor(String),
|
|
|
|
/// Output tensor error
|
|
#[error("Output tensor error: {0}")]
|
|
OutputTensor(String),
|
|
|
|
/// Missing input
|
|
#[error("Missing required input: {0}")]
|
|
MissingInput(String),
|
|
|
|
/// Missing output
|
|
#[error("Missing expected output: {0}")]
|
|
MissingOutput(String),
|
|
|
|
/// Unsupported data type
|
|
#[error("Unsupported data type: {0}")]
|
|
UnsupportedDType(String),
|
|
|
|
/// Shape mismatch
|
|
#[error("Shape mismatch: expected {expected:?}, got {actual:?}")]
|
|
ShapeMismatch {
|
|
expected: Vec<i64>,
|
|
actual: Vec<i64>,
|
|
},
|
|
|
|
/// Execution provider error
|
|
#[error("Execution provider error: {0}")]
|
|
ExecutionProvider(String),
|
|
|
|
/// IO error
|
|
#[error("IO error: {0}")]
|
|
Io(#[from] std::io::Error),
|
|
|
|
/// ORT error
|
|
#[error("ORT error: {0}")]
|
|
Ort(String),
|
|
}
|
|
|
|
/// Result type for ONNX operations
|
|
pub type Result<T> = std::result::Result<T, OnnxError>;
|
|
|
|
impl From<ort::Error> for OnnxError {
|
|
fn from(err: ort::Error) -> Self {
|
|
OnnxError::Ort(err.to_string())
|
|
}
|
|
}
|