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

#include "MLIR/Interfaces/GradientUtils.h"

Inheritance diagram for mlir::enzyme::MGradientUtils:
Collaboration diagram for mlir::enzyme::MGradientUtils:

Public Member Functions

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 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)
 

Public Attributes

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 20 of file GradientUtils.h.

Constructor & Destructor Documentation

◆ MGradientUtils()

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

Definition at line 35 of file GradientUtils.cpp.

References Logic, and mlir::enzyme::MEnzymeLogic::solver.

Member Function Documentation

◆ cloneWithNewOperands()

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

Definition at line 115 of file GradientUtils.cpp.

◆ erase()

◆ eraseIfUnused()

void mlir::enzyme::MGradientUtils::eraseIfUnused ( Operation * op,
bool erase = true,
bool check = true )
inline

Definition at line 85 of file GradientUtils.h.

Referenced by mlir::enzyme::detail::allocationForwardHandler().

◆ forceAugmentedReturns()

void mlir::enzyme::MGradientUtils::forceAugmentedReturns ( )

◆ getBaseObject()

Value MGradientUtils::getBaseObject ( mlir::Value v)
static

The base allocation a pointer-like value views: view-like ops and LLVM geps and casts peeled away, the way LLVM's getUnderlyingObject does.

Definition at line 352 of file GradientUtils.cpp.

References mlir::enzyme::oputils::getBaseObject().

Referenced by getDiffeTypeOfBase().

◆ getDiffeTypeOfBase()

DIFFE_TYPE MGradientUtils::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.

Definition at line 356 of file GradientUtils.cpp.

References ArgDiffeTypes, DUP_ARG, getBaseObject(), and oldFunc.

Referenced by mlir::enzyme::detail::callForwardHandler(), mlir::enzyme::detail::callReverseHandler(), and primalStoreElidable().

◆ getNewFromOriginal() [1/4]

mlir::Value mlir::enzyme::MGradientUtils::getNewFromOriginal ( const mlir::Value originst) const

Definition at line 67 of file GradientUtils.cpp.

◆ getNewFromOriginal() [2/4]

Block * mlir::enzyme::MGradientUtils::getNewFromOriginal ( mlir::Block * originst) const

Definition at line 88 of file GradientUtils.cpp.

◆ getNewFromOriginal() [3/4]

Operation * mlir::enzyme::MGradientUtils::getNewFromOriginal ( Operation * originst) const

Definition at line 99 of file GradientUtils.cpp.

◆ getNewFromOriginal() [4/4]

◆ getShadowType()

mlir::Type mlir::enzyme::MGradientUtils::getShadowType ( mlir::Type T)
inline

◆ invertPointerM()

◆ isConstantInstruction()

bool mlir::enzyme::MGradientUtils::isConstantInstruction ( mlir::Operation * v) const

Definition at line 123 of file GradientUtils.cpp.

Referenced by isFullyInactive(), and visitChild().

◆ isConstantValue()

◆ primalStoreElidable()

bool mlir::enzyme::MGradientUtils::primalStoreElidable ( mlir::Value ptr)
inline

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.

Definition at line 103 of file GradientUtils.h.

References DUP_NONEED, and getDiffeTypeOfBase().

Referenced by mlir::enzyme::detail::memoryIdentityForwardHandler().

◆ reindex_arguments()

static llvm::SmallVector< mlir::Value, 1 > mlir::enzyme::MGradientUtils::reindex_arguments ( llvm::ArrayRef< mlir::Value > vals,
mlir::OperandRange range )
inlinestatic

Definition at line 122 of file GradientUtils.h.

◆ replaceOrigOpWith()

◆ setDiffe()

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

◆ setInvertedPointer()

void mlir::enzyme::MGradientUtils::setInvertedPointer ( mlir::Value origv,
mlir::Value newv )

Definition at line 260 of file GradientUtils.cpp.

References getShadowType().

Referenced by mlir::enzyme::detail::allocationForwardHandler().

◆ visitChild()

LogicalResult MGradientUtils::visitChild ( Operation * op)

Member Data Documentation

◆ activityAnalyzer

std::unique_ptr<enzyme::ActivityAnalyzer> mlir::enzyme::MGradientUtils::activityAnalyzer

Definition at line 35 of file GradientUtils.h.

◆ ArgDiffeTypes

ArrayRef<DIFFE_TYPE> mlir::enzyme::MGradientUtils::ArgDiffeTypes

Definition at line 54 of file GradientUtils.h.

Referenced by getDiffeTypeOfBase().

◆ AtomicAdd

bool mlir::enzyme::MGradientUtils::AtomicAdd

◆ blocksNotForAnalysis

SmallPtrSet<Block *, 4> mlir::enzyme::MGradientUtils::blocksNotForAnalysis

Definition at line 33 of file GradientUtils.h.

◆ dataflowActivityAnalyzer

std::unique_ptr<enzyme::DataFlowActivityAnalyzer> mlir::enzyme::MGradientUtils::dataflowActivityAnalyzer

Definition at line 42 of file GradientUtils.h.

◆ dataflowSolver

std::unique_ptr<DataFlowSolver> mlir::enzyme::MGradientUtils::dataflowSolver

Definition at line 41 of file GradientUtils.h.

◆ invertedPointers

◆ Logic

◆ mode

DerivativeMode mlir::enzyme::MGradientUtils::mode

Definition at line 27 of file GradientUtils.h.

Referenced by visitChild().

◆ newFunc

◆ oldFunc

FunctionOpInterface mlir::enzyme::MGradientUtils::oldFunc

◆ omp

◆ originalToNewFn

IRMapping mlir::enzyme::MGradientUtils::originalToNewFn

◆ originalToNewFnOps

◆ postpasses

llvm::StringRef mlir::enzyme::MGradientUtils::postpasses

◆ readOnlyCache

DenseMap<Operation *, bool> mlir::enzyme::MGradientUtils::readOnlyCache

Definition at line 34 of file GradientUtils.h.

◆ RetDiffeTypes

ArrayRef<DIFFE_TYPE> mlir::enzyme::MGradientUtils::RetDiffeTypes

Definition at line 55 of file GradientUtils.h.

Referenced by mlir::enzyme::detail::returnReverseHandler().

◆ returnPrimals

const llvm::ArrayRef<bool> mlir::enzyme::MGradientUtils::returnPrimals

◆ returnShadows

const llvm::ArrayRef<bool> mlir::enzyme::MGradientUtils::returnShadows

◆ strongZero

◆ TA

◆ TR

MTypeResults mlir::enzyme::MGradientUtils::TR

Definition at line 45 of file GradientUtils.h.

◆ verifyPostPasses

bool mlir::enzyme::MGradientUtils::verifyPostPasses

◆ width


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