use thiserror::Error;
pub type Result<T> = std::result::Result<T, PMetalError>;
#[derive(Error, Debug)]
pub enum PMetalError {
#[error("Failed to load model: {0}")]
ModelLoad(String),
#[error("Unsupported model architecture: {0}")]
UnsupportedArchitecture(String),
#[error("Configuration error: {0}")]
Config(String),
#[error("Shape mismatch: expected {expected:?}, got {actual:?}")]
ShapeMismatch {
expected: Vec<usize>,
actual: Vec<usize>,
},
#[error("Dtype mismatch: expected {expected}, got {actual}")]
DtypeMismatch {
expected: String,
actual: String,
},
#[error("Out of memory: required {required_gb:.2}GB, available {available_gb:.2}GB")]
OutOfMemory {
required_gb: f64,
available_gb: f64,
},
#[error("Quantization error: {0}")]
Quantization(String),
#[error("Training error: {0}")]
Training(String),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Serialization error: {0}")]
Serialization(String),
#[error("Hub error: {0}")]
Hub(String),
#[error("Tokenizer error: {0}")]
Tokenizer(String),
#[error("MLX error: {0}")]
Mlx(String),
#[error("Invalid argument: {0}")]
InvalidArgument(String),
#[error("Not implemented: {0}")]
NotImplemented(String),
}