pub enum AutodiffError {
NonScalarLoss {
num_elements: usize,
},
MissingNode,
TangentShapeMismatch {
expected: String,
got: String,
},
HvpNotSupported,
ModeNotSupported {
mode: String,
reason: String,
},
InvalidArgument(String),
GraphFreed,
}Expand description
AD-specific error type.
§Examples
use chainrules_core::AutodiffError;
let err = AutodiffError::NonScalarLoss { num_elements: 8 };
assert!(format!("{err}").contains("scalar"));Variants§
NonScalarLoss
Loss tensor for pullback must contain exactly one element.
MissingNode
Attempted pullback on a tensor not connected to AD tape.
TangentShapeMismatch
Tangent shape must match primal shape.
HvpNotSupported
A ReverseRule does not support HVP (pullback_with_tangents).
ModeNotSupported
The requested AD mode is not supported for the given algebra or operation.
For example, tropical einsum does not support frule (JVP) or hvp — only rrule (VJP) via the argmax route is available.
§Examples
use chainrules_core::AutodiffError;
let err = AutodiffError::ModeNotSupported {
mode: "frule".into(),
reason: "tropical einsum supports rrule only (max is not smooth)".into(),
};Fields
InvalidArgument(String)
Generic AD argument error.
GraphFreed
Attempted to execute backward/grad on a graph that was already freed.
§Examples
use chainrules_core::AutodiffError;
let err = AutodiffError::GraphFreed;
assert!(err.to_string().contains("freed"));Trait Implementations§
Source§impl Debug for AutodiffError
impl Debug for AutodiffError
Source§impl Display for AutodiffError
impl Display for AutodiffError
Source§impl Error for AutodiffError
impl Error for AutodiffError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for AutodiffError
impl RefUnwindSafe for AutodiffError
impl Send for AutodiffError
impl Sync for AutodiffError
impl Unpin for AutodiffError
impl UnwindSafe for AutodiffError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more