Enzyme main
Loading...
Searching...
No Matches
EnzymeLogic.h File Reference
#include <algorithm>
#include <set>
#include <utility>
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/ErrorHandling.h"
#include "ActivityAnalysis.h"
#include "FunctionUtils.h"
#include "TraceUtils.h"
#include "TypeAnalysis/TypeAnalysis.h"
#include "Utils.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/Interfaces/FunctionInterfaces.h"
#include "../../Utils.h"
#include <functional>
Include dependency graph for EnzymeLogic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  AugmentedReturn
 return structtype if recursive function More...
 
struct  ReverseCacheKey
 todiff is the function to differentiate retType is the activity info of the return. More...
 
struct  RequestContext
 
struct  FloatRepresentation
 
struct  FloatTruncation
 
class  EnzymeLogic
 
struct  EnzymeLogic::AugmentedCacheKey
 
struct  EnzymeLogic::ForwardCacheKey
 
class  mlir::enzyme::MFnTypeInfo
 
class  mlir::enzyme::MTypeAnalysis
 
class  mlir::enzyme::MTypeResults
 
class  mlir::enzyme::MEnzymeLogic
 
struct  mlir::enzyme::MEnzymeLogic::MForwardCacheKey
 
struct  mlir::enzyme::MEnzymeLogic::MReverseCacheKey
 

Namespaces

namespace  mlir
 
namespace  mlir::enzyme
 

Typedefs

typedef void mlir::enzyme::buildReturnFunction(OpBuilder &, mlir::Block *)
 

Enumerations

enum class  AugmentedStruct { Tape , Return , DifferentialReturn }
 
enum class  CacheType { Self , Shadow , Tape }
 
enum  TruncateMode { TruncMemMode = 0b0001 , TruncOpMode = 0b0010 , TruncOpFullModuleMode = 0b0110 }
 

Functions

static std::string str (AugmentedStruct c)
 
static llvm::raw_ostream & operator<< (llvm::raw_ostream &o, AugmentedStruct c)
 
static std::string str (CacheType c)
 
static llvm::raw_ostream & operator<< (llvm::raw_ostream &o, CacheType c)
 
static llvm::Type * getTypeForWidth (llvm::LLVMContext &ctx, unsigned width, bool builtinFloat)
 
static const char * truncateModeStr (TruncateMode mode)
 
bool shouldAugmentCall (llvm::CallInst *op, const GradientUtils *gutils)
 
bool legalCombinedForwardReverse (llvm::CallInst *origop, const std::map< llvm::ReturnInst *, llvm::StoreInst * > &replacedReturns, llvm::SmallVectorImpl< llvm::Instruction * > &postCreate, llvm::SmallVectorImpl< llvm::Instruction * > &userReplace, const GradientUtils *gutils, const llvm::SmallPtrSetImpl< const llvm::Instruction * > &unnecessaryInstructions, const llvm::SmallPtrSetImpl< llvm::BasicBlock * > &oldUnreachable, const bool subretused)
 
std::pair< llvm::SmallVector< llvm::Type *, 4 >, llvm::SmallVector< llvm::Type *, 4 > > getDefaultFunctionTypeForAugmentation (llvm::FunctionType *called, bool returnUsed, DIFFE_TYPE retType)
 
std::pair< llvm::SmallVector< llvm::Type *, 4 >, llvm::SmallVector< llvm::Type *, 4 > > getDefaultFunctionTypeForGradient (llvm::FunctionType *called, DIFFE_TYPE retType)
 

Variables

llvm::cl::opt< bool > EnzymePrint
 
constexpr char EnzymeFPRTPrefix [] = "__enzyme_fprt_"
 
constexpr char EnzymeFPRTOriginalPrefix [] = "__enzyme_fprt_original_"
 
llvm::cl::opt< bool > looseTypeAnalysis
 
llvm::cl::opt< bool > nonmarkedglobals_inactiveloads
 

Enumeration Type Documentation

◆ AugmentedStruct

enum class AugmentedStruct
strong
Enumerator
Tape 
Return 
DifferentialReturn 

Definition at line 60 of file EnzymeLogic.h.

◆ CacheType

enum class CacheType
strong
Enumerator
Self 
Shadow 
Tape 

Definition at line 80 of file EnzymeLogic.h.

◆ TruncateMode

Enumerator
TruncMemMode 
TruncOpMode 
TruncOpFullModuleMode 

Definition at line 336 of file EnzymeLogic.h.

Function Documentation

◆ getDefaultFunctionTypeForAugmentation()

std::pair< llvm::SmallVector< llvm::Type *, 4 >, llvm::SmallVector< llvm::Type *, 4 > > getDefaultFunctionTypeForAugmentation ( llvm::FunctionType * called,
bool returnUsed,
DIFFE_TYPE retType )

◆ getDefaultFunctionTypeForGradient()

std::pair< llvm::SmallVector< llvm::Type *, 4 >, llvm::SmallVector< llvm::Type *, 4 > > getDefaultFunctionTypeForGradient ( llvm::FunctionType * called,
DIFFE_TYPE retType )

◆ getTypeForWidth()

static llvm::Type * getTypeForWidth ( llvm::LLVMContext & ctx,
unsigned width,
bool builtinFloat )
static

Definition at line 319 of file EnzymeLogic.h.

◆ legalCombinedForwardReverse()

bool legalCombinedForwardReverse ( llvm::CallInst * origop,
const std::map< llvm::ReturnInst *, llvm::StoreInst * > & replacedReturns,
llvm::SmallVectorImpl< llvm::Instruction * > & postCreate,
llvm::SmallVectorImpl< llvm::Instruction * > & userReplace,
const GradientUtils * gutils,
const llvm::SmallPtrSetImpl< const llvm::Instruction * > & unnecessaryInstructions,
const llvm::SmallPtrSetImpl< llvm::BasicBlock * > & oldUnreachable,
const bool subretused )

◆ operator<<() [1/2]

static llvm::raw_ostream & operator<< ( llvm::raw_ostream & o,
AugmentedStruct c )
inlinestatic

Definition at line 75 of file EnzymeLogic.h.

◆ operator<<() [2/2]

static llvm::raw_ostream & operator<< ( llvm::raw_ostream & o,
CacheType c )
inlinestatic

Definition at line 95 of file EnzymeLogic.h.

◆ shouldAugmentCall()

bool shouldAugmentCall ( llvm::CallInst * op,
const GradientUtils * gutils )

◆ str() [1/2]

◆ str() [2/2]

static std::string str ( CacheType c)
inlinestatic

Definition at line 82 of file EnzymeLogic.h.

◆ truncateModeStr()

static const char * truncateModeStr ( TruncateMode mode)
static

Definition at line 341 of file EnzymeLogic.h.

Variable Documentation

◆ EnzymeFPRTOriginalPrefix

char EnzymeFPRTOriginalPrefix[] = "__enzyme_fprt_original_"
constexpr

Definition at line 58 of file EnzymeLogic.h.

◆ EnzymeFPRTPrefix

char EnzymeFPRTPrefix[] = "__enzyme_fprt_"
constexpr

Definition at line 57 of file EnzymeLogic.h.

◆ EnzymePrint

llvm::cl::opt<bool> EnzymePrint
extern

◆ looseTypeAnalysis

◆ nonmarkedglobals_inactiveloads

llvm::cl::opt<bool> nonmarkedglobals_inactiveloads
extern