40#include "../../expressions/lhsExpressionInterface.hpp"
42#include "../../tapes/interfaces/fullTapeInterface.hpp"
43#include "../../tapes/misc/vectorAccessInterface.hpp"
44#include "../../traits/tapeTraits.hpp"
45#include "../data/externalFunctionUserData.hpp"
46#include "externalFunctionHelper.hpp"
50extern int enzyme_const;
52template<
typename... Args>
53void __enzyme_autodiff(
void*, Args...);
55template<
typename... Args>
56void __enzyme_fwddiff(
void*, Args...);
83 template<
typename T_Type>
92 using Real =
typename Type::Real;
117 template<PrimalFunc func>
124 template<PrimalFunc func>
126 for (
size_t i = 0; i < m; i += 1) {
130 for (
size_t i = 0; i < n; i += 1) {
134 callAndAddToTape<func>();
138 template<PrimalFunc func>
139 static void enzymeDiff_b(
Real const* x,
Real* x_b,
size_t m,
Real const*
y,
Real const* y_b,
size_t n,
152 template<PrimalFunc func>
153 static void enzymeDiff_d(
Real const* x,
Real const* x_d,
size_t m,
Real*
y,
Real* y_d,
size_t n,
154 ExternalFunctionUserData* d) {
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
#define CODI_T(...)
Abbreviation for CODI_TEMPLATE.
Definition macros.hpp:111
CoDiPack - Code Differentiation Package.
Definition codi.hpp:90
Represents a concrete lvalue in the CoDiPack expression tree.
Definition activeType.hpp:52
Helper class for the implementation of an external function with Enzyme in CoDiPack.
Definition enzymeExternalFunctionHelper.hpp:84
typename Type::Real Real
See LhsExpressionInterface.
Definition enzymeExternalFunctionHelper.hpp:92
typename Type::Tape Tape
See LhsExpressionInterface.
Definition enzymeExternalFunctionHelper.hpp:96
T_Type Type
See ExternalFunctionHelper.
Definition enzymeExternalFunctionHelper.hpp:88
typename Base::PrimalFunc PrimalFunc
See ExternalFunctionHelper.
Definition enzymeExternalFunctionHelper.hpp:98
typename Type::Identifier Identifier
See LhsExpressionInterface.
Definition enzymeExternalFunctionHelper.hpp:93
void callAndAddToTape()
Definition enzymeExternalFunctionHelper.hpp:118
EnzymeExternalFunctionHelper()
Constructor.
Definition enzymeExternalFunctionHelper.hpp:103
void callAndAddToTape(Type const *x, size_t m, Type *y, size_t n)
Adds all inputs in x and outputs in y to the external function and then calls callAndAddToTape().
Definition enzymeExternalFunctionHelper.hpp:125
Helper class for the implementation of an external function in CoDiPack.
Definition externalFunctionHelper.hpp:102
void addInput(Type const &input)
Add an input value.
Definition externalFunctionHelper.hpp:451
void callPrimalFuncWithADType(FuncObj &func, Args &&... args)
Definition externalFunctionHelper.hpp:513
void addOutput(Type &output)
Add an output value.
Definition externalFunctionHelper.hpp:492
void(*)(Real const *x, size_t m, Real *y, size_t n, ExternalFunctionUserData *d) PrimalFunc
Function interface for the primal call of an external function.
Definition externalFunctionHelper.hpp:128
void callPrimalFunc(PrimalFunc func)
Definition externalFunctionHelper.hpp:539
std::vector< Real > y
Shared vector of output variables.
Definition externalFunctionHelper.hpp:397
void addToTape(ReverseFunc reverseFunc, ForwardFunc forwardFunc=nullptr, PrimalFunc primalFunc=nullptr)
Add the external function to the tape.
Definition externalFunctionHelper.hpp:577
Ease of access structure for user-provided data on the tape for external functions....
Definition externalFunctionUserData.hpp:59
Full tape interface that supports all features of CoDiPack.
Definition fullTapeInterface.hpp:82
Base class for all CoDiPack lvalue expression.
Definition lhsExpressionInterface.hpp:63