AutoDiff
Variables
ExaPF.AutoDiff.AbstractStack
— TypeAbstractStack{VT}
Abstract variable storing the inputs and the intermediate values in the expression tree.
Expressions
ExaPF.AutoDiff.AbstractExpression
— TypeAbstractExpression
Abstract type for differentiable function $f(x)$. Any AbstractExpression
implements two functions: a forward mode to evaluate $f(x)$, and an adjoint to evaluate $∂f(x)$.
Forward mode
The direct evaluation of the function $f$ is implemented as
(expr::AbstractExpression)(output::VT, stack::AbstractStack{VT}) where VT<:AbstractArray
the input being specified in stack
, the results being stored in the array output
.
Reverse mode
The adjoint of the function is specified by the function adjoint!
, with the signature:
adjoint!(expr::AbstractExpression, ∂stack::AbstractStack{VT}, stack::AbstractStack{VT}, ̄v::VT) where VT<:AbstractArray
The variable stack
stores the result of the direct evaluation, and is not modified in adjoint!
. The results are stored inside the adjoint stack ∂stack
.
ExaPF.AutoDiff.adjoint!
— Functionadjoint!(expr::AbstractExpression, ∂stack::AbstractStack{VT}, stack::AbstractStack{VT}, ̄v::VT) where VT<:AbstractArray
Compute the adjoint of the AbstractExpression
expr
with relation to the adjoint vector ̄v
. The results are stored in the adjoint stack ∂stack
. The variable stack
stores the result of a previous direct evaluation, and is not modified in adjoint!
.
First and second-order derivatives
ExaPF.AutoDiff.AbstractJacobian
— TypeAbstractJacobian
Automatic differentiation for the compressed Jacobian of any nonlinear constraint $h(x)$.
ExaPF.AutoDiff.AbstractHessianProd
— TypeAbstractHessianProd
Returns the adjoint-Hessian-vector product $λ^⊤ H v$ of any nonlinear constraint $h(x)$.
ExaPF.AutoDiff.AbstractFullHessian
— TypeAbstractHessianProd
Full sparse Hessian $H$ of any nonlinear constraint $h(x)$.
Utils
ExaPF.AutoDiff.seed!
— Functionseed!(
H::AbstractHessianProd,
v::AbstractVector{T},
) where {T}
Seed the duals with v to compute the Hessian vector product $λ^⊤ H v$.
ExaPF.AutoDiff.seed_coloring!
— Functionseed_coloring!(
M::Union{AbstractJacobian, AbstractFullHessian}
coloring::AbstractVector,
)
Seed the duals with the coloring
based seeds to compute the Jacobian or Hessian $M$.
ExaPF.AutoDiff.partials!
— Functionpartials!(jac::AbstractJacobian)
Extract partials from Jacobian jac
in jac.J
.
partials!(hess::AbstractFullHessian)
Extract partials from Hessian hess
into hess.H
.
ExaPF.AutoDiff.set_value!
— Functionset_value!(
jac,
primals::AbstractVector{T}
) where {T}
Set values of ForwardDiff.Dual
numbers in jac
to primals
.