Skip to main content

llama_gguf/onnx/
error.rs

1//! Error types for ONNX operations
2
3/// Errors that can occur during ONNX file operations.
4#[derive(thiserror::Error, Debug)]
5pub enum OnnxError {
6    #[error("IO error: {0}")]
7    Io(#[from] std::io::Error),
8
9    #[error("Protobuf decode error: {0}")]
10    Decode(#[from] prost::DecodeError),
11
12    #[error("Missing ONNX graph in model")]
13    MissingGraph,
14
15    #[error("Missing initializer tensor: {0}")]
16    MissingTensor(String),
17
18    #[error("Unsupported ONNX data type: {0}")]
19    UnsupportedDataType(i32),
20
21    #[error("Missing config file: {0}")]
22    MissingConfig(String),
23
24    #[error("Config parse error: {0}")]
25    ConfigParse(String),
26
27    #[error("Unsupported model type: {0}")]
28    UnsupportedModelType(String),
29
30    #[error("Tensor shape mismatch for {name}: expected {expected} elements, got {actual}")]
31    ShapeMismatch {
32        name: String,
33        expected: usize,
34        actual: usize,
35    },
36
37    #[error("Model error: {0}")]
38    Model(#[from] crate::model::ModelError),
39
40    #[error("Tensor error: {0}")]
41    Tensor(#[from] crate::tensor::TensorError),
42
43    #[error("ONNX error: {0}")]
44    Other(String),
45}
46
47pub type OnnxResult<T> = std::result::Result<T, OnnxError>;