Implementation of a tape-free forward AD mode through the internal expression interfaces. More...
#include <forwardEvaluation.hpp>
Public Types | |
using | Gradient = T_Gradient |
See ForwardEvaluation. | |
using | Identifier = Gradient |
Same as the gradient type. Tangent data is stored in the active types. | |
using | PassiveReal = RealTraits::PassiveReal<Real> |
Basic computation type. | |
using | Real = T_Real |
See ForwardEvaluation. | |
Public Types inherited from codi::InternalStatementRecordingTapeInterface< T_Gradient > | |
using | Identifier |
See InternalStatementRecordingTapeInterface. | |
Public Types inherited from codi::GradientAccessTapeInterface< T_Gradient, T_Gradient > | |
using | Gradient |
See GradientAccessTapeInterface. | |
using | Identifier |
See GradientAccessTapeInterface. | |
Public Member Functions | |
template<typename Lhs , typename Rhs > | |
void | store (LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs) |
Has to be called by an AD variable every time it is assigned. | |
template<typename Lhs , typename Rhs > | |
void | store (LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Rhs > const &rhs) |
Has to be called by an AD variable every time it is assigned. | |
template<typename Lhs > | |
void | store (LhsExpressionInterface< Real, Gradient, ForwardEvaluation, Lhs > &lhs, Real const &rhs) |
Has to be called by an AD variable every time it is assigned. | |
Implementation of GradientAccessTapeInterface | |
void | setGradient (Identifier &identifier, Gradient const &gradient, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Set the gradient. | |
Gradient const & | getGradient (Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const |
Set the gradient. | |
Gradient & | gradient (Identifier &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Reference access to gradient. | |
Gradient const & | gradient (Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const |
Constant reference access to gradient. | |
Public Member Functions inherited from codi::InternalStatementRecordingTapeInterface< T_Gradient > | |
void | initIdentifier (Real &value, Identifier &identifier) |
void | destroyIdentifier (Real &value, Identifier &identifier) |
Has to be called for each identifier, before it is deallocated. | |
void | store (Lhs &lhs, Rhs const &rhs) |
Has to be called by an AD variable every time it is assigned. | |
Public Member Functions inherited from codi::GradientAccessTapeInterface< T_Gradient, T_Gradient > | |
void | setGradient (Identifier const &identifier, Gradient const &gradient, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Set the gradient. | |
Gradient const & | getGradient (Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const |
Set the gradient. | |
Gradient & | gradient (Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
Reference access to gradient. | |
Gradient const & | gradient (Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const |
Constant reference access to gradient. | |
Implementation of InternalStatementRecordingTapeInterface | |
static bool constexpr | AllowJacobianOptimization = true |
See InternalStatementRecordingTapeInterface. | |
template<typename Real > | |
void | initIdentifier (Real &value, Identifier &identifier) |
template<typename Real > | |
void | destroyIdentifier (Real &value, Identifier &identifier) |
Has to be called for each identifier, before it is deallocated. | |
Additional Inherited Members | |
Static Public Attributes inherited from codi::InternalStatementRecordingTapeInterface< T_Gradient > | |
static bool constexpr | AllowJacobianOptimization |
If certain operations can be hidden from the tape. | |
Implementation of a tape-free forward AD mode through the internal expression interfaces.
For an explanation of the forward AD mode please see the Section forward AD.
The store method implementation performs a reverse AD sweep on the expression itself. The result is then added to the tangent data of the left hand side type.
The identifier data in the LhsExpressionInterface implementations is used by this class to store the tangent data for each value.
This way, a tape-free foward mode is implemented in a manner that is consistent with CoDiPack's taping interface, even if no tape is actually recorded.
See Tape Interface Design for a general overview of the tape interface design in CoDiPack.
T_Real | The computation type of a tape usually defined by ActiveType::Real. |
T_Gradient | The gradient type of a tape usually defined by ActiveType::Gradient. |
|
inline |
Has to be called for each identifier, before it is deallocated.
|
inline |
Set the gradient.
Automatic adjoints management involves bounds checking and locking. If no adjoint variable with the given identifier exists, a reference to adjoints[0] is returned. See AdjointsManagement for details.
Implementation: Automatic adjoints management has no effect. The forward mode does not maintain internal adjoints.
|
inline |
Reference access to gradient.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
Implementation: Automatic adjoints management has no effect. The forward mode does not maintain internal adjoints.
|
inline |
Constant reference access to gradient.
Automatic adjoints management involves bounds checking and locking. If no adjoint variable with the given identifier exists, a reference to adjoints[0] is returned. See AdjointsManagement for details.
Implementation: Automatic adjoints management has no effect. The forward mode does not maintain internal adjoints.
|
inline |
Has to be called for each identifier, after it is allocated.
|
inline |
Set the gradient.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
Implementation: Automatic adjoints management has no effect. The forward mode does not maintain internal adjoints.
|
inline |
Has to be called by an AD variable every time it is assigned.
Update of the value is performed by the tape. The tape will additionally store information, e.g., for the reversal of the statement.
Lhs | Has to implement LhsExpressionInterface. |
Rhs | Has to implement ExpressionInterface. |
|
inline |
Has to be called by an AD variable every time it is assigned.
Update of the value is performed by the tape. The tape will additionally store information, e.g., for the reversal of the statement.
Lhs | Has to implement LhsExpressionInterface. |
Rhs | Has to implement ExpressionInterface. Optimization for copy statements. |
|
inline |
Has to be called by an AD variable every time it is assigned.
Update of the value is performed by the tape. The tape will additionally store information, e.g., for the reversal of the statement.
Lhs | Has to implement LhsExpressionInterface. |
Rhs | Has to implement ExpressionInterface. Specialization for passive assignments. |