43#include "../expressions/lhsExpressionInterface.hpp"
44#include "../expressions/logic/compileTimeTraversalLogic.hpp"
45#include "../expressions/logic/helpers/forEachLeafLogic.hpp"
46#include "../expressions/logic/helpers/jacobianComputationLogic.hpp"
47#include "../expressions/logic/traversalLogic.hpp"
48#include "../expressions/referenceActiveType.hpp"
50#include "../misc/mathUtility.hpp"
51#include "../misc/memberStore.hpp"
52#include "../traits/adjointVectorTraits.hpp"
53#include "../traits/computationTraits.hpp"
54#include "../traits/expressionTraits.hpp"
55#include "commonTapeImplementation.hpp"
56#include "data/chunk.hpp"
57#include "data/chunkedData.hpp"
58#include "indices/indexManagerInterface.hpp"
59#include "io/tapeReaderWriterInterface.hpp"
60#include "misc/adjointVectorAccess.hpp"
61#include "misc/duplicateJacobianRemover.hpp"
62#include "misc/localAdjoints.hpp"
76 template<
typename T_Real,
typename T_Gradient,
typename T_IndexManager,
template<
typename,
typename>
class T_Data,
77 template<
typename,
typename,
typename>
class T_Adjoints = LocalAdjoints>
84 template<
typename Chunk,
typename Nested>
91 template<
typename Impl>
97 IndexManager::NeedsStaticStorage;
101 using StatementChunk =
typename std::conditional<IsLinearIndexHandler, Chunk1<Config::ArgumentSize>,
127 template<
typename T_TapeTypes,
typename T_Impl>
139 using Real =
typename TapeTypes::Real;
155 template<
typename Adjo
intVector>
162 TapeTypes::IsLinearIndexHandler;
167#if CODI_RemoveDuplicateJacobianArguments
181 return static_cast<Impl const&
>(*this);
185 return static_cast<Impl&
>(*this);
195 template<
typename... Args>
199 template<
typename... Args>
217 jacobianData(std::max(Config::ChunkSize, Config::MaxArgumentSize)),
242 checkAdjointSize(identifier);
268 template<
typename Real>
272 identifier = IndexManager::InactiveIndex;
276 template<
typename Real>
291 template<
typename Node,
typename Jacobian,
typename DataVector>
293 Real jacobian = ComputationTraits::adjointConversion<Real>(jacobianExpr);
298 dataVector.pushData(jacobian,
node.getIdentifier());
305 template<
typename Type,
typename Jacobian,
typename DataVector>
307 DataVector& dataVector) {
310 Real jacobian = ComputationTraits::adjointConversion<Real>(jacobianExpr);
314 node.jacobian += jacobian;
324 template<
typename Type,
typename DataVector>
328 dataVector.pushData(
node.jacobian,
node.getIdentifier());
340 template<
typename Rhs>
345#if CODI_RemoveDuplicateJacobianArguments
346 auto& insertVector = jacobianSorter;
351 pushJacobianLogic.
eval(rhs.
cast(),
Real(1.0), insertVector);
352 pushDelayedJacobianLogic.
eval(rhs.
cast(), insertVector);
354#if CODI_RemoveDuplicateJacobianArguments
364 template<
typename Lhs,
typename Rhs>
373 typename JacobianData::InternalPosHandle jacobianStart =
jacobianData.reserveItems(MaxArgs);
377 size_t numberOfArguments =
jacobianData.getPushedDataCount(jacobianStart);
385 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
386 jacobians -= numberOfArguments;
387 rhsIdentifiers -= numberOfArguments;
390 rhs.
cast().getValue(), numberOfArguments,
391 rhsIdentifiers, jacobians);
400 lhs.
cast().value() = rhs.
cast().getValue();
405 template<
typename Lhs,
typename Rhs>
419 lhs.
cast().value() = rhs.
cast().getValue();
424 template<
typename Lhs>
428 lhs.
cast().value() = rhs;
439 template<
typename Lhs>
442 if (TapeTypes::IsLinearIndexHandler) {
452 if (TapeTypes::IsLinearIndexHandler) {
464 template<
typename Lhs>
466 cast().internalRegisterInput(value,
true);
490 if (TapeTypes::IsLinearIndexHandler) {
491 name =
"CoDi Tape Statistics ( JacobianLinearTape )";
493 name =
"CoDi Tape Statistics ( JacobianReuseTape )";
498 double memoryAdjoints =
static_cast<double>(nAdjoints) *
static_cast<double>(
sizeof(
Gradient));
501 TapeValues::LocalReductionOperation
constexpr operation =
502 globalAdjoints ? TapeValues::LocalReductionOperation::Max : TapeValues::LocalReductionOperation::Sum;
506 values.
addDoubleEntry(
"Memory allocated", memoryAdjoints, operation,
true,
true);
526 template<
typename Adjo
intVector>
530 Real const*
const rhsJacobians,
532 size_t endJacobianPos = curJacobianPos - numberOfArguments;
535 while (endJacobianPos < curJacobianPos)
CODI_Likely {
537 adjointVector[rhsIdentifiers[curJacobianPos]] += rhsJacobians[curJacobianPos] * lhsAdjoint;
540 curJacobianPos = endJacobianPos;
549 template<
typename Adjo
intVector>
553 Real const*
const rhsJacobians,
555 size_t endJacobianPos = curJacobianPos + numberOfArguments;
557 while (curJacobianPos < endJacobianPos)
CODI_Likely {
558 lhsAdjoint += rhsJacobians[curJacobianPos] * adjointVector[rhsIdentifiers[curJacobianPos]];
575 template<
typename Adjo
intVector>
580 cast(), start, end, &adjointWrapper, EventHints::EvaluationKind::Reverse, EventHints::Endpoint::Begin);
583 Base::llfByteData.evaluateReverse(start, end, evalFunc, cast(), std::forward<AdjointVector>(data));
586 EventHints::EvaluationKind::Reverse, EventHints::Endpoint::End);
590 template<
typename Adjo
intVector>
595 cast(), start, end, &adjointWrapper, EventHints::EvaluationKind::Forward, EventHints::Endpoint::Begin);
598 Base::llfByteData.evaluateForward(start, end, evalFunc, cast(), std::forward<AdjointVector>(data));
601 EventHints::EvaluationKind::Forward, EventHints::Endpoint::End);
674 CODI_EXCEPTION(
"Tried to set a get only parameter.");
691 template<
typename Adjo
intVector>
698 template<
typename Adjo
int>
714 template<
typename Lhs>
716 cast().internalRegisterInput(value,
false);
738 cast().evaluateForward(start, end,
adjoints.data());
754 cast().incrementManualPushCounter();
763 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
769 rhsIdentifiers, jacobians);
787 impl.initializeManualPushData(lhsValue, lhsIndex, size);
810 impl.initializeManualPushData(lhsValue, lhsIndex, size);
812 for (
size_t rhsCount = 0; rhsCount < size; rhsCount++) {
813 cast().incrementManualPushCounter();
814 jacobianData.pushData(jacobians[rhsCount], rhsIdentifiers[rhsCount]);
823 template<
typename Type>
828 Base::llfByteData.evaluateForward(start, end, Impl::template internalWriteTape<Type>, writer);
890 evaluate(start, end, adjointsManagement);
894 template<
typename Adjo
intVector>
896 evaluate(start, end, std::forward<AdjointVector>(data));
906 template<
typename Adjo
intVector>
922 CODI_EXCEPTION(
"Accessing primal evaluation of an Jacobian tape.");
929 CODI_EXCEPTION(
"Accessing primal vector of an Jacobian tape.");
939 CODI_EXCEPTION(
"Accessing primal vector of an Jacobian tape.");
949 CODI_INLINE void checkAdjointSize(Identifier
const& identifier) {
950 if (identifier >= (Identifier)
adjoints.size()) {
951 internalResizeAdjointsVector();
#define CODI_Unlikely
Declare unlikely evaluation of an execution path.
Definition config.h:399
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:417
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:457
#define CODI_Likely
Declare likely evaluation of an execution path.
Definition config.h:397
#define CODI_RemoveDuplicateJacobianArguments
See codi::Config::RemoveDuplicateJacobianArguments.
Definition config.h:229
#define codiAssert(x)
See codi::Config::EnableAssert.
Definition config.h:432
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_ENABLE_CHECK(option, condition)
Definition macros.hpp:53
#define CODI_WRAP_FUNCTION_TEMPLATE(NAME, FUNC)
Wrap a function in a function object. Used for performance optimizations.
Definition macros.hpp:167
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
typename GradientImplementation< AdjointVector >::Gradient Gradient
Deduce the entry type from an adjoint vector type, usually identical to the gradient type of a tape.
Definition adjointVectorTraits.hpp:92
uint16_t LowLevelFunctionToken
Token type for low level functions in the tapes.
Definition config.h:108
const bool CheckEmptyStatements
Tapes push statements only if at least one Jacobian was pushed.
Definition config.h:154
size_t constexpr ChunkSize
Default size of chunks (ChunkBase) used in ChunkedData in reverse tape implementations.
Definition config.h:94
bool constexpr CheckZeroIndex
Ignore active types that are not dependent on any input value in Jacobian tapes.
Definition config.h:178
bool constexpr IgnoreInvalidJacobians
Ignore invalid Jacobians like NaN or Inf.
Definition config.h:240
bool constexpr CheckTapeActivity
Makes it possible to ignore certain code parts. If turned of everything will be recorded.
Definition config.h:170
size_t constexpr StatementLowLevelFunctionTag
Statement tag for low level functions.
Definition config.h:126
bool constexpr CheckJacobianIsZero
Ignore Jacobians that are zero in Jacobian based tapes.
Definition config.h:162
size_t constexpr MaxArgumentSize
Maximum number of arguments in a statement.
Definition config.h:120
bool constexpr StatementEvents
Enable statement events. Disabled by default.
Definition config.h:319
bool constexpr CopyOptimization
Do not store copy statements like a = b; if the identity handler allows it.
Definition config.h:186
uint8_t ArgumentSize
Type for the number of arguments in statements.
Definition config.h:117
size_t constexpr StatementInputTag
Tag for statements that are inputs. Used in linear index management context.
Definition config.h:123
bool constexpr SkipZeroAdjointEvaluation
Do not perform a reverse evaluation of a statement if the seeding adjoint is zero.
Definition config.h:256
bool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:133
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type, that was used in the application.
Definition realTraits.hpp:117
bool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:139
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
IntegralType getNextMultiple(IntegralType const &targetSize, IntegralType const &chunkSize)
Helper function for overallocation in multiples of a given chunk size.
Definition mathUtility.hpp:49
TapeParameters
Configuration options for a tape.
Definition tapeParameters.hpp:52
@ LargestIdentifier
[A: R] Largest identifier distributed by the index manger.
@ JacobianSize
[A: RW] Allocated number of entries in the argument Jacobian vector in Jacobian tapes.
@ StatementSize
[A: RW] Allocated number of entries in the statement vector in all tapes.
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.
Implementation of VectorAccessInterface for adjoint vectors.
Definition adjointVectorAccess.hpp:61
Definition byteDataView.hpp:51
Data is stored chunk-wise in this DataInterface implementation. If a chunk runs out of space,...
Definition chunkedData.hpp:64
Implementation of all common tape functionality.
Definition commonTapeImplementation.hpp:131
Real manualPushLhsValue
For storeManual, remember the value assigned to the lhs.
Definition commonTapeImplementation.hpp:158
void setParameter(TapeParameters parameter, size_t value)
See Parameters functions.
Definition commonTapeImplementation.hpp:459
void evaluateForward(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Definition commonTapeImplementation.hpp:592
size_t manualPushCounter
Count the pushes after storeManual, to identify the last push.
Definition commonTapeImplementation.hpp:161
Identifier manualPushLhsIdentifier
For storeManual, remember the identifier assigned to the lhs.
Definition commonTapeImplementation.hpp:159
bool isActive() const
Check if the tape is recording.
Definition commonTapeImplementation.hpp:320
size_t manualPushGoal
Store the number of expected pushes after a storeManual call.
Definition commonTapeImplementation.hpp:160
void init(typename ImplTapeTypes::NestedData *nested)
Initialize the base class.
Definition commonTapeImplementation.hpp:751
std::set< TapeParameters > options
All options.
Definition commonTapeImplementation.hpp:153
void writeTape(std::unique_ptr< TapeWriterInterface< Type > > writer)
For full-tape writers using a smart pointer.
Definition commonTapeImplementation.hpp:605
void evaluate(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a full reverse evaluation of the tape.
Definition commonTapeImplementation.hpp:293
void swap(Impl &other)
Swap all data with an other tape.
Definition commonTapeImplementation.hpp:368
typename CommonTapeTypes< ImplTapeTypes >::Position Position
See TapeTypesInterface.
Definition commonTapeImplementation.hpp:145
LowLevelFunctionByteData llfByteData
Byte data for low level functions.
Definition commonTapeImplementation.hpp:156
size_t getParameter(TapeParameters parameter) const
See Parameters functions.
Definition commonTapeImplementation.hpp:431
void evaluatePrimal()
Perform a full (forward) reevaluation of the primals in the tape.
Definition commonTapeImplementation.hpp:726
void internalStoreLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &dataView)
Called by the implementing tapes to store a low level function. The size is reserved and allocated....
Definition commonTapeImplementation.hpp:494
Data stream interface for tape data. Encapsulates data that is written e.g. for each statement or arg...
Definition dataInterface.hpp:149
Combines entries of Jacobians with the same identifier.
Definition duplicateJacobianRemover.hpp:58
void storeData(Vec &vec)
Definition duplicateJacobianRemover.hpp:98
static void notifyStatementStoreOnTapeListeners(Tape &tape, Identifier const &lhsIdentifier, Real const &newValue, size_t numActiveVariables, Identifier const *rhsIdentifiers, Real const *jacobians)
Invoke callbacks for StatementStoreOnTape events.
Definition eventSystem.hpp:676
static void notifyTapeEvaluateListeners(Tape &tape, Position const &start, Position const &end, VectorAccess *adjoint, EventHints::EvaluationKind evalKind, EventHints::Endpoint endpoint)
Invoke callbacks for TapeEvaluate events.
Definition eventSystem.hpp:486
static void notifyTapeRegisterInputListeners(Tape &tape, Real &value, Identifier &identifier)
Invoke callbacks for TapeRegisterInput events.
Definition eventSystem.hpp:424
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:59
Impl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:75
Counts the number of nodes that inherit from LhsExpressionInterface in the expression.
Definition expressionTraits.hpp:184
Implement logic for leaf nodes only.
Definition forEachLeafLogic.hpp:60
Indices enable the mapping of primal values to their adjoint counterparts.
Definition indexManagerInterface.hpp:78
Whether the adjoint vector is global, that is, shared among different tapes.
Definition adjointVectorTraits.hpp:50
Abstracts the internal set of adjoint variables provided as part of the tape.
Definition internalAdjointsInterface.hpp:80
Pushes all delayed Jacobians.
Definition jacobianBaseTape.hpp:320
void handleActive(ReferenceActiveType< Type > const &node, DataVector &dataVector)
Specialization for ReferenceActiveType nodes. Pushes the delayed Jacobian.
Definition jacobianBaseTape.hpp:325
Pushes Jacobians and indices to the tape.
Definition jacobianBaseTape.hpp:288
void handleJacobianOnActive(Node const &node, Jacobian jacobianExpr, DataVector &dataVector)
General implementation. Checks for invalid and passive values/Jacobians.
Definition jacobianBaseTape.hpp:292
void handleJacobianOnActive(ReferenceActiveType< Type > const &node, Jacobian jacobianExpr, DataVector &dataVector)
Specialization for ReferenceActiveType nodes. Delays Jacobian push.
Definition jacobianBaseTape.hpp:306
Wrapper helper for improved compiler optimizations.
Definition jacobianBaseTape.hpp:565
Wrapper helper for improved compiler optimizations.
Definition jacobianBaseTape.hpp:546
Base class for all standard Jacobian tape implementations.
Definition jacobianBaseTape.hpp:128
void evaluateKeepState(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:888
void pushJacobians(ExpressionInterface< Real, Rhs > const &rhs)
Push Jacobians and delayed Jacobians to the tape.
Definition jacobianBaseTape.hpp:341
IndexManager & getIndexManager()
Returns a reference to the Index Manager.
Definition jacobianBaseTape.hpp:838
JacobianData jacobianData
Data stream for argument specific data.
Definition jacobianBaseTape.hpp:174
typename Base::Position Position
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:152
size_t getParameter(TapeParameters parameter) const
See Parameters functions.
Definition jacobianBaseTape.hpp:645
typename TapeTypes::Gradient Gradient
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:140
typename TapeTypes::JacobianData JacobianData
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:145
static void internalEvaluateReverse_EvalStatements(Args &&... args)
Perform a reverse evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
void resizeAdjointVector()
Explicitly trigger resizing of the adjoint vector. See Adjoint vector management.
Definition jacobianBaseTape.hpp:630
Gradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Constant reference access to gradient.
Definition jacobianBaseTape.hpp:251
StatementData statementData
Data stream for statement specific data.
Definition jacobianBaseTape.hpp:173
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, LhsExpressionInterface< Real, Gradient, Impl, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:406
Adjoints adjoints
Evaluation vector for AD.
Definition jacobianBaseTape.hpp:176
void beginUseAdjointVector()
Declare that the adjoint vector is being used. See Adjoint vector management.
Definition jacobianBaseTape.hpp:635
static void incrementTangents(AdjointVector const &adjointVector, AdjointVectorTraits::Gradient< AdjointVector > &lhsAdjoint, Config::ArgumentSize const &numberOfArguments, size_t &curJacobianPos, Real const *const rhsJacobians, Identifier const *const rhsIdentifiers)
Performs the AD forward equation for a statement.
Definition jacobianBaseTape.hpp:550
Real const & primal(Identifier const &identifier) const
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:936
void pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfArguments)
Add statement specific data to the data streams.
TapeValues internalGetTapeValues() const
Adds data from all streams, the size of the adjoint vector and index manager data.
Definition jacobianBaseTape.hpp:488
typename TapeTypes::IndexManager IndexManager
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:141
friend Base
Allow the base class to call protected and private methods.
Definition jacobianBaseTape.hpp:137
void clearAdjoints(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Clear all adjoint values, that is, set them to zero.
Definition jacobianBaseTape.hpp:471
void evaluateKeepState(Position const &start, Position const &end, AdjointVector &&data)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:895
typename TapeTypes::template Adjoints< Impl > Adjoints
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:147
VectorAccess< decltype(adjoints.data())> * createVectorAccess()
See Adjoint vector access.
Definition jacobianBaseTape.hpp:686
void pushLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &data)
Push a low level function to the tape.
Definition jacobianBaseTape.hpp:848
VectorAccess< AdjointVector > * createVectorAccessCustomAdjoints(AdjointVector &&data)
Definition jacobianBaseTape.hpp:692
void endUseAdjointVector()
Declare that the adjoint vector is no longer used. See Adjoint vector management.
Definition jacobianBaseTape.hpp:640
static void internalEvaluateForward_EvalStatements(Args &&... args)
Perform a forward evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
void deleteAdjointVector()
Delete the adjoint vector. See Adjoint vector management.
Definition jacobianBaseTape.hpp:625
void swap(Impl &other)
Swap all data with an other tape.
Definition jacobianBaseTape.hpp:615
void evaluateForward(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a forward evaluation of a part of the tape. It has to hold start <= end.
Definition jacobianBaseTape.hpp:729
typename TapeTypes::Real Real
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:139
typename TapeTypes::StatementData StatementData
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:144
T_Impl Impl
See JacobianBaseTape.
Definition jacobianBaseTape.hpp:134
Real & primal(Identifier const &identifier)
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:926
JacobianBaseTape()
Constructor.
Definition jacobianBaseTape.hpp:210
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, Real const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:425
void store(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &lhs, ExpressionInterface< Real, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:365
static void incrementAdjoints(AdjointVector &adjointVector, AdjointVectorTraits::Gradient< AdjointVector > const &lhsAdjoint, Config::ArgumentSize const &numberOfArguments, size_t &curJacobianPos, Real const *const rhsJacobians, Identifier const *const rhsIdentifiers)
Performs the AD reverse equation for a statement.
Definition jacobianBaseTape.hpp:527
void evaluateForwardKeepState(Position const &start, Position const &end, AdjointVector &&data)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:907
void setParameter(TapeParameters parameter, size_t value)
See Parameters functions.
Definition jacobianBaseTape.hpp:665
void evaluateForward(Position const &start, Position const &end, AdjointVector &&data)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition jacobianBaseTape.hpp:591
void evaluate(Position const &start, Position const &end, AdjointVector &&data)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition jacobianBaseTape.hpp:576
typename JacobianData::Position NestedPosition
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:151
static bool constexpr HasPrimalValues
See PrimalEvaluationTapeInterface.
Definition jacobianBaseTape.hpp:159
static bool constexpr RequiresPrimalRestore
See PrimalEvaluationTapeInterface.
Definition jacobianBaseTape.hpp:163
void evaluateForwardKeepState(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a tape evaluation but restore the state afterwards such that it is the same as when the evalu...
Definition jacobianBaseTape.hpp:900
void registerInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition jacobianBaseTape.hpp:465
static bool constexpr AllowJacobianOptimization
See InternalStatementRecordingTapeInterface.
Definition jacobianBaseTape.hpp:158
void storeManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size)
Definition jacobianBaseTape.hpp:775
void writeTape(codi::TapeWriterInterface< Type > *writer, Position const &start, Position const &end)
For full or partial tapes using a pointer to the writer.
Definition jacobianBaseTape.hpp:824
VectorAccess< Adjoint * > * createVectorAccessCustomAdjoints(Adjoint *data)
Definition jacobianBaseTape.hpp:699
void evaluate(Position const &start, Position const &end, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Perform a reverse evaluation for a part of the tape. It hast to hold start >= end.
Definition jacobianBaseTape.hpp:866
void initIdentifier(Real &value, Identifier &identifier)
Definition jacobianBaseTape.hpp:269
void pushJacobianManual(Real const &jacobian, Real const &value, Identifier const &index)
Definition jacobianBaseTape.hpp:751
void createStatementManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size, Real const *jacobians, Identifier const *rhsIdentifiers)
Definition jacobianBaseTape.hpp:798
void evaluatePrimal(Position const &start, Position const &end)
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:919
static bool constexpr LinearIndexHandling
See IdentifierInformationTapeInterface.
Definition jacobianBaseTape.hpp:161
Real registerExternalFunctionOutput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition jacobianBaseTape.hpp:715
void destroyIdentifier(Real &value, Identifier &identifier)
Has to be called for each identifier, before it is deallocated.
Definition jacobianBaseTape.hpp:277
Gradient & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reference access to gradient.
Definition jacobianBaseTape.hpp:239
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition jacobianBaseTape.hpp:149
T_TapeTypes TapeTypes
See JacobianBaseTape.
Definition jacobianBaseTape.hpp:132
MemberStore< IndexManager, Impl, TapeTypes::IsStaticIndexHandler > indexManager
Index manager.
Definition jacobianBaseTape.hpp:172
typename TapeTypes::Identifier Identifier
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:142
void deleteVectorAccess(VectorAccessInterface< Real, Identifier > *access)
See Adjoint vector access.
Definition jacobianBaseTape.hpp:704
void internalRegisterInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, bool unusedIndex)
Add a new input to the tape.
Definition jacobianBaseTape.hpp:440
decltype(adjoints.data()) getInternalAdjoints()
Obtain a representation of the tape's internal adjoint vector that can be used as custom adjoints.
Definition jacobianBaseTape.hpp:605
Definition jacobianComputationLogic.hpp:53
Type definitions for the Jacobian tapes.
Definition jacobianBaseTape.hpp:78
T_Real Real
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:81
typename std::conditional< IsLinearIndexHandler, Chunk1< Config::ArgumentSize >, Chunk2< Identifier, Config::ArgumentSize > >::type StatementChunk
Definition jacobianBaseTape.hpp:101
Data< JacobianChunk, StatementData > JacobianData
Jacobian data vector.
Definition jacobianBaseTape.hpp:106
Data< StatementChunk, IndexManager > StatementData
Statement data vector.
Definition jacobianBaseTape.hpp:103
T_Data< Chunk, Nested > Data
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:85
T_Gradient Gradient
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:82
T_IndexManager IndexManager
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:83
static bool constexpr IsLinearIndexHandler
True if the index manager is linear.
Definition jacobianBaseTape.hpp:95
T_Adjoints< Gradient, Identifier, Impl > Adjoints
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:92
typename IndexManager::Index Identifier
See IndexManagerInterface.
Definition jacobianBaseTape.hpp:88
JacobianData NestedData
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:108
static bool constexpr IsStaticIndexHandler
True if the index manager must be stored statically in the tape.
Definition jacobianBaseTape.hpp:96
Default implementation of the Jacobian interface.
Definition jacobian.hpp:60
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
Impl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:99
Defines a member that can either be static or local to the struct.
Definition memberStore.hpp:56
Type & get()
Get a reference to the actual member.
Definition memberStore.hpp:76
Holds a reference to an ActiveType for manual optimization of common arguments.
Definition referenceActiveType.hpp:59
Interface for the definition of tape types.
Definition commonTapeImplementation.hpp:64
Tape information that can be printed in a pretty print format or a table format.
Definition tapeValues.hpp:75
void addUnsignedLongEntry(std::string const &name, unsigned long const &value, LocalReductionOperation operation=LocalReductionOperation::Sum)
Add unsigned long entry.
Definition tapeValues.hpp:163
void addDoubleEntry(std::string const &name, double const &value, LocalReductionOperation operation=LocalReductionOperation::Sum, bool usedMem=false, bool allocatedMem=false)
Add double entry. If it is a memory entry, it should be in bytes.
Definition tapeValues.hpp:137
void addSection(std::string const &name)
Add section. All further entries are added under this section.
Definition tapeValues.hpp:158
The interface used by all the tape writers. The tape writers are used to generate text,...
Definition tapeReaderWriterInterface.hpp:128
virtual void start(Tape &tape)
Destructor.
Definition tapeReaderWriterInterface.hpp:143
virtual void finish()
After all the statements have been written, the finish method finalizes the writing process.
Definition tapeReaderWriterInterface.hpp:176
void eval(NodeInterface< Node > const &node, Args &&... args)
Start the evaluation of the logic on the given expression.
Definition traversalLogic.hpp:70
void node(Node const &node, Args &&... args)
Called for each node in the expression.
Definition traversalLogic.hpp:86
Unified access to the adjoint vector and primal vector in a tape evaluation.
Definition vectorAccessInterface.hpp:91