Enzyme main
Loading...
Searching...
No Matches
DifferentialUseAnalysis.h File Reference
#include <map>
#include <set>
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Instruction.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include "DiffeGradientUtils.h"
#include "GradientUtils.h"
#include "LibraryFuncs.h"
Include dependency graph for DifferentialUseAnalysis.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DifferentialUseAnalysis::Node
 

Namespaces

namespace  DifferentialUseAnalysis
 

Typedefs

typedef std::pair< const llvm::Value *, QueryTypeUsageKey
 
using DifferentialUseAnalysis::Graph = std::map<Node, std::set<Node>>
 

Enumerations

enum class  QueryType { Primal = 0 , Shadow = 1 , ShadowByConstPrimal = 2 }
 Classification of what type of use is requested. More...
 

Functions

static std::string to_string (QueryType mode)
 
bool DifferentialUseAnalysis::is_use_directly_needed_in_reverse (const GradientUtils *gutils, const llvm::Value *val, DerivativeMode mode, const llvm::Instruction *user, const llvm::SmallPtrSetImpl< llvm::BasicBlock * > &oldUnreachable, QueryType shadow, bool *recursiveUse=nullptr)
 Determine if a value is needed directly to compute the adjoint of the given instruction user.
 
template<QueryType VT, bool OneLevel = false>
bool DifferentialUseAnalysis::is_value_needed_in_reverse (const GradientUtils *gutils, const llvm::Value *inst, DerivativeMode mode, std::map< UsageKey, bool > &seen, const llvm::SmallPtrSetImpl< llvm::BasicBlock * > &oldUnreachable)
 
template<QueryType VT>
static bool DifferentialUseAnalysis::is_value_needed_in_reverse (const GradientUtils *gutils, const llvm::Value *inst, DerivativeMode mode, const llvm::SmallPtrSetImpl< llvm::BasicBlock * > &oldUnreachable)
 
void DifferentialUseAnalysis::dump (std::map< Node, std::set< Node > > &G)
 
void DifferentialUseAnalysis::bfs (const std::map< Node, std::set< Node > > &G, const llvm::SetVector< llvm::Value * > &Recompute, std::map< Node, Node > &parent)
 
int DifferentialUseAnalysis::cmpLoopNest (llvm::Loop *prev, llvm::Loop *next)
 
void DifferentialUseAnalysis::minCut (const llvm::DataLayout &DL, llvm::LoopInfo &OrigLI, const llvm::SetVector< llvm::Value * > &Recomputes, const llvm::SetVector< llvm::Value * > &Intermediates, llvm::SetVector< llvm::Value * > &Required, llvm::SetVector< llvm::Value * > &MinReq, const GradientUtils *gutils, llvm::TargetLibraryInfo &TLI)
 
 DifferentialUseAnalysis::__attribute__ ((always_inline)) static inline void forEachDirectInsertUser(llvm
 
bool DifferentialUseAnalysis::callShouldNotUseDerivative (const GradientUtils *gutils, llvm::CallBase &orig, QueryType qtype, const llvm::Value *val)
 Return whether or not this is a constant and should use reverse pass.
 

Variables

llvm::cl::opt< bool > EnzymePrintDiffUse
 
llvm::StringMap< std::function< bool(const llvm::CallInst *, const GradientUtils *, const llvm::Value *, bool, DerivativeMode, bool &)> > customDiffUseHandlers
 

Typedef Documentation

◆ UsageKey

typedef std::pair<const llvm::Value *, QueryType> UsageKey

Definition at line 79 of file DifferentialUseAnalysis.h.

Enumeration Type Documentation

◆ QueryType

enum class QueryType
strong

Classification of what type of use is requested.

Enumerator
Primal 
Shadow 
ShadowByConstPrimal 

Definition at line 57 of file DifferentialUseAnalysis.h.

Function Documentation

◆ to_string()

static std::string to_string ( QueryType mode)
inlinestatic

Definition at line 67 of file DifferentialUseAnalysis.h.

References Primal, Shadow, and ShadowByConstPrimal.

Variable Documentation

◆ customDiffUseHandlers

llvm::StringMap< std::function<bool(const llvm::CallInst *, const GradientUtils *, const llvm::Value *, bool, DerivativeMode, bool &)> > customDiffUseHandlers
extern

Definition at line 54 of file DifferentialUseAnalysis.cpp.

Referenced by EnzymeRegisterDiffUseCallHandler().

◆ EnzymePrintDiffUse

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