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

#include "MLIR/Interfaces/GradientUtils.h"

Inheritance diagram for mlir::enzyme::MDiffeGradientUtils:
Collaboration diagram for mlir::enzyme::MDiffeGradientUtils:

Public Member Functions

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
 
DIFFE_TYPE getDiffeTypeOfBase (mlir::Value ptr)
 The activity the caller declared for the memory this pointer views: the base's entry in ArgDiffeTypes when the base is an argument of the function being differentiated, DUP_ARG otherwise.
 
bool primalStoreElidable (mlir::Value ptr)
 True when a primal store through this pointer may be omitted: declaring the base enzyme_dupnoneed is the caller saying nothing – itself included – needs the primal contents of that memory.
 
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 MDiffeGradientUtils * CreateFromClone (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 mlir::Value getBaseObject (mlir::Value v)
 The base allocation a pointer-like value views: view-like ops and LLVM geps and casts peeled away, the way LLVM's getUnderlyingObject does.
 
static llvm::SmallVector< mlir::Value, 1 > reindex_arguments (llvm::ArrayRef< mlir::Value > vals, mlir::OperandRange range)
 

Protected Attributes

IRMapping differentials
 
Block * initializationBlock
 
SmallVector< std::function< Value(Location, Type)> > gradientCreatorHook
 

Additional Inherited Members

- Public Attributes inherited from mlir::enzyme::MGradientUtils
FunctionOpInterface newFunc
 
MEnzymeLogic & Logic
 
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::ActivityAnalyzer > activityAnalyzer
 
std::unique_ptr< DataFlowSolver > dataflowSolver
 
std::unique_ptr< enzyme::DataFlowActivityAnalyzer > dataflowActivityAnalyzer
 
MTypeAnalysis & TA
 
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_TYPE > ArgDiffeTypes
 
ArrayRef< DIFFE_TYPE > RetDiffeTypes
 

Detailed Description

Definition at line 132 of file GradientUtils.h.

Constructor & Destructor Documentation

◆ MDiffeGradientUtils()

mlir::enzyme::MDiffeGradientUtils::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 )
inline

Definition at line 152 of file GradientUtils.h.

Member Function Documentation

◆ CreateFromClone()

static MDiffeGradientUtils * mlir::enzyme::MDiffeGradientUtils::CreateFromClone ( 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 )
inlinestatic

Definition at line 173 of file GradientUtils.h.

◆ deregisterGradientCreatorHook()

void MDiffeGradientUtils::deregisterGradientCreatorHook ( std::function< Value(Location, Type)> hook)

Definition at line 166 of file GradientUtils.cpp.

References gradientCreatorHook.

◆ diffe()

◆ getDifferential()

mlir::Value mlir::enzyme::MDiffeGradientUtils::getDifferential ( mlir::Value origv)

Definition at line 190 of file GradientUtils.cpp.

Referenced by mlir::enzyme::localizeGradients().

◆ getNewGradient()

Value MDiffeGradientUtils::getNewGradient ( Location loc,
Type t )

◆ registerGradientCreatorHook()

void MDiffeGradientUtils::registerGradientCreatorHook ( std::function< Value(Location, Type)> hook)

Definition at line 160 of file GradientUtils.cpp.

References gradientCreatorHook.

◆ setDiffe()

void mlir::enzyme::MDiffeGradientUtils::setDiffe ( mlir::Value origv,
mlir::Value newv,
mlir::OpBuilder & builder )

◆ zeroDiffe()

Member Data Documentation

◆ differentials

IRMapping mlir::enzyme::MDiffeGradientUtils::differentials
protected

Definition at line 134 of file GradientUtils.h.

◆ gradientCreatorHook

SmallVector<std::function<Value(Location, Type)> > mlir::enzyme::MDiffeGradientUtils::gradientCreatorHook
protected

◆ initializationBlock

Block* mlir::enzyme::MDiffeGradientUtils::initializationBlock
protected

Definition at line 136 of file GradientUtils.h.

Referenced by getNewGradient().


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