Minimum tape interface for a working reverse tape implementation. More...
#include <reverseTapeInterface.hpp>

Public Types | |
| using | Gradient = T_Gradient |
| See ReverseTapeInterface. | |
| using | Identifier = T_Identifier |
| See ReverseTapeInterface. | |
| using | PassiveReal = RealTraits::PassiveReal<Real> |
| Basic computation type. | |
| using | Real = T_Real |
| See ReverseTapeInterface. | |
Public Types inherited from codi::InternalStatementRecordingTapeInterface< T_Identifier > | |
| using | Identifier = T_Identifier |
| See InternalStatementRecordingTapeInterface. | |
Public Types inherited from codi::GradientAccessTapeInterface< T_Gradient, T_Identifier > | |
| using | Gradient = T_Gradient |
| See GradientAccessTapeInterface. | |
| using | Identifier = T_Identifier |
| See GradientAccessTapeInterface. | |
Public Member Functions | |
Recording | |
| template<typename Lhs, typename Tape> | |
| void | registerInput (LhsExpressionInterface< Real, Gradient, Tape, Lhs > &value) |
| template<typename Lhs, typename Tape> | |
| void | registerOutput (LhsExpressionInterface< Real, Gradient, Tape, Lhs > &value) |
| void | setActive () |
| Start/continue recording of statements. | |
| void | setPassive () |
| Stop/interrupt recording of statements. | |
| bool | isActive () const |
| Check if the tape is recording. | |
Reversal | |
| void | evaluate (AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
| Perform a full reverse evaluation of the tape. | |
Reset | |
| void | clearAdjoints (AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
| Clear all adjoint values, that is, set them to zero. | |
| void | reset (bool resetAdjoints=true, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) |
| Reset the tape to the initial state for a fresh recording. | |
Tape information | |
| template<typename Stream = std::ostream> | |
| void | printStatistics (Stream &out=std::cout) const |
| Default formatting of TapeValues. | |
| template<typename Stream = std::ostream> | |
| void | printTableHeader (Stream &out=std::cout) const |
| Table header output of TapeValues. | |
| template<typename Stream = std::ostream> | |
| void | printTableRow (Stream &out=std::cout) const |
| Table row output of TapeValues. | |
| TapeValues | getTapeValues () const |
| Get current tape values. | |
| 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. | |
| template<typename Lhs, typename Rhs> | |
| 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_Identifier > | |
| 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. | |
Additional Inherited Members | |
| static bool constexpr | AllowJacobianOptimization |
| If certain operations can be hidden from the tape. | |
Minimum tape interface for a working reverse tape implementation.
See Tape Interface Design for a general overview of the tape interface design in CoDiPack.
For an example on how to uses this interface to perform an AD reverse mode recording and evaluation of a program, please see tutorials Tutorial 2 - Reverse mode AD and Tutorial 5 - Repeated tape recordings).
Implementation hints: A tape should only record information if it is active, that is, everything between a call to setActive() and setPassive(). A call to setActive() does not reset the tape in CoDiPack. A reset can only be performed by a call to reset(). Hence, the user may skip unnecessarys parts of the recording by setting the tape passive for these regions.
Here is an example for using a tape (documentation/examples/reverseModeAD.cpp):
| T_Real | The computation type of a tape, usually chosen as ActiveType::Real. |
| T_Gradient | The gradient type of a tape, usually chosen as ActiveType::Gradient. |
| T_Identifier | The adjoint/tangent identification of a tape, usually chosen as ActiveType::Identifier. |
| void codi::ReverseTapeInterface< T_Real, T_Gradient, T_Identifier >::clearAdjoints | ( | AdjointsManagement | adjointsManagement = AdjointsManagement::Automatic | ) |
Clear all adjoint values, that is, set them to zero.
Automatic adjoints management involves locking, see AdjointsManagement for details.
| void codi::ReverseTapeInterface< T_Real, T_Gradient, T_Identifier >::evaluate | ( | AdjointsManagement | adjointsManagement = AdjointsManagement::Automatic | ) |
Perform a full reverse evaluation of the tape.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
| void codi::ReverseTapeInterface< T_Real, T_Gradient, T_Identifier >::registerInput | ( | LhsExpressionInterface< Real, Gradient, Tape, Lhs > & | value | ) |
Mark a value as input (independent) and make it active.
| Lhs | Class that implements the LhsExpressionInterface. See also LhsExpressionInterface. |
| Tape | Tape implementation used in the LhsExpressionInterface. See also LhsExpressionInterface. |
| void codi::ReverseTapeInterface< T_Real, T_Gradient, T_Identifier >::registerOutput | ( | LhsExpressionInterface< Real, Gradient, Tape, Lhs > & | value | ) |
Mark a value as output (dependent).
| Lhs | Class that implements the LhsExpressionInterface. See also LhsExpressionInterface. |
| Tape | Tape implementation used in the LhsExpressionInterface. See also LhsExpressionInterface. |
| void codi::ReverseTapeInterface< T_Real, T_Gradient, T_Identifier >::reset | ( | bool | resetAdjoints = true, |
| AdjointsManagement | adjointsManagement = AdjointsManagement::Automatic ) |
Reset the tape to the initial state for a fresh recording.
See Tutorial 5 - Repeated tape recordings for remarks on repeated tape recording in CoDiPack.
Automatic adjoints management involves locking, see AdjointsManagement for details.