//! 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, actual: Vec, }, /// 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 = std::result::Result; impl From for OnnxError { fn from(err: ort::Error) -> Self { OnnxError::Ort(err.to_string()) } }