Add functions with custom derivatives to the tape. Can, e.g, be used to optimize small recurring functions like matrix matrix multiplication. More...
#include <lowLevelFunctionTapeInterface.hpp>
Public Types | |
using | Gradient = T_Gradient |
See LowLevelFunctionTapeInterface. | |
using | Identifier = T_Identifier |
See LowLevelFunctionTapeInterface. | |
using | Real = T_Real |
See LowLevelFunctionTapeInterface. | |
Interface definition | |
TemporaryMemory & | getTemporaryMemory () |
Temporary memory that can be used for dynamic data both during the evaluation and the recording. | |
void | pushLowLevelFunction (Config::LowLevelFunctionToken token, size_t size, ByteDataView &data) |
Push a low level function to the tape. | |
Config::LowLevelFunctionToken | registerLowLevelFunction (LowLevelFunctionEntry< LowLevelFunctionTapeInterface, Real, Identifier > const &entry) |
Register a low level function on the tape. | |
template<LowLevelFunctionEntryCallKind callType, typename... Args> | |
static void | callLowLevelFunction (LowLevelFunctionTapeInterface &tape, bool forward, size_t &curLLFByteDataPos, char *dataPtr, size_t &curLLFInfoDataPos, Config::LowLevelFunctionToken *const tokenPtr, Config::LowLevelFunctionDataSize *const dataSizePtr, Args &&... args) |
Internal function for evaluating a low level function entry. | |
Add functions with custom derivatives to the tape. Can, e.g, be used to optimize small recurring functions like matrix matrix multiplication.
A low level function like the matrix matrix multiplication can be added with this interface. First, the function needs to be registered with registerLowLevelFunction. This needs to be done only once, after this, the function is generally available. It can then be pushed as often as required with pushLowLevelFunction. Each push can be accompanied by different data, e.g., the specific matrices used by individual matrix matrix multiplications.
The user can write arbitrary data into the byte data stream. There is no requirement on the layout.
T_Real | The computation type of a tape, usually chosen as ActiveType::Real. |
T_Gradient | The gradient type of a tape, usually chosen as ActiveType::Gradient. |
T_Identifier | The adjoint/tangent identification type of a tape, usually chosen as ActiveType::Identifier. |
|
static |
Internal function for evaluating a low level function entry.
The positions curLLFByteDataPos
, and curLLFInfoDataPos
are advanced according to forward
. If forward
is true, they are increment otherwise they are decremented.
tape | The tape that is evaluated. |
forward | If the tape is forward evaluated. |
curLLFByteDataPos | Position of dynamic data. |
dataPtr | Pointer for dynamic data. |
curLLFInfoDataPos | Position of info data. |
tokenPtr | Pointer for token data. |
dataSizePtr | Pointer for data size data. |
args | Additional arguments for the function call. |
callType | The function type that is called. |
void codi::LowLevelFunctionTapeInterface< T_Real, T_Gradient, T_Identifier >::pushLowLevelFunction | ( | Config::LowLevelFunctionToken | token, |
size_t | size, | ||
ByteDataView & | data ) |
Push a low level function to the tape.
Allocates memory with the requested size on the byte data stream. data
is initialized for accessing this allocated memory. After the call, it can be used to write data to the data stream. token
is the token from registerLowLevelFunction.
See LowLevelFunctionTapeInterface for the expected data layout.