37#include "../interfaces/fullTapeInterface.hpp"
38#include "../misc/adjointVectorAccess.hpp"
39#include "tagTapeBase.hpp"
54 template<
typename T_Real,
typename T_Tag>
56 public TagTapeBase<T_Real, T_Tag, T_Real, TagTapeReverse<T_Real, T_Tag>> {
83 std::set<TapeParameters> parameters;
95 template<
typename Adjo
int>
101 template<
typename Adjo
int>
154 template<
typename Adjo
int>
167 std::swap(active, other.active);
168 std::swap(parameters, other.parameters);
184 template<
typename Lhs>
278 template<
typename Lhs>
292 template<
typename Real>
299 template<
typename Real>
305 template<
typename Lhs,
typename Rhs>
311 validate.
eval(rhs, vi, *
this);
322 lhs.
cast().value() = rhs.
cast().getValue();
326 template<
typename Lhs,
typename Rhs>
333 template<
typename Lhs>
339 lhs.
cast().value() = rhs;
454 template<
typename Lhs>
461 template<
typename Lhs>
492 void reset(
bool resetAdjoints =
true) {
497 template<
typename Stream = std::ostream>
503 template<
typename Stream = std::ostream>
509 template<
typename Stream = std::ostream>
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
uint8_t ArgumentSize
Type for the number of arguments in statements.
Definition config.h:117
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
CoDiPack - Code Differentiation Package.
Definition codi.hpp:91
void CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:46
TapeParameters
Configuration options for a tape.
Definition tapeParameters.hpp:52
AdjointsManagement
Policies for management of the tape's interal adjoints.
Definition tapeParameters.hpp:98
@ Automatic
Manage internal adjoints automatically, including locking, bounds checking, and resizing.
Empty Position with no nested data.
Definition position.hpp:47
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:59
Impl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:75
User-defined evaluation functions for the taping process.
Definition externalFunction.hpp:102
Full tape interface that supports all features of CoDiPack.
Definition fullTapeInterface.hpp:84
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
Identifier const & getIdentifier() const
Impl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:99
EnumBitset< TagFlags > properties
Current properties of the value.
Definition tagData.hpp:62
Tag tag
Current tag of the value.
Definition tagData.hpp:61
Base implementation for tagging tapes.
Definition tagTapeBase.hpp:73
void verifyRegisterValue(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, const Identifier &tag)
Verify tag, properties and lhs error.
Definition tagTapeBase.hpp:319
void resetTag(Tag &tag) const
Reset tag on value.
Definition tagTapeBase.hpp:336
void handleError(ValidationIndicator< Real, Tag > &vi) const
Call tag error callback.
Definition tagTapeBase.hpp:306
void setTag(Tag &tag) const
Set tag on value.
Definition tagTapeBase.hpp:331
static Tag constexpr PassiveTag
Tag indicating an inactive value.
Definition tagTapeBase.hpp:88
void verifyTag(ValidationIndicator< Real, Tag > &vi, Tag const &tag) const
Checks if the tag is correct. Errors are set on the ValidationIndicator object.
Definition tagTapeBase.hpp:226
void verifyTagAndProperties(Tag const &tag, Real const &value, const EnumBitset< TagFlags > &properties) const
Checks if the tag and the properties are correct.
Definition tagTapeBase.hpp:256
static Tag constexpr InvalidTag
Tag indicating an invalid value.
Definition tagTapeBase.hpp:89
void checkLhsError(Real &lhsValue, Identifier &lhsIdentifier, const Real &rhs) const
Check if a property for the lhs value is triggered.
Definition tagTapeBase.hpp:289
void swap(Impl &other)
Swap members.
Definition tagTapeBase.hpp:130
Required definition for event system.
Definition tagTapeReverse.hpp:63
int Index
Required definition for event system.
Definition tagTapeReverse.hpp:65
Required definition for event system.
Definition tagTapeReverse.hpp:61
Tape for tagging variables and find errors in the AD workflow.
Definition tagTapeReverse.hpp:56
TagTapeReverse()
Constructor.
Definition tagTapeReverse.hpp:88
void resetHard()
Do nothing.
Definition tagTapeReverse.hpp:171
void deleteAdjointVector()
Do nothing.
Definition tagTapeReverse.hpp:173
void destroyIdentifier(Real &value, Identifier &identifier)
Do nothing.
Definition tagTapeReverse.hpp:300
void clearAdjoints(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:371
bool hasParameter(TapeParameters parameter) const
Do nothing.
Definition tagTapeReverse.hpp:137
void evaluate()
Do nothing.
Definition tagTapeReverse.hpp:486
Real const & primal(Identifier const &identifier) const
Do nothing.
Definition tagTapeReverse.hpp:438
void deleteVectorAccess(VectorAccessInterface< Real, Identifier > *access)
Do nothing.
Definition tagTapeReverse.hpp:161
void printTableRow(Stream &out=std::cout) const
Do nothing.
Definition tagTapeReverse.hpp:510
void resizeAdjointVector()
Do nothing.
Definition tagTapeReverse.hpp:174
void deleteData()
Do nothing.
Definition tagTapeReverse.hpp:122
void setPassive()
Set tape to passive.
Definition tagTapeReverse.hpp:472
Identifier getInvalidIndex() const
-1 tag.
Definition tagTapeReverse.hpp:266
void evaluateForward(Position const &start, Position const &end, Adjoint *data)
Do nothing.
Definition tagTapeReverse.hpp:102
Real & primal(Identifier const &identifier)
Do nothing.
Definition tagTapeReverse.hpp:432
TapeValues getTapeValues() const
Do nothing.
Definition tagTapeReverse.hpp:515
void setParameter(TapeParameters parameter, size_t value)
Do nothing.
Definition tagTapeReverse.hpp:144
Gradient const & getGradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Verify tag.
Definition tagTapeReverse.hpp:223
void initIdentifier(Real &value, Identifier &identifier)
Do nothing.
Definition tagTapeReverse.hpp:293
VectorAccessInterface< Real, Identifier > * createVectorAccessCustomAdjoints(Adjoint *data)
Do nothing.
Definition tagTapeReverse.hpp:155
bool isActive() const
Check if tape is active.
Definition tagTapeReverse.hpp:477
Gradient & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Verify tag.
Definition tagTapeReverse.hpp:233
TagData< Tag > Identifier
See TapeTypesInterface.
Definition tagTapeReverse.hpp:70
void setActive()
Set tape to active.
Definition tagTapeReverse.hpp:467
void endUseAdjointVector()
Do nothing.
Definition tagTapeReverse.hpp:176
Position getPosition() const
Do nothing.
Definition tagTapeReverse.hpp:376
void clearAdjoints()
Do nothing.
Definition tagTapeReverse.hpp:489
size_t getParameter(TapeParameters parameter) const
Do nothing.
Definition tagTapeReverse.hpp:130
Identifier getPassiveIndex() const
Zero tag.
Definition tagTapeReverse.hpp:261
static bool constexpr LinearIndexHandling
Behave as linear index handler.
Definition tagTapeReverse.hpp:258
void revertPrimals(Position const &pos)
Do nothing.
Definition tagTapeReverse.hpp:444
void pushExternalFunction(ExternalFunction< TagTapeReverse > const &extFunc)
Do nothing.
Definition tagTapeReverse.hpp:192
void evaluatePrimal()
Do nothing.
Definition tagTapeReverse.hpp:418
void store(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs)
Verify all tags of the rhs and the lhs properties.
Definition tagTapeReverse.hpp:306
T_Real Real
See TagTapeReverse.
Definition tagTapeReverse.hpp:57
void registerOutput(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Verify tag.
Definition tagTapeReverse.hpp:462
void setPrimal(Identifier const &identifier, Real const &gradient)
Do nothing.
Definition tagTapeReverse.hpp:421
static bool constexpr HasPrimalValues
No primal values.
Definition tagTapeReverse.hpp:409
Real registerExternalFunctionOutput(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Verifies tag properties.
Definition tagTapeReverse.hpp:185
void evaluateForward()
Do nothing.
Definition tagTapeReverse.hpp:207
static bool constexpr AllowJacobianOptimization
Do not allow Jacobian optimization.
Definition tagTapeReverse.hpp:289
void storeManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size)
Set tag on lhs.
Definition tagTapeReverse.hpp:353
void reset(bool resetAdjoints=true)
Do nothing.
Definition tagTapeReverse.hpp:492
Real const & getPrimal(Identifier const &identifier) const
Do nothing.
Definition tagTapeReverse.hpp:426
Position getZeroPosition() const
Do nothing.
Definition tagTapeReverse.hpp:381
void beginUseAdjointVector()
Do nothing.
Definition tagTapeReverse.hpp:175
void swap(TagTapeReverse &other)
Swap members.
Definition tagTapeReverse.hpp:166
std::set< TapeParameters > const & getAvailableParameters() const
Empty set.
Definition tagTapeReverse.hpp:125
void evaluateKeepState(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:396
Gradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Verify tag.
Definition tagTapeReverse.hpp:243
void evaluate(Position const &start, Position const &end, Adjoint *data)
Do nothing.
Definition tagTapeReverse.hpp:96
void writeToFile(std::string const &filename) const
Do nothing.
Definition tagTapeReverse.hpp:112
void evaluate(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:366
T_Tag Tag
See TagTapeReverse.
Definition tagTapeReverse.hpp:58
void store(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &lhs, PassiveReal const &rhs)
Verify the lhs properties.
Definition tagTapeReverse.hpp:334
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition tagTapeReverse.hpp:73
void setGradient(Identifier const &identifier, Gradient const &gradient, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Verify tag.
Definition tagTapeReverse.hpp:215
void deactivateValue(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Set tag to passive.
Definition tagTapeReverse.hpp:279
void evaluateForward(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:202
VectorAccessInterface< Real, Identifier > * createVectorAccess()
Do nothing.
Definition tagTapeReverse.hpp:149
void resetTo(Position const &pos, bool resetAdjoints=true)
Do nothing.
Definition tagTapeReverse.hpp:386
void evaluateForwardKeepState(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:400
void store(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, TagTapeReverse, Rhs > const &rhs)
Verify all tags of the rhs and the lhs properties.
Definition tagTapeReverse.hpp:327
void evaluatePrimal(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:413
void registerInput(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Verify value properties.
Definition tagTapeReverse.hpp:455
void printStatistics(Stream &out=std::cout) const
Do nothing.
Definition tagTapeReverse.hpp:498
bool isActive(Identifier const &identifier) const
Default check.
Definition tagTapeReverse.hpp:482
bool isIdentifierActive(Identifier const &index) const
Verify tag.
Definition tagTapeReverse.hpp:271
void pushJacobiManual(Real const &jacobian, Real const &value, Identifier const &index)
Do nothing.
Definition tagTapeReverse.hpp:348
Real Gradient
See TapeTypesInterface.
Definition tagTapeReverse.hpp:69
static bool constexpr RequiresPrimalRestore
No primal values.
Definition tagTapeReverse.hpp:410
EmptyPosition Position
See TapeTypesInterface.
Definition tagTapeReverse.hpp:71
void readFromFile(std::string const &filename)
Do nothing.
Definition tagTapeReverse.hpp:117
void printTableHeader(Stream &out=std::cout) const
Do nothing.
Definition tagTapeReverse.hpp:504
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:75
void eval(NodeInterface< Node > const &node, Args &&... args)
Start the evaluation of the logic on the given expression.
Definition traversalLogic.hpp:70
Helper class for statement validation.
Definition tagTapeBase.hpp:49
bool isActive
true if an active rhs is detected. tag != 0
Definition tagTapeBase.hpp:50
Unified access to the adjoint vector and primal vector in a tape evaluation.
Definition vectorAccessInterface.hpp:91