23#[derive(Clone, Copy, Eq, PartialEq, Encodable, Decodable, Debug, StableHash)]
24pub enum DiffMode {
25▶ /// No autodiff is applied (used during error handling).
26 Error,
27 /// The primal function which we will differentiate.
· · ·
26▶ Error,
27 /// The primal function which we will differentiate.
28 Source,
· · ·
113 fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
114 match self {
115▶ DiffMode::Error => write!(f, "Error"),
116 DiffMode::Source => write!(f, "Source"),
117 DiffMode::Forward => write!(f, "Forward"),
· · ·
125/// Const is valid for all cases and means that we don't compute derivatives wrt. this output.
126/// That usually means we have a &mut or *mut T output and compute derivatives wrt. that arg,
127▶/// but this is too complex to verify here. Also it's just a logic error if users get this wrong.
128pub fn valid_ret_activity(mode: DiffMode, activity: DiffActivity) -> bool {
129 if activity == DiffActivity::None {
· · ·
132 }
133 match mode {
134▶ DiffMode::Error => false,
135 DiffMode::Source => false,
136 DiffMode::Forward => activity.is_dual_or_const(),
+ 2 more matches in this file