pub enum TapeOp {
Show 34 variants
Const(f64),
Var(usize),
Add(usize, usize),
Sub(usize, usize),
Mul(usize, usize),
Div(usize, usize),
Pow(usize, usize),
Neg(usize),
Abs(usize),
Sqrt(usize),
Exp(usize),
Log(usize),
Log10(usize),
Sin(usize),
Cos(usize),
Tan(usize),
Atan(usize),
Acos(usize),
Sinh(usize),
Cosh(usize),
Tanh(usize),
Asin(usize),
Acosh(usize),
Asinh(usize),
Atanh(usize),
Atan2(usize, usize),
Min(usize, usize),
Max(usize, usize),
Cmp(CmpOp, usize, usize),
And(usize, usize),
Or(usize, usize),
Not(usize),
Select(usize, usize, usize),
Funcall(Box<FuncallData>),
}Expand description
One operation in the flattened tape. Operand fields are tape-slot
indices into the same tape; Var(i) references problem variable
index i (read from the input x slice during forward).
Variants§
Const(f64)
Var(usize)
Add(usize, usize)
Sub(usize, usize)
Mul(usize, usize)
Div(usize, usize)
Pow(usize, usize)
Neg(usize)
Abs(usize)
Sqrt(usize)
Exp(usize)
Log(usize)
Log10(usize)
Sin(usize)
Cos(usize)
Tan(usize)
Atan(usize)
Acos(usize)
Sinh(usize)
Cosh(usize)
Tanh(usize)
Asin(usize)
Acosh(usize)
Asinh(usize)
Atanh(usize)
Atan2(usize, usize)
Two-argument arctangent atan2(vals[a], vals[b]) (operands are
(y, x), matching AMPL’s atan2(y, x) / .nl opcode o48).
Min(usize, usize)
Pairwise minimum min(vals[a], vals[b]). Piecewise linear: the
value/tangent/adjoint route through whichever operand is smaller
(ties pick the first), and the second derivative is identically
zero. n-ary AMPL min (opcode o11) folds to a chain of these.
Max(usize, usize)
Pairwise maximum max(vals[a], vals[b]) — the Min mirror;
n-ary AMPL max (opcode o12) folds to a chain of these.
Cmp(CmpOp, usize, usize)
Relational comparison vals[a] OP vals[b] → 1.0/0.0.
Piecewise constant, so its derivative is identically zero — the
AD passes treat it as a constant w.r.t. its operands.
And(usize, usize)
Logical AND: 1.0 iff both operands are nonzero. Zero derivative.
Or(usize, usize)
Logical OR: 1.0 iff either operand is nonzero. Zero derivative.
Not(usize)
Logical NOT: 1.0 iff the operand is zero. Zero derivative.
Select(usize, usize, usize)
if-then-else: operands (cond, then, else). The value is
vals[then] when vals[cond] != 0 else vals[else], and the
value/tangent/adjoint all route through the active branch only.
The condition contributes no derivative (the branch switch is a
non-smooth event the AD ignores).
Funcall(Box<FuncallData>)
AMPL imported (external) function call. The payload (library
handle, name, and argument list) is boxed so this rare variant
does not inflate size_of::<TapeOp>(): without the box the
Arc+String+Vec make every op ~64 bytes, which on a
summand-split objective with millions of tiny tapes (e.g.
sensors) costs gigabytes. Boxing drops the common arithmetic
ops back to the size of the next-largest variant.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TapeOp
impl RefUnwindSafe for TapeOp
impl Send for TapeOp
impl Sync for TapeOp
impl Unpin for TapeOp
impl UnsafeUnpin for TapeOp
impl UnwindSafe for TapeOp
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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