use thiserror::Error;
pub type Result<T> = std::result::Result<T, UnslothError>;
#[derive(Error, Debug)]
#[non_exhaustive]
pub enum UnslothError {
#[error("kernel error: {0}")]
Kernel(String),
#[error("out of memory: required {required} bytes, available {available} bytes")]
OutOfMemory {
required: usize,
available: usize,
},
#[error("device not available: {0}")]
DeviceNotAvailable(String),
#[error("shape mismatch: expected {expected:?}, got {actual:?}")]
ShapeMismatch {
expected: Vec<usize>,
actual: Vec<usize>,
},
#[error("invalid configuration: {0}")]
InvalidConfig(String),
#[error("quantization error: {0}")]
Quantization(String),
#[error("ternary operation error: {0}")]
Ternary(String),
#[error("candle error: {0}")]
Candle(#[from] candle_core::Error),
}