Allows for an arbitrary adjoint evaluation of a recorded tape. More...
#include <customAdjointVectorHelper.hpp>
Public Types | |
using | Base = CustomAdjointVectorInterface<Type> |
Abbreviation for the base class. | |
using | Gradient = T_Gradient |
See CustomAdjointVectorHelper. | |
using | Identifier = typename Type::Identifier |
See LhsExpressionInterface. | |
using | Position = typename Tape::Position |
See PositionalEvaluationTapeInterface. | |
using | Real = typename Type::Real |
See LhsExpressionInterface. | |
using | Tape = typename Type::Tape |
See LhsExpressionInterface. | |
using | Type = T_Type |
< See CustomAdjointVectorHelper. | |
Public Types inherited from codi::CustomAdjointVectorInterface< T_Type > | |
using | Identifier = typename Type::Identifier |
See LhsExpressionInterface. | |
using | Position = typename Tape::Position |
See PositionalEvaluationTapeInterface. | |
using | Real = typename Type::Real |
See LhsExpressionInterface. | |
using | Tape = typename Type::Tape |
See LhsExpressionInterface. | |
using | Type = T_Type |
See CustomAdjointVectorInterface. | |
Public Member Functions | |
CustomAdjointVectorHelper () | |
Constructor. | |
~CustomAdjointVectorHelper () | |
Destructor. | |
Implementation of CustomAdjointVectorInterface interface | |
void | clearAdjoints () |
Set all adjoints to zero. | |
void | deleteAdjointVector () |
Delete the adjoint vector. | |
void | evaluate (Position const &start, Position const &end) |
Perform a full reverse evaluation of the tape. | |
void | evaluateForward (Position const &start, Position const &end) |
Perform a forward evaluation of a part of the tape. It has to hold start <= end. | |
VectorAccessInterface< Real, Identifier > * | getVectorInterface () |
Get a new general interface to the adjoint vector. | |
virtual void | evaluate (Position const &start, Position const &end)=0 |
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end. | |
void | evaluate () |
Perform a full reverse evaluation of the tape. | |
virtual void | evaluateForward (Position const &start, Position const &end)=0 |
Perform a forward evaluation of a part of the tape. It has to hold start <= end. | |
void | evaluateForward () |
Perform a forward evaluation of a part of the tape. It has to hold start <= end. | |
Gradient access methods | |
Gradient const & | getGradient (Identifier const &identifier) const |
Get a constant reference to the gradient. | |
Gradient & | gradientUnchecked (Identifier const &identifier) |
Get a reference to the gradient. Unchecked access. | |
Gradient const & | gradientUnchecked (Identifier const &identifier) const |
Get a constant reference to the gradient. Unchecked access. | |
Gradient & | gradient (Identifier const &identifier) |
Get a reference to the gradient. Checked access. | |
Gradient const & | gradient (Identifier const &identifier) const |
Get a constant reference to the gradient. Checked access. | |
void | setGradient (Identifier &identifier, Gradient const &gradientValue) |
Set the gradient. Checked access. | |
Public Member Functions inherited from codi::CustomAdjointVectorInterface< T_Type > | |
CustomAdjointVectorInterface () | |
Constructor. | |
virtual | ~CustomAdjointVectorInterface () |
Destructor. | |
void | evaluate () |
Perform a full reverse evaluation of the tape. | |
void | evaluateForward () |
Perform a forward evaluation of a part of the tape. It has to hold start <= end. | |
void | setTape (Tape &tape) |
Set the tape for the evaluations. | |
Protected Attributes | |
AdjointVectorAccess< Real, Identifier, Gradient > * | adjointInterface |
Last created adjoint interface. | |
std::vector< Gradient > | adjointVector |
Custom adjoint vector. | |
Gradient const | constZeroValue |
Temporary constant zero value. | |
Gradient | zeroValue |
Temporary zero value. | |
Protected Attributes inherited from codi::CustomAdjointVectorInterface< T_Type > | |
Tape & | tape |
Current tape for evaluations. Default: the Type's current tape. | |
Allows for an arbitrary adjoint evaluation of a recorded tape.
The evaluation of a reverse AD tape is independent of the recording of the tape. For example, the reverse evaluation can be performed simultaneously on differtent adjoint vectors or with a vector mode that is not the same as the vector mode implied by the CoDiPack type.
An example for a different vector mode and the general usage is:
The major difference in using the vector helper is that you cannot interact with the adjoints directly, e.g. via the codi::LhsExpressionInterface::getGradient or codi::LhsExpressionInterface::setGradient functions. Instead, you extract the identifier from the AD variable via the codi::LhsExpressionInterface::getIdentifier() functions. The identifier is then used to access the adjoint values via the vector helper, e.g. for seeding or extraction.
For details on custom vector evaluations see CustomAdjointVectorEvaluationTapeInterface.
T_Type | The underlying CoDiPack type. |
T_Gradient | Type of the entries of the custom adjoint vector. |
|
inlinevirtual |
Set all adjoints to zero.
Implements codi::CustomAdjointVectorInterface< T_Type >.
|
inlinevirtual |
Delete the adjoint vector.
Implements codi::CustomAdjointVectorInterface< T_Type >.
|
inline |
Perform a full reverse evaluation of the tape.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
|
inlinevirtual |
Perform a full reverse evaluation of the tape.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
Implements codi::CustomAdjointVectorInterface< T_Type >.
|
virtual |
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
Implements codi::CustomAdjointVectorInterface< T_Type >.
|
inline |
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
|
inlinevirtual |
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
Implements codi::CustomAdjointVectorInterface< T_Type >.
|
virtual |
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Automatic adjoints management involves bounds checking, resizing, and locking, see AdjointsManagement for details.
Implements codi::CustomAdjointVectorInterface< T_Type >.
|
inlinevirtual |
Get a new general interface to the adjoint vector.
Implements codi::CustomAdjointVectorInterface< T_Type >.