use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum AutodiffError {
NotDifferentiable {
op: String,
fix: String,
},
BufferNotFound {
name: String,
},
UnsupportedNode {
kind: String,
},
}
impl fmt::Display for AutodiffError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotDifferentiable { op, fix } => {
write!(f, "autodiff: op `{op}` is not differentiable. Fix: {fix}")
}
Self::BufferNotFound { name } => {
write!(f, "autodiff: buffer `{name}` not found in Program. Fix: check buffer declarations match the output/input sets.")
}
Self::UnsupportedNode { kind } => {
write!(f, "autodiff: unsupported IR node `{kind}`. Fix: expand autodiff coverage or restructure the Program.")
}
}
}
}
impl std::error::Error for AutodiffError {}