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);
180 template<
typename Lhs>
264 template<
typename Lhs>
278 template<
typename Real>
285 template<
typename Real>
291 template<
typename Lhs,
typename Rhs>
297 validate.
eval(rhs, vi, *
this);
308 lhs.
cast().value() = rhs.
cast().getValue();
312 template<
typename Lhs,
typename Rhs>
319 template<
typename Lhs>
325 lhs.
cast().value() = rhs;
440 template<
typename Lhs>
447 template<
typename Lhs>
478 void reset(
bool resetAdjoints =
true) {
483 template<
typename Stream = std::ostream>
489 template<
typename Stream = std::ostream>
495 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:90
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
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:82
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:172
void destroyIdentifier(Real &value, Identifier &identifier)
Do nothing.
Definition tagTapeReverse.hpp:286
void clearAdjoints(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:357
bool hasParameter(TapeParameters parameter) const
Do nothing.
Definition tagTapeReverse.hpp:137
void evaluate()
Do nothing.
Definition tagTapeReverse.hpp:472
Gradient & gradient(Identifier const &identifier)
Verify tag.
Definition tagTapeReverse.hpp:225
Real const & primal(Identifier const &identifier) const
Do nothing.
Definition tagTapeReverse.hpp:424
void deleteVectorAccess(VectorAccessInterface< Real, Identifier > *access)
Do nothing.
Definition tagTapeReverse.hpp:161
void printTableRow(Stream &out=std::cout) const
Do nothing.
Definition tagTapeReverse.hpp:496
void deleteData()
Do nothing.
Definition tagTapeReverse.hpp:122
Gradient const & getGradient(Identifier const &identifier) const
Verify tag.
Definition tagTapeReverse.hpp:218
void setPassive()
Set tape to passive.
Definition tagTapeReverse.hpp:458
Identifier getInvalidIndex() const
-1 tag.
Definition tagTapeReverse.hpp:252
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:418
TapeValues getTapeValues() const
Do nothing.
Definition tagTapeReverse.hpp:501
void setParameter(TapeParameters parameter, size_t value)
Do nothing.
Definition tagTapeReverse.hpp:144
void initIdentifier(Real &value, Identifier &identifier)
Do nothing.
Definition tagTapeReverse.hpp:279
VectorAccessInterface< Real, Identifier > * createVectorAccessCustomAdjoints(Adjoint *data)
Do nothing.
Definition tagTapeReverse.hpp:155
bool isActive() const
Check if tape is active.
Definition tagTapeReverse.hpp:463
TagData< Tag > Identifier
See TapeTypesInterface.
Definition tagTapeReverse.hpp:70
void setActive()
Set tape to active.
Definition tagTapeReverse.hpp:453
void setGradient(Identifier const &identifier, Gradient const &gradient)
Verify tag.
Definition tagTapeReverse.hpp:211
Position getPosition() const
Do nothing.
Definition tagTapeReverse.hpp:362
void clearAdjoints()
Do nothing.
Definition tagTapeReverse.hpp:475
Gradient const & gradient(Identifier const &identifier) const
Verify tag.
Definition tagTapeReverse.hpp:232
size_t getParameter(TapeParameters parameter) const
Do nothing.
Definition tagTapeReverse.hpp:130
Identifier getPassiveIndex() const
Zero tag.
Definition tagTapeReverse.hpp:247
static bool constexpr LinearIndexHandling
Behave as linear index handler.
Definition tagTapeReverse.hpp:244
void revertPrimals(Position const &pos)
Do nothing.
Definition tagTapeReverse.hpp:430
void pushExternalFunction(ExternalFunction< TagTapeReverse > const &extFunc)
Do nothing.
Definition tagTapeReverse.hpp:188
void evaluatePrimal()
Do nothing.
Definition tagTapeReverse.hpp:404
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:292
T_Real Real
See TagTapeReverse.
Definition tagTapeReverse.hpp:57
void registerOutput(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Verify tag.
Definition tagTapeReverse.hpp:448
void setPrimal(Identifier const &identifier, Real const &gradient)
Do nothing.
Definition tagTapeReverse.hpp:407
static bool constexpr HasPrimalValues
No primal values.
Definition tagTapeReverse.hpp:395
Real registerExternalFunctionOutput(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Verifies tag properties.
Definition tagTapeReverse.hpp:181
void evaluateForward()
Do nothing.
Definition tagTapeReverse.hpp:203
static bool constexpr AllowJacobianOptimization
Do not allow Jacobian optimization.
Definition tagTapeReverse.hpp:275
void storeManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size)
Set tag on lhs.
Definition tagTapeReverse.hpp:339
void reset(bool resetAdjoints=true)
Do nothing.
Definition tagTapeReverse.hpp:478
Real const & getPrimal(Identifier const &identifier) const
Do nothing.
Definition tagTapeReverse.hpp:412
Position getZeroPosition() const
Do nothing.
Definition tagTapeReverse.hpp:367
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:382
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:352
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:320
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition tagTapeReverse.hpp:73
void deactivateValue(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Set tag to passive.
Definition tagTapeReverse.hpp:265
void evaluateForward(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:198
VectorAccessInterface< Real, Identifier > * createVectorAccess()
Do nothing.
Definition tagTapeReverse.hpp:149
void resetTo(Position const &pos, bool resetAdjoints=true)
Do nothing.
Definition tagTapeReverse.hpp:372
void evaluateForwardKeepState(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:386
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:313
void evaluatePrimal(Position const &start, Position const &end)
Do nothing.
Definition tagTapeReverse.hpp:399
void registerInput(LhsExpressionInterface< Real, Gradient, TagTapeReverse, Lhs > &value)
Verify value properties.
Definition tagTapeReverse.hpp:441
void printStatistics(Stream &out=std::cout) const
Do nothing.
Definition tagTapeReverse.hpp:484
bool isActive(Identifier const &identifier) const
Default check.
Definition tagTapeReverse.hpp:468
bool isIdentifierActive(Identifier const &index) const
Verify tag.
Definition tagTapeReverse.hpp:257
void pushJacobiManual(Real const &jacobian, Real const &value, Identifier const &index)
Do nothing.
Definition tagTapeReverse.hpp:334
Real Gradient
See TapeTypesInterface.
Definition tagTapeReverse.hpp:69
static bool constexpr RequiresPrimalRestore
No primal values.
Definition tagTapeReverse.hpp:396
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:490
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:73
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