Enum AutodiffError
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§
§impl Debug for AutodiffError
impl Debug for AutodiffError
§impl Display for AutodiffError
impl Display for AutodiffError
§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()
Source§impl From<AutodiffError> for Error
impl From<AutodiffError> for Error
Source§fn from(source: AutodiffError) -> Error
fn from(source: AutodiffError) -> Error
Converts to this type from the input type.
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
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more