|
Enzyme main
|
#include "MLIR/Interfaces/EnzymeLogic.h"

Classes | |
| struct | AugmentedCacheKey |
| struct | ForwardCacheKey |
Public Types | |
| using | BatchCacheKey |
| using | TraceCacheKey |
| using | TruncateCacheKey |
Public Member Functions | |
| EnzymeLogic (bool PostOpt) | |
| llvm::Function * | CreateNoFree (RequestContext context, llvm::Function *todiff) |
| llvm::Value * | CreateNoFree (RequestContext context, llvm::Value *todiff) |
| const AugmentedReturn & | CreateAugmentedPrimal (RequestContext context, llvm::Function *todiff, DIFFE_TYPE retType, llvm::ArrayRef< DIFFE_TYPE > constant_args, TypeAnalysis &TA, bool returnUsed, bool shadowReturnUsed, const FnTypeInfo &typeInfo, bool subsequent_calls_may_write, const std::vector< bool > _overwritten_args, bool forceAnonymousTape, bool runtimeActivity, bool strongZero, unsigned width, bool AtomicAdd, bool omp=false) |
| Create an augmented forward pass. | |
| llvm::Function * | CreatePrimalAndGradient (RequestContext context, const ReverseCacheKey &&key, TypeAnalysis &TA, const AugmentedReturn *augmented, bool omp=false) |
| Create the reverse pass, or combined forward+reverse derivative function. | |
| llvm::Function * | CreateForwardDiff (RequestContext context, llvm::Function *todiff, DIFFE_TYPE retType, llvm::ArrayRef< DIFFE_TYPE > constant_args, TypeAnalysis &TA, bool returnValue, DerivativeMode mode, bool freeMemory, bool runtimeActivity, bool strongZero, unsigned width, llvm::Type *additionalArg, const FnTypeInfo &typeInfo, bool subsequent_calls_may_write, const std::vector< bool > _overwritten_args, const AugmentedReturn *augmented, bool omp=false) |
| Create the forward (or forward split) mode derivative function. | |
| llvm::Function * | CreateBatch (RequestContext context, llvm::Function *tobatch, unsigned width, llvm::ArrayRef< BATCH_TYPE > arg_types, BATCH_TYPE ret_type) |
| Create a function batched in its inputs. | |
| llvm::Function * | CreateTruncateFunc (RequestContext context, llvm::Function *tobatch, FloatTruncation truncation, TruncateMode mode) |
| bool | CreateTruncateValue (RequestContext context, llvm::Value *addr, FloatRepresentation from, FloatRepresentation to, bool isTruncate) |
| llvm::Function * | CreateTrace (RequestContext context, llvm::Function *totrace, const llvm::SmallPtrSetImpl< llvm::Function * > &sampleFunctions, const llvm::SmallPtrSetImpl< llvm::Function * > &observeFunctions, const llvm::StringSet<> &ActiveRandomVariables, ProbProgMode mode, bool autodiff, TraceInterface *interface) |
Create a traced version of a function context the instruction which requested this trace (or null). | |
| void | clear () |
Public Attributes | |
| PreProcessCache | PPC |
| bool | PostOpt |
PostOpt is whether to perform basic optimization of the function after synthesis | |
| void * | ExternalContext |
| Provided through the frontend and only used from it. | |
| std::map< llvm::Function *, llvm::Function * > | NoFreeCachedFunctions |
| std::map< AugmentedCacheKey, AugmentedReturn > | AugmentedCachedFunctions |
| std::map< ReverseCacheKey, llvm::Function * > | ReverseCachedFunctions |
| std::map< ForwardCacheKey, llvm::Function * > | ForwardCachedFunctions |
| std::map< BatchCacheKey, llvm::Function * > | BatchCachedFunctions |
| std::map< TraceCacheKey, llvm::Function * > | TraceCachedFunctions |
| std::map< TruncateCacheKey, llvm::Function * > | TruncateCachedFunctions |
Definition at line 450 of file EnzymeLogic.h.
Definition at line 685 of file EnzymeLogic.h.
Definition at line 689 of file EnzymeLogic.h.
Definition at line 747 of file EnzymeLogic.h.
|
inline |
Definition at line 460 of file EnzymeLogic.h.
| void EnzymeLogic::clear | ( | ) |
Definition at line 6794 of file EnzymeLogic.cpp.
| const AugmentedReturn & EnzymeLogic::CreateAugmentedPrimal | ( | RequestContext | context, |
| llvm::Function * | todiff, | ||
| DIFFE_TYPE | retType, | ||
| llvm::ArrayRef< DIFFE_TYPE > | constant_args, | ||
| TypeAnalysis & | TA, | ||
| bool | returnUsed, | ||
| bool | shadowReturnUsed, | ||
| const FnTypeInfo & | typeInfo, | ||
| bool | subsequent_calls_may_write, | ||
| const std::vector< bool > | _overwritten_args, | ||
| bool | forceAnonymousTape, | ||
| bool | runtimeActivity, | ||
| bool | strongZero, | ||
| unsigned | width, | ||
| bool | AtomicAdd, | ||
| bool | omp = false ) |
Create an augmented forward pass.
return structtype if recursive function
context the instruction which requested this derivative (or null). todiff is the function to differentiate retType is the activity info of the return constant_args is the activity info of the arguments returnUsed is whether the primal's return should also be returned typeInfo is the type info information about the calling context subsequent_calls_may_write denotes whether an instruction between forward and reverse may write to memory potentially read by this function. _overwritten_args marks whether an argument may be rewritten before loads in the generated function (and thus cannot be cached). forceAnonymousTape forces the tape to be an i8* rather than the true tape structure AtomicAdd is whether to perform all adjoint updates to memory in an atomic way
Explicitly handle all returns first to ensure that all instructions know whether or not they are used
Keep track of inverted pointers we may need to return
Definition at line 1998 of file EnzymeLogic.cpp.
Referenced by AdjointGenerator::recursivelyHandleSubfunction(), and AdjointGenerator::visitOMPCall().
| llvm::Function * EnzymeLogic::CreateBatch | ( | RequestContext | context, |
| llvm::Function * | tobatch, | ||
| unsigned | width, | ||
| llvm::ArrayRef< BATCH_TYPE > | arg_types, | ||
| BATCH_TYPE | ret_type ) |
Create a function batched in its inputs.
context the instruction which requested this batch (or null). tobatch is the function to batch width is the vector width requested. arg_types denotes which arguments are batched. ret_type denotes whether to batch the return.
Definition at line 5812 of file EnzymeLogic.cpp.
Referenced by InstructionBatcher::visitCallInst().
| Function * EnzymeLogic::CreateForwardDiff | ( | RequestContext | context, |
| llvm::Function * | todiff, | ||
| DIFFE_TYPE | retType, | ||
| llvm::ArrayRef< DIFFE_TYPE > | constant_args, | ||
| TypeAnalysis & | TA, | ||
| bool | returnValue, | ||
| DerivativeMode | mode, | ||
| bool | freeMemory, | ||
| bool | runtimeActivity, | ||
| bool | strongZero, | ||
| unsigned | width, | ||
| llvm::Type * | additionalArg, | ||
| const FnTypeInfo & | typeInfo, | ||
| bool | subsequent_calls_may_write, | ||
| const std::vector< bool > | _overwritten_args, | ||
| const AugmentedReturn * | augmented, | ||
| bool | omp = false ) |
Create the forward (or forward split) mode derivative function.
context the instruction which requested this derivative (or null). todiff is the function to differentiate retType is the activity info of the return constant_args is the activity info of the arguments TA is the type analysis results returnValue is whether the primal's return should also be returned mode is the requested derivative mode is whether we should free memory allocated here (and could be accessed externally). width is the vector width requested. additionalArg is the type (or null) of an additional type in the signature to hold the tape. FnTypeInfo is the known types of the argument and returns subsequent_calls_may_write denotes whether an instruction between forward and reverse may write to memory potentially read by this function. _overwritten_args marks whether an argument may be rewritten before loads in the generated function (and thus cannot be cached). augmented is the data structure created by prior call to an augmented forward pass omp is whether this function is an OpenMP closure body.
Definition at line 4666 of file EnzymeLogic.cpp.
Referenced by AdjointGenerator::recursivelyHandleSubfunction().
| llvm::Function * EnzymeLogic::CreateNoFree | ( | RequestContext | context, |
| llvm::Function * | todiff ) |
Referenced by AdjointGenerator::visitCallInst().
| llvm::Value * EnzymeLogic::CreateNoFree | ( | RequestContext | context, |
| llvm::Value * | todiff ) |
Definition at line 6199 of file EnzymeLogic.cpp.
| Function * EnzymeLogic::CreatePrimalAndGradient | ( | RequestContext | context, |
| const ReverseCacheKey && | key, | ||
| TypeAnalysis & | TA, | ||
| const AugmentedReturn * | augmented, | ||
| bool | omp = false ) |
Create the reverse pass, or combined forward+reverse derivative function.
context the instruction which requested this derivative (or null). augmented is the data structure created by prior call to an augmented forward pass
Definition at line 3691 of file EnzymeLogic.cpp.
Referenced by AdjointGenerator::recursivelyHandleSubfunction(), and AdjointGenerator::visitOMPCall().
| llvm::Function * EnzymeLogic::CreateTrace | ( | RequestContext | context, |
| llvm::Function * | totrace, | ||
| const llvm::SmallPtrSetImpl< llvm::Function * > & | sampleFunctions, | ||
| const llvm::SmallPtrSetImpl< llvm::Function * > & | observeFunctions, | ||
| const llvm::StringSet<> & | ActiveRandomVariables, | ||
| ProbProgMode | mode, | ||
| bool | autodiff, | ||
| TraceInterface * | interface ) |
Create a traced version of a function context the instruction which requested this trace (or null).
totrace is the function to trace sampleFunctions is a set of the functions to sample observeFunctions is a set of the functions to observe ActiveRandomVariables is a set of which variables are active mode is the mode to use autodiff is whether to also differentiate interface specifies the ABI to use.
Definition at line 6099 of file EnzymeLogic.cpp.
Referenced by TraceGenerator::handleArbitraryCall().
| llvm::Function * EnzymeLogic::CreateTruncateFunc | ( | RequestContext | context, |
| llvm::Function * | tobatch, | ||
| FloatTruncation | truncation, | ||
| TruncateMode | mode ) |
Definition at line 5724 of file EnzymeLogic.cpp.
| bool EnzymeLogic::CreateTruncateValue | ( | RequestContext | context, |
| llvm::Value * | addr, | ||
| FloatRepresentation | from, | ||
| FloatRepresentation | to, | ||
| bool | isTruncate ) |
Definition at line 5702 of file EnzymeLogic.cpp.
| std::map<AugmentedCacheKey, AugmentedReturn> EnzymeLogic::AugmentedCachedFunctions |
Definition at line 566 of file EnzymeLogic.h.
| std::map<BatchCacheKey, llvm::Function *> EnzymeLogic::BatchCachedFunctions |
Definition at line 687 of file EnzymeLogic.h.
| void* EnzymeLogic::ExternalContext |
Provided through the frontend and only used from it.
Definition at line 458 of file EnzymeLogic.h.
Referenced by EnzymeGradientUtilsGetExternalContext().
| std::map<ForwardCacheKey, llvm::Function *> EnzymeLogic::ForwardCachedFunctions |
Definition at line 683 of file EnzymeLogic.h.
| std::map<llvm::Function *, llvm::Function *> EnzymeLogic::NoFreeCachedFunctions |
Definition at line 562 of file EnzymeLogic.h.
| bool EnzymeLogic::PostOpt |
PostOpt is whether to perform basic optimization of the function after synthesis
Definition at line 456 of file EnzymeLogic.h.
| PreProcessCache EnzymeLogic::PPC |
Definition at line 452 of file EnzymeLogic.h.
Referenced by DiffeGradientUtils::CreateFromClone().
| std::map<ReverseCacheKey, llvm::Function *> EnzymeLogic::ReverseCachedFunctions |
Definition at line 593 of file EnzymeLogic.h.
| std::map<TraceCacheKey, llvm::Function *> EnzymeLogic::TraceCachedFunctions |
Definition at line 691 of file EnzymeLogic.h.
| std::map<TruncateCacheKey, llvm::Function *> EnzymeLogic::TruncateCachedFunctions |
Definition at line 749 of file EnzymeLogic.h.