Enzyme main
Loading...
Searching...
No Matches
mlir::enzyme::MGradientUtilsReverse Class Reference

#include "MLIR/Interfaces/GradientUtilsReverse.h"

Inheritance diagram for mlir::enzyme::MGradientUtilsReverse:
Collaboration diagram for mlir::enzyme::MGradientUtilsReverse:

Public Member Functions

 MGradientUtilsReverse (MEnzymeLogic &Logic, FunctionOpInterface newFunc_, FunctionOpInterface oldFunc_, MTypeAnalysis &TA_, IRMapping invertedPointers_, const llvm::ArrayRef< bool > returnPrimals, const llvm::ArrayRef< bool > returnShadows, const SmallPtrSetImpl< mlir::Value > &constantvalues_, const SmallPtrSetImpl< mlir::Value > &activevals_, ArrayRef< DIFFE_TYPE > ReturnActivity, ArrayRef< DIFFE_TYPE > ArgDiffeTypes_, IRMapping &originalToNewFn_, std::map< Operation *, Operation * > &originalToNewFnOps_, DerivativeMode mode_, unsigned width, bool omp, llvm::StringRef postpasses, bool verifyPostPasses, bool strongZero)
 
void addToDiffe (mlir::Value oldGradient, mlir::Value addedGradient, OpBuilder &builder)
 
Type getIndexType ()
 
Value insertInit (Type t)
 
void registerCacheCreatorHook (std::function< std::pair< Value, Value >(Type)> hook)
 
void deregisterCacheCreatorHook (std::function< std::pair< Value, Value >(Type)> hook)
 
std::pair< Value, Value > getNewCache (Type t)
 
Type getCacheType (Type t)
 
Type getIndexCacheType ()
 
Value initAndPushCache (Value v, OpBuilder &builder)
 
Operation * cloneWithNewOperands (OpBuilder &B, Operation *op)
 
Value popCache (Value cache, OpBuilder &builder)
 
void createReverseModeBlocks (Region &oldFunc, Region &newFunc)
 
- Public Member Functions inherited from mlir::enzyme::MDiffeGradientUtils
void registerGradientCreatorHook (std::function< Value(Location, Type)> hook)
 
void deregisterGradientCreatorHook (std::function< Value(Location, Type)> hook)
 
Value getNewGradient (Location loc, Type t)
 
mlir::Value getDifferential (mlir::Value origv)
 
void setDiffe (mlir::Value origv, mlir::Value newv, mlir::OpBuilder &builder)
 
void zeroDiffe (mlir::Value origv, mlir::OpBuilder &builder)
 
mlir::Value diffe (mlir::Value origv, mlir::OpBuilder &builder)
 
 MDiffeGradientUtils (MEnzymeLogic &Logic, FunctionOpInterface newFunc_, FunctionOpInterface oldFunc_, MTypeAnalysis &TA, MTypeResults TR, IRMapping &invertedPointers_, const llvm::ArrayRef< bool > returnPrimals, const llvm::ArrayRef< bool > returnShadows, const SmallPtrSetImpl< mlir::Value > &constantvalues_, const SmallPtrSetImpl< mlir::Value > &activevals_, ArrayRef< DIFFE_TYPE > RetActivity, ArrayRef< DIFFE_TYPE > ArgActivity, IRMapping &origToNew_, std::map< Operation *, Operation * > &origToNewOps_, DerivativeMode mode, unsigned width, bool omp, llvm::StringRef postpasses, bool verifyPostPasses, bool strongZero)
 
- Public Member Functions inherited from mlir::enzyme::MGradientUtils
SmallVector< mlir::Value, 1 > getNewFromOriginal (ValueRange originst) const
 
mlir::Value getNewFromOriginal (const mlir::Value originst) const
 
mlir::Block * getNewFromOriginal (mlir::Block *originst) const
 
Operation * getNewFromOriginal (Operation *originst) const
 
 MGradientUtils (MEnzymeLogic &Logic, FunctionOpInterface newFunc_, FunctionOpInterface oldFunc_, MTypeAnalysis &TA_, MTypeResults TR_, IRMapping &invertedPointers_, const llvm::ArrayRef< bool > returnPrimals, const llvm::ArrayRef< bool > returnShadows, const SmallPtrSetImpl< mlir::Value > &constantvalues_, const SmallPtrSetImpl< mlir::Value > &activevals_, ArrayRef< DIFFE_TYPE > ReturnActivities, ArrayRef< DIFFE_TYPE > ArgDiffeTypes_, IRMapping &originalToNewFn_, std::map< Operation *, Operation * > &originalToNewFnOps_, DerivativeMode mode, unsigned width, bool omp, llvm::StringRef postpasses, bool verifyPostPasses, bool strongZero)
 
void erase (Operation *op)
 
void replaceOrigOpWith (Operation *op, ValueRange vals)
 
void eraseIfUnused (Operation *op, bool erase=true, bool check=true)
 
bool isConstantInstruction (mlir::Operation *v) const
 
bool isConstantValue (mlir::Value v) const
 
mlir::Value invertPointerM (mlir::Value v, OpBuilder &Builder2)
 
void forceAugmentedReturns ()
 
Operation * cloneWithNewOperands (OpBuilder &B, Operation *op)
 
LogicalResult visitChild (Operation *op)
 
void setDiffe (mlir::Value origv, mlir::Value newv, mlir::OpBuilder &builder)
 
void setInvertedPointer (mlir::Value origv, mlir::Value newv)
 
mlir::Type getShadowType (mlir::Type T)
 

Static Public Member Functions

static MGradientUtilsReverseCreateFromClone (MEnzymeLogic &Logic, DerivativeMode mode_, unsigned width, FunctionOpInterface todiff, MTypeAnalysis &TA, MFnTypeInfo &oldTypeInfo, const ArrayRef< bool > returnPrimals, const ArrayRef< bool > returnShadows, llvm::ArrayRef< DIFFE_TYPE > retType, llvm::ArrayRef< DIFFE_TYPE > constant_args, mlir::Type additionalArg, bool omp, llvm::StringRef postpasses, bool verifyPostPasses, bool strongZero)
 
- Static Public Member Functions inherited from mlir::enzyme::MDiffeGradientUtils
static MDiffeGradientUtilsCreateFromClone (MEnzymeLogic &Logic, DerivativeMode mode, unsigned width, FunctionOpInterface todiff, MTypeAnalysis &TA, MFnTypeInfo &oldTypeInfo, const llvm::ArrayRef< bool > returnPrimals, const llvm::ArrayRef< bool > returnShadows, ArrayRef< DIFFE_TYPE > RetActivity, ArrayRef< DIFFE_TYPE > ArgActivity, mlir::Type additionalArg, bool omp, llvm::StringRef postpasses, bool verifyPostPasses, bool strongZero)
 
- Static Public Member Functions inherited from mlir::enzyme::MGradientUtils
static llvm::SmallVector< mlir::Value, 1 > reindex_arguments (llvm::ArrayRef< mlir::Value > vals, mlir::OperandRange range)
 

Public Attributes

IRMapping mapReverseModeBlocks
 
SmallVector< std::function< std::pair< Value, Value >(Type)> > cacheCreatorHook
 
- Public Attributes inherited from mlir::enzyme::MGradientUtils
FunctionOpInterface newFunc
 
MEnzymeLogicLogic
 
bool AtomicAdd
 
DerivativeMode mode
 
FunctionOpInterface oldFunc
 
IRMapping invertedPointers
 
IRMapping originalToNewFn
 
std::map< Operation *, Operation * > originalToNewFnOps
 
SmallPtrSet< Block *, 4 > blocksNotForAnalysis
 
DenseMap< Operation *, bool > readOnlyCache
 
std::unique_ptr< enzyme::ActivityAnalyzeractivityAnalyzer
 
MTypeAnalysisTA
 
MTypeResults TR
 
bool omp
 
bool verifyPostPasses
 
llvm::StringRef postpasses
 
bool strongZero
 
const llvm::ArrayRef< bool > returnPrimals
 
const llvm::ArrayRef< bool > returnShadows
 
unsigned width
 
ArrayRef< DIFFE_TYPEArgDiffeTypes
 
ArrayRef< DIFFE_TYPERetDiffeTypes
 

Additional Inherited Members

- Protected Attributes inherited from mlir::enzyme::MDiffeGradientUtils
IRMapping differentials
 
Block * initializationBlock
 
SmallVector< std::function< Value(Location, Type)> > gradientCreatorHook
 

Detailed Description

Definition at line 26 of file GradientUtilsReverse.h.

Constructor & Destructor Documentation

◆ MGradientUtilsReverse()

mlir::enzyme::MGradientUtilsReverse::MGradientUtilsReverse ( MEnzymeLogic & Logic,
FunctionOpInterface newFunc_,
FunctionOpInterface oldFunc_,
MTypeAnalysis & TA_,
IRMapping invertedPointers_,
const llvm::ArrayRef< bool > returnPrimals,
const llvm::ArrayRef< bool > returnShadows,
const SmallPtrSetImpl< mlir::Value > & constantvalues_,
const SmallPtrSetImpl< mlir::Value > & activevals_,
ArrayRef< DIFFE_TYPE > ReturnActivity,
ArrayRef< DIFFE_TYPE > ArgDiffeTypes_,
IRMapping & originalToNewFn_,
std::map< Operation *, Operation * > & originalToNewFnOps_,
DerivativeMode mode_,
unsigned width,
bool omp,
llvm::StringRef postpasses,
bool verifyPostPasses,
bool strongZero )

Definition at line 30 of file GradientUtilsReverse.cpp.

Referenced by CreateFromClone().

Member Function Documentation

◆ addToDiffe()

void mlir::enzyme::MGradientUtilsReverse::addToDiffe ( mlir::Value oldGradient,
mlir::Value addedGradient,
OpBuilder & builder )

◆ cloneWithNewOperands()

Operation * mlir::enzyme::MGradientUtilsReverse::cloneWithNewOperands ( OpBuilder & B,
Operation * op )

Definition at line 108 of file GradientUtilsReverse.cpp.

◆ CreateFromClone()

◆ createReverseModeBlocks()

void MGradientUtilsReverse::createReverseModeBlocks ( Region & oldFunc,
Region & newFunc )

◆ deregisterCacheCreatorHook()

void MGradientUtilsReverse::deregisterCacheCreatorHook ( std::function< std::pair< Value, Value >(Type)> hook)

Definition at line 78 of file GradientUtilsReverse.cpp.

References cacheCreatorHook.

Referenced by mlir::enzyme::MEnzymeLogic::differentiate().

◆ getCacheType()

Type mlir::enzyme::MGradientUtilsReverse::getCacheType ( Type t)

Definition at line 65 of file GradientUtilsReverse.cpp.

Referenced by initAndPushCache().

◆ getIndexCacheType()

Type mlir::enzyme::MGradientUtilsReverse::getIndexCacheType ( )

◆ getIndexType()

Type mlir::enzyme::MGradientUtilsReverse::getIndexType ( )

◆ getNewCache()

std::pair< Value, Value > MGradientUtilsReverse::getNewCache ( Type t)

Definition at line 85 of file GradientUtilsReverse.cpp.

References cacheCreatorHook, and insertInit().

Referenced by initAndPushCache().

◆ initAndPushCache()

Value MGradientUtilsReverse::initAndPushCache ( Value v,
OpBuilder & builder )

Definition at line 95 of file GradientUtilsReverse.cpp.

References getCacheType(), getNewCache(), and popCache().

Referenced by AutoDiffCallRev::cacheValues().

◆ insertInit()

Value mlir::enzyme::MGradientUtilsReverse::insertInit ( Type t)

◆ popCache()

Value MGradientUtilsReverse::popCache ( Value cache,
OpBuilder & builder )

◆ registerCacheCreatorHook()

void MGradientUtilsReverse::registerCacheCreatorHook ( std::function< std::pair< Value, Value >(Type)> hook)

Definition at line 71 of file GradientUtilsReverse.cpp.

References cacheCreatorHook.

Referenced by mlir::enzyme::MEnzymeLogic::differentiate().

Member Data Documentation

◆ cacheCreatorHook

SmallVector<std::function<std::pair<Value, Value>(Type)> > mlir::enzyme::MGradientUtilsReverse::cacheCreatorHook

◆ mapReverseModeBlocks

IRMapping mlir::enzyme::MGradientUtilsReverse::mapReverseModeBlocks

The documentation for this class was generated from the following files: