43#include "../expressions/aggregate/aggregatedActiveType.hpp"
44#include "../expressions/aggregate/arrayAccessExpression.hpp"
45#include "../expressions/lhsExpressionInterface.hpp"
46#include "../expressions/logic/compileTimeTraversalLogic.hpp"
47#include "../expressions/logic/helpers/forEachLeafLogic.hpp"
48#include "../expressions/logic/helpers/jacobianComputationLogic.hpp"
49#include "../expressions/logic/traversalLogic.hpp"
50#include "../expressions/referenceActiveType.hpp"
52#include "../misc/mathUtility.hpp"
53#include "../misc/memberStore.hpp"
54#include "../traits/adjointVectorTraits.hpp"
55#include "../traits/computationTraits.hpp"
56#include "../traits/expressionTraits.hpp"
57#include "commonTapeImplementation.hpp"
58#include "data/chunk.hpp"
59#include "data/chunkedData.hpp"
60#include "indices/indexManagerInterface.hpp"
61#include "io/tapeReaderWriterInterface.hpp"
62#include "misc/adjointVectorAccess.hpp"
63#include "misc/duplicateJacobianRemover.hpp"
64#include "misc/localAdjoints.hpp"
78 template<
typename T_Real,
typename T_Gradient,
typename T_IndexManager,
template<
typename,
typename>
class T_Data,
79 template<
typename,
typename,
typename>
class T_Adjoints =
LocalAdjoints>
86 template<
typename Chunk,
typename Nested>
92 typename IndexManager::ActiveTypeIndexData;
95 template<
typename Impl>
101 IndexManager::NeedsStaticStorage;
105 using StatementChunk =
typename std::conditional<IsLinearIndexHandler, Chunk1<Config::ArgumentSize>,
131 template<
typename T_TapeTypes,
typename T_Impl>
143 using Real =
typename TapeTypes::Real;
160 template<
typename Adjo
intVector>
167 TapeTypes::IsLinearIndexHandler;
172#if CODI_RemoveDuplicateJacobianArguments
186 return static_cast<Impl const&
>(*this);
190 return static_cast<Impl&
>(*this);
200 template<
typename... Args>
204 template<
typename... Args>
247 checkAdjointSize(identifier);
273 template<
typename Real>
281 template<
typename Real>
296 template<
typename Node,
typename DataVector>
304 dataVector.pushData(jacobian,
node.getIdentifier());
311 template<
typename Type,
typename DataVector>
319 node.jacobian += jacobian;
329 template<
typename Type,
typename DataVector>
336 dataVector.pushData(
node.jacobian,
node.getIdentifier());
348 template<
typename Rhs>
350 PushJacobianLogic pushJacobianLogic;
351 PushDelayedJacobianLogic pushDelayedJacobianLogic;
353#if CODI_RemoveDuplicateJacobianArguments
354 auto& insertVector = jacobianSorter;
360 pushDelayedJacobianLogic.eval(rhs.
cast(), insertVector,
indexManager.get());
362#if CODI_RemoveDuplicateJacobianArguments
373 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
378 int constexpr Elements = AggregatedTraits::Elements;
380 bool freeAndUpdate =
true;
390 typename JacobianData::InternalPosHandle jacobianStart =
jacobianData.reserveItems(MaxArgs * Elements);
391 std::array<size_t, Elements> numberOfArguments;
392 size_t totalNumberOfArguments = 0;
396 size_t newTotalNumberOfArguments =
jacobianData.getPushedDataCount(jacobianStart);
397 numberOfArguments[i.value] = newTotalNumberOfArguments - totalNumberOfArguments;
398 totalNumberOfArguments = newTotalNumberOfArguments;
401 if (0 != totalNumberOfArguments) {
402 freeAndUpdate =
false;
411 std::array<ActiveTypeTapeData, Elements> identifiers = {};
414 indexManager.get().template assignIndex<Impl>(identifiers[i.value]);
419 Aggregated
real = rhs.
cast().getValue();
420 size_t eventJacobianOffset = 0;
426 lhs.
values[i.value].getTapeData() = identifiers[i.value];
427 cast().pushStmtData(lhs.
values[i.value].getIdentifier(),
433 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
434 jacobians -= totalNumberOfArguments;
435 rhsIdentifiers -= totalNumberOfArguments;
438 cast(), lhs.
values[i.value].getIdentifier(),
439 AggregatedTraits::template arrayAccess<i.value>(
real), numberOfArguments[i.value],
440 &rhsIdentifiers[eventJacobianOffset], &jacobians[eventJacobianOffset]);
442 eventJacobianOffset += numberOfArguments[i.value];
446 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(
real);
452 Aggregated
real = rhs.
cast().getValue();
455 lhs.
values[i.value].value() = AggregatedTraits::template arrayAccess<i.value>(
real);
463 template<
typename Aggregated,
typename Type,
typename Lhs,
typename Rhs>
468 int constexpr Elements = AggregatedTraits::Elements;
477 rhs.
values[i.value].getTapeData());
487 lhs.
values[i.value].value() = rhs.
values[i.value].getValue();
492 template<
typename Lhs,
typename Rhs>
501 typename JacobianData::InternalPosHandle jacobianStart =
jacobianData.reserveItems(MaxArgs);
505 size_t numberOfArguments =
jacobianData.getPushedDataCount(jacobianStart);
513 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
514 jacobians -= numberOfArguments;
515 rhsIdentifiers -= numberOfArguments;
518 rhs.
cast().getValue(), numberOfArguments,
519 rhsIdentifiers, jacobians);
528 lhs.
cast().value() = rhs.
cast().getValue();
533 template<
typename Lhs,
typename Rhs>
541 indexManager.get().template copyIndex<Impl>(lhs.
cast().getTapeData(), rhs.
cast().getTapeData());
547 lhs.
cast().value() = rhs.
cast().getValue();
552 template<
typename Lhs>
556 lhs.
cast().value() = rhs;
567 template<
typename Lhs>
570 if (TapeTypes::IsLinearIndexHandler) {
575 indexManager.get().template assignUnusedIndex<Impl>(value.
cast().getTapeData());
580 if (TapeTypes::IsLinearIndexHandler) {
592 template<
typename Lhs>
594 cast().internalRegisterInput(value,
true);
618 if (TapeTypes::IsLinearIndexHandler) {
619 name =
"CoDi Tape Statistics ( JacobianLinearTape )";
621 name =
"CoDi Tape Statistics ( JacobianReuseTape )";
625 size_t nAdjoints =
indexManager.get().getLargestCreatedIndex();
626 double memoryAdjoints =
static_cast<double>(nAdjoints) *
static_cast<double>(
sizeof(
Gradient));
629 TapeValues::LocalReductionOperation
constexpr operation =
630 globalAdjoints ? TapeValues::LocalReductionOperation::Max : TapeValues::LocalReductionOperation::Sum;
634 values.
addDoubleEntry(
"Memory allocated", memoryAdjoints, operation,
true,
true);
654 template<
typename Adjo
intVector>
660 size_t endJacobianPos = curJacobianPos - numberOfArguments;
663 while (endJacobianPos < curJacobianPos)
CODI_Likely {
665 adjointVector[rhsIdentifiers[curJacobianPos]] += rhsJacobians[curJacobianPos] * lhsAdjoint;
668 curJacobianPos = endJacobianPos;
677 template<
typename Adjo
intVector>
684 size_t endJacobianPos = curJacobianPos + numberOfArguments;
686 while (curJacobianPos < endJacobianPos)
CODI_Likely {
687 lhsAdjoint += rhsJacobians[curJacobianPos] * adjointVector[rhsIdentifiers[curJacobianPos]];
704 template<
typename Adjo
intVector>
709 cast(), start, end, &adjointWrapper, EventHints::EvaluationKind::Reverse, EventHints::Endpoint::Begin);
711 Wrap_internalEvaluateReverse_EvalStatements<AdjointVector> evalFunc;
712 Base::llfByteData.evaluateReverse(start, end, evalFunc, cast(), std::forward<AdjointVector>(data));
715 EventHints::EvaluationKind::Reverse, EventHints::Endpoint::End);
719 template<
typename Adjo
intVector>
724 cast(), start, end, &adjointWrapper, EventHints::EvaluationKind::Forward, EventHints::Endpoint::Begin);
726 Wrap_internalEvaluateForward_EvalStatements<AdjointVector> evalFunc;
727 Base::llfByteData.evaluateForward(start, end, evalFunc, cast(), std::forward<AdjointVector>(data));
730 EventHints::EvaluationKind::Forward, EventHints::Endpoint::End);
760 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
803 CODI_EXCEPTION(
"Tried to set a get only parameter.");
820 template<
typename Adjo
intVector>
827 template<
typename Adjo
int>
843 template<
typename Lhs>
845 cast().internalRegisterInput(value,
false);
861 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
867 cast().evaluateForward(start, end,
adjoints.data());
883 cast().incrementManualPushCounter();
892 jacobianData.getDataPointers(jacobians, rhsIdentifiers);
898 rhsIdentifiers, jacobians);
941 for (
size_t rhsCount = 0; rhsCount < size; rhsCount++) {
942 cast().incrementManualPushCounter();
943 jacobianData.pushData(jacobians[rhsCount], rhsIdentifiers[rhsCount]);
952 template<
typename Type>
957 Base::llfByteData.evaluateForward(start, end, Impl::template internalWriteTape<Type>, writer);
998 checkAdjointSize(
indexManager.get().getLargestCreatedIndex());
1019 evaluate(start, end, adjointsManagement);
1023 template<
typename Adjo
intVector>
1025 evaluate(start, end, std::forward<AdjointVector>(data));
1035 template<
typename Adjo
intVector>
1051 CODI_EXCEPTION(
"Accessing primal evaluation of an Jacobian tape.");
1058 CODI_EXCEPTION(
"Accessing primal vector of an Jacobian tape.");
1068 CODI_EXCEPTION(
"Accessing primal vector of an Jacobian tape.");
1076 CODI_EXCEPTION(
"Accessing primal vector of an Jacobian tape.");
1085 CODI_INLINE void checkAdjointSize(Identifier
const& identifier) {
1086 if (identifier >= (Identifier)
adjoints.size()) {
1087 internalResizeAdjointsVector();
#define CODI_Unlikely
Declare unlikely evaluation of an execution path.
Definition config.h:408
#define CODI_LAMBDA_INLINE
See codi::Config::ForcedInlines.
Definition config.h:473
#define CODI_NO_INLINE
See codi::Config::AvoidedInlines.
Definition config.h:426
#define CODI_INLINE
See codi::Config::ForcedInlines.
Definition config.h:469
#define CODI_Likely
Declare likely evaluation of an execution path.
Definition config.h:406
#define CODI_RESTRICT
See codi::Config::Restrict.
Definition config.h:491
#define CODI_RemoveDuplicateJacobianArguments
See codi::Config::RemoveDuplicateJacobianArguments.
Definition config.h:229
#define codiAssert(x)
See codi::Config::EnableAssert.
Definition config.h:441
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:97
#define CODI_ENABLE_CHECK(option, condition)
Definition macros.hpp:62
#define CODI_WRAP_FUNCTION_TEMPLATE(NAME, FUNC)
Wrap a function in a function object. Used for performance optimizations.
Definition macros.hpp:178
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:117
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
Configuration options for CoDiPack.
Definition config.h:65
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:328
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
inlinebool isTotalFinite(Type const &v)
Function for checking if all values of the type are finite.
Definition realTraits.hpp:139
inlinebool isTotalZero(Type const &v)
Function for checking if the value of the type is completely zero.
Definition realTraits.hpp:145
typename TraitsImplementation< Type >::PassiveReal PassiveReal
The original computation type that was used in the application.
Definition realTraits.hpp:123
CoDiPack - Code Differentiation Package.
Definition codi.hpp:97
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.
Definition tapeParameters.hpp:60
@ JacobianSize
[A: RW] Allocated number of entries in the argument Jacobian vector in Jacobian tapes.
Definition tapeParameters.hpp:59
@ StatementSize
[A: RW] Allocated number of entries in the statement vector in all tapes.
Definition tapeParameters.hpp:66
@ AdjointSize
Definition tapeParameters.hpp:53
inlinevoid static_for(F func, Args &&... args)
Static for with i = 0 .. (N - 1). See CompileTimeLoop for details.
Definition compileTimeLoop.hpp:110
typename ArrayAccessExpressionImpl< Aggregated, element >::template Expression< Arg > ArrayAccessExpression
Expression that performs a[element] in a compile time context.
Definition arrayAccessExpression.hpp:98
inlineauto real(ExpressionInterface< std::complex< Real >, Arg > const &arg)
Function overload for FUNCTION.
Definition allOperators.hpp:75
inlinevoid CODI_UNUSED(Args const &...)
Disable unused warnings for an arbitrary number of arguments.
Definition macros.hpp:55
AdjointsManagement
Policies for management of the tape's interal adjoints.
Definition tapeParameters.hpp:100
@ Automatic
Manage internal adjoints automatically, including locking, bounds checking, and resizing.
Definition tapeParameters.hpp:102
ChunkedData< Chunk, NestedData > DefaultChunkedData
ChunkData DataInterface used in all regular tapes.
Definition chunkedData.hpp:520
inlineauto max(ExpressionInterface< Real, ArgA > const &argA, ExpressionInterface< Real, ArgB > const &argB)
Function overload for FUNCTION.
Definition binaryOperators.hpp:73
Implementation of VectorAccessInterface for adjoint vectors.
Definition adjointVectorAccess.hpp:61
InnerActiveType values[Elements]
Array representation.
Definition aggregatedActiveType.hpp:75
Represents a concrete aggregated lvalue int the CoDiPack expression tree.
Definition aggregatedActiveType.hpp:164
Definition byteDataView.hpp:51
inlinevoid internalStoreLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &dataView)
Definition commonTapeImplementation.hpp:519
inlinevoid initializeManualPushData(Real const &lhsValue, Identifier const &lhsIndex, size_t size)
Initialize all manual push data, including the counter. Check that a previous manual store is complet...
Definition commonTapeImplementation.hpp:202
Real manualPushLhsValue
For storeManual, remember the value assigned to the lhs.
Definition commonTapeImplementation.hpp:160
void setParameter(TapeParameters parameter, size_t value)
Definition commonTapeImplementation.hpp:484
void evaluateForward(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:652
size_t manualPushCounter
Count the pushes after storeManual, to identify the last push.
Definition commonTapeImplementation.hpp:163
Identifier manualPushLhsIdentifier
For storeManual, remember the identifier assigned to the lhs.
Definition commonTapeImplementation.hpp:161
bool isActive() const
Definition commonTapeImplementation.hpp:322
size_t manualPushGoal
Store the number of expected pushes after a storeManual call.
Definition commonTapeImplementation.hpp:162
void init(typename ImplTapeTypes::NestedData *nested)
Initialize the base class.
Definition commonTapeImplementation.hpp:823
std::set< TapeParameters > options
All options.
Definition commonTapeImplementation.hpp:155
void writeTape(std::unique_ptr< TapeWriterInterface< Type > > writer)
Definition commonTapeImplementation.hpp:665
void evaluate(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Definition commonTapeImplementation.hpp:295
void swap(Impl &other)
Definition commonTapeImplementation.hpp:393
typename CommonTapeTypes< ImplTapeTypes >::Position Position
Definition commonTapeImplementation.hpp:147
LowLevelFunctionByteData llfByteData
Byte data for low level functions.
Definition commonTapeImplementation.hpp:158
CommonTapeImplementation()
Definition commonTapeImplementation.hpp:234
size_t getParameter(TapeParameters parameter) const
Definition commonTapeImplementation.hpp:456
void evaluatePrimal()
Definition commonTapeImplementation.hpp:798
InternalAdjoints getInternalAdjoints()
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
inlinevoid storeData(Vec &vec)
Definition duplicateJacobianRemover.hpp:98
static inlinevoid notifyTapeRegisterInputListeners(Tape &tape, Real &value, Identifier &identifier)
Invoke callbacks for TapeRegisterInput events.
Definition eventSystem.hpp:424
static inlinevoid 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 inlinevoid 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
Base class for all CoDiPack expressions.
Definition expressionInterface.hpp:60
inlineImpl const & cast() const
Cast to the implementation.
Definition expressionInterface.hpp:76
Counts the number of nodes that inherit from LhsExpressionInterface in the expression.
Definition expressionTraits.hpp:258
static size_t constexpr value
See NumberOfActiveTypeArguments.
Definition expressionTraits.hpp:272
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:325
inlinevoid handleActive(ReferenceActiveType< Type > const &node, DataVector &dataVector, IndexManager &indexManager)
Specialization for ReferenceActiveType nodes. Pushes the delayed Jacobian.
Definition jacobianBaseTape.hpp:331
Pushes Jacobians and indices to the tape.
Definition jacobianBaseTape.hpp:293
inlinevoid handleJacobianOnActive(Node const &node, Real jacobian, DataVector &dataVector, IndexManager const &indexManager)
General implementation. Checks for invalid and passive values/Jacobians.
Definition jacobianBaseTape.hpp:297
inlinevoid handleJacobianOnActive(ReferenceActiveType< Type > const &node, Real jacobian, DataVector &dataVector, IndexManager const &indexManager)
Specialization for ReferenceActiveType nodes. Delays Jacobian push.
Definition jacobianBaseTape.hpp:312
inlineTapeValues internalGetTapeValues() const
Adds data from all streams, the size of the adjoint vector and index manager data.
Definition jacobianBaseTape.hpp:616
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:1017
IndexManager & getIndexManager()
Returns a reference to the Index Manager.
Definition jacobianBaseTape.hpp:967
JacobianData jacobianData
Definition jacobianBaseTape.hpp:179
typename Base::Position Position
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:157
inlinestatic 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:655
size_t getParameter(TapeParameters parameter) const
See Parameters functions.
Definition jacobianBaseTape.hpp:774
inlinevoid pushJacobians(ExpressionInterface< Real, Rhs > const &rhs)
Push Jacobians and delayed Jacobians to the tape.
Definition jacobianBaseTape.hpp:349
typename TapeTypes::Gradient Gradient
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:144
inlinevoid initTapeData(Real &value, ActiveTypeTapeData &data)
< Has to be called for each tape data, after it is allocated.
Definition jacobianBaseTape.hpp:274
typename TapeTypes::JacobianData JacobianData
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:150
static void internalEvaluateReverse_EvalStatements(Args &&... args)
Perform a reverse evaluation of the tape. Arguments are from the recursive eval methods of the DataIn...
inlinevoid 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:493
void resizeAdjointVector()
Explicitly trigger resizing of the adjoint vector. See Adjoint vector management.
Definition jacobianBaseTape.hpp:759
StatementData statementData
Definition jacobianBaseTape.hpp:178
Adjoints adjoints
Definition jacobianBaseTape.hpp:181
void beginUseAdjointVector()
Declare that the adjoint vector is being used. See Adjoint vector management.
Definition jacobianBaseTape.hpp:764
Real const & primal(Identifier const &identifier) const
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:1065
inlinevoid swap(Impl &other)
Swap all data with an other tape.
Definition jacobianBaseTape.hpp:744
void pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfArguments)
Add statement specific data to the data streams.
typename TapeTypes::IndexManager IndexManager
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:145
friend Base
Definition jacobianBaseTape.hpp:141
inlinevoid pushLowLevelFunction(Config::LowLevelFunctionToken token, size_t size, ByteDataView &data)
Push a low level function to the tape.
Definition jacobianBaseTape.hpp:977
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:1024
typename TapeTypes::template Adjoints< Impl > Adjoints
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:152
VectorAccess< decltype(adjoints.data())> * createVectorAccess()
See Adjoint vector access.
Definition jacobianBaseTape.hpp:815
VectorAccess< AdjointVector > * createVectorAccessCustomAdjoints(AdjointVector &&data)
Definition jacobianBaseTape.hpp:821
inlinestatic 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:678
void endUseAdjointVector()
Declare that the adjoint vector is no longer used. See Adjoint vector management.
Definition jacobianBaseTape.hpp:769
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:754
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:858
inlinevoid destroyTapeData(Real &value, ActiveTypeTapeData &data)
Has to be called for each tape data, before it is deallocated.
Definition jacobianBaseTape.hpp:282
inlinevoid internalRegisterInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value, bool unusedIndex)
Add a new input to the tape.
Definition jacobianBaseTape.hpp:568
typename TapeTypes::Real Real
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:143
inlinevoid 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:995
typename TapeTypes::StatementData StatementData
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:149
inlineGradient & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Reference access to gradient.
Definition jacobianBaseTape.hpp:244
T_Impl Impl
See JacobianBaseTape.
Definition jacobianBaseTape.hpp:138
Real & primal(Identifier const &identifier)
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:1055
JacobianBaseTape()
Constructor.
Definition jacobianBaseTape.hpp:215
typename TapeTypes::ActiveTypeTapeData ActiveTypeTapeData
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:147
AdjointVectorAccess< Real, Identifier, AdjointVector > VectorAccess
Vector access type generated by this tape.
Definition jacobianBaseTape.hpp:161
CommonTapeImplementation< T_TapeTypes, T_Impl > Base
Base class abbreviation.
Definition jacobianBaseTape.hpp:140
Real * getPrimalVector()
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:1075
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:1036
void setParameter(TapeParameters parameter, size_t value)
See Parameters functions.
Definition jacobianBaseTape.hpp:794
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:720
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:705
inlinevoid 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:534
inlinevoid store(AggregatedActiveType< Aggregated, Type, Lhs > &lhs, ExpressionInterface< Aggregated, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:374
typename JacobianData::Position NestedPosition
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:156
static bool constexpr HasPrimalValues
Definition jacobianBaseTape.hpp:164
void storeManual(Real const &lhsValue, ActiveTypeTapeData &lhsData, Config::ArgumentSize const &size)
Definition jacobianBaseTape.hpp:904
static bool constexpr RequiresPrimalRestore
Definition jacobianBaseTape.hpp:168
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:1029
inlinevoid 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:553
static bool constexpr AllowJacobianOptimization
Definition jacobianBaseTape.hpp:163
inlinevoid store(AggregatedActiveType< Aggregated, Type, Lhs > &lhs, AggregatedActiveType< Aggregated, Type, Rhs > const &rhs)
Has to be called by an AD variable every time it is assigned.
Definition jacobianBaseTape.hpp:464
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:953
VectorAccess< Adjoint * > * createVectorAccessCustomAdjoints(Adjoint *data)
Definition jacobianBaseTape.hpp:828
void createStatementManual(Real const &lhsValue, Identifier &lhsIndex, Config::ArgumentSize const &size, Real const *jacobians, Identifier const *rhsIdentifiers)
Definition jacobianBaseTape.hpp:927
void evaluatePrimal(Position const &start, Position const &end)
Not implemented, raises an exception.
Definition jacobianBaseTape.hpp:1048
static bool constexpr LinearIndexHandling
Definition jacobianBaseTape.hpp:166
Real registerExternalFunctionOutput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition jacobianBaseTape.hpp:844
void pushJacobianManual(Real const &jacobian, Real const &value, ActiveTypeTapeData const &data)
Definition jacobianBaseTape.hpp:880
RealTraits::PassiveReal< Real > PassiveReal
Basic computation type.
Definition jacobianBaseTape.hpp:154
T_TapeTypes TapeTypes
See JacobianBaseTape.
Definition jacobianBaseTape.hpp:136
inlinevoid clearAdjoints(AdjointsManagement adjointsManagement=AdjointsManagement::Automatic)
Clear all adjoint values, that is, set them to zero.
Definition jacobianBaseTape.hpp:599
MemberStore< IndexManager, Impl, TapeTypes::IsStaticIndexHandler > indexManager
Definition jacobianBaseTape.hpp:177
typename TapeTypes::Identifier Identifier
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:146
void deleteVectorAccess(VectorAccessInterface< Real, Identifier > *access)
See Adjoint vector access.
Definition jacobianBaseTape.hpp:833
inlineGradient const & gradient(Identifier const &identifier, AdjointsManagement adjointsManagement=AdjointsManagement::Automatic) const
Constant reference access to gradient.
Definition jacobianBaseTape.hpp:256
inlinevoid registerInput(LhsExpressionInterface< Real, Gradient, Impl, Lhs > &value)
Definition jacobianBaseTape.hpp:593
Definition jacobianComputationLogic.hpp:54
inlinevoid pushStmtData(Identifier const &index, Config::ArgumentSize const &numberOfArguments)
Add statement specific data to the data streams.
Definition jacobianLinearTape.hpp:126
Type definitions for the Jacobian tapes.
Definition jacobianBaseTape.hpp:80
T_Real Real
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:83
typename std::conditional< IsLinearIndexHandler, Chunk1< Config::ArgumentSize >, Chunk2< Identifier, Config::ArgumentSize > >::type StatementChunk
Definition jacobianBaseTape.hpp:105
Chunk2< Real, Identifier > JacobianChunk
Jacobian chunks is <Jacobian, rhs index>.
Definition jacobianBaseTape.hpp:109
typename IndexManager::ActiveTypeIndexData ActiveTypeTapeData
Take the active real data from the index manager.
Definition jacobianBaseTape.hpp:91
Data< JacobianChunk, StatementData > JacobianData
Jacobian data vector.
Definition jacobianBaseTape.hpp:110
Data< StatementChunk, IndexManager > StatementData
Statement data vector.
Definition jacobianBaseTape.hpp:107
T_Data< Chunk, Nested > Data
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:87
T_Gradient Gradient
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:84
T_IndexManager IndexManager
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:85
static bool constexpr IsLinearIndexHandler
True if the index manager is linear.
Definition jacobianBaseTape.hpp:99
T_Adjoints< Gradient, Identifier, Impl > Adjoints
See JacobianTapeTypes.
Definition jacobianBaseTape.hpp:96
typename IndexManager::Index Identifier
See IndexManagerInterface.
Definition jacobianBaseTape.hpp:90
JacobianData NestedData
See TapeTypesInterface.
Definition jacobianBaseTape.hpp:112
static bool constexpr IsStaticIndexHandler
True if the index manager must be stored statically in the tape.
Definition jacobianBaseTape.hpp:100
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63
inlineImpl & cast()
Cast to the implementation.
Definition lhsExpressionInterface.hpp:103
Adjoint variables owned by a tape instance.
Definition localAdjoints.hpp:54
Defines a member that can either be static or local to the struct.
Definition memberStore.hpp:56
Methods that access inner values of aggregated types that contain CoDiPack active types.
Definition realTraits.hpp:233
Holds a reference to an ActiveType for manual optimization of common arguments.
Definition referenceActiveType.hpp:61
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:129
virtual void start(Tape &tape)
Destructor.
Definition tapeReaderWriterInterface.hpp:144
virtual void finish()
After all the statements have been written, the finish method finalizes the writing process.
Definition tapeReaderWriterInterface.hpp:177
inlinevoid node(Node const &node, Args &&... args)
Definition traversalLogic.hpp:87
Unified access to the adjoint vector and primal vector in a tape evaluation.
Definition vectorAccessInterface.hpp:94