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

Helper class to analyze the differential activity. More...

#include "MLIR/Analysis/ActivityAnalysis.h"

Collaboration diagram for mlir::enzyme::ActivityAnalyzer:

Public Types

enum class  UseActivity {
  None = 0 , OnlyLoads = 1 , OnlyStores = 2 , OnlyNonPointerStores = 3 ,
  AllStores = 4
}
 

Public Member Functions

 ActivityAnalyzer (const llvm::SmallPtrSetImpl< Block * > &notForAnalysis_, llvm::DenseMap< Operation *, bool > &readOnlyCache_, const llvm::SmallPtrSetImpl< Value > &ConstantValues, const llvm::SmallPtrSetImpl< Value > &ActiveValues, llvm::ArrayRef< DIFFE_TYPE > ActiveReturns)
 Construct the analyzer from the a previous set of constant and active values and whether returns are active.
 
bool isConstantOperation (MTypeResults const &TR, Operation *op)
 Return whether this operation is known not to propagate adjoints Note that operations could return an active pointer, but do not propagate adjoints themselves.
 
bool isConstantValue (MTypeResults const &TR, Value val)
 Return whether this values is known not to contain derivative information, either directly or as a pointer to.
 
bool isReadOnly (Operation *val)
 
bool isValueInactiveFromUsers (MTypeResults const &TR, Value val, UseActivity UA, Operation **FoundInst=nullptr)
 Is the value free of any active uses.
 
bool isValueActivelyStoredOrReturned (MTypeResults const &TR, Value val, bool outside=false)
 Is the value potentially actively returned or stored.
 

Public Attributes

const llvm::ArrayRef< DIFFE_TYPE > ActiveReturns
 Library Information.
 

Detailed Description

Helper class to analyze the differential activity.

Definition at line 56 of file ActivityAnalysis.h.

Member Enumeration Documentation

◆ UseActivity

Enumerator
None 
OnlyLoads 
OnlyStores 
OnlyNonPointerStores 
AllStores 

Definition at line 203 of file ActivityAnalysis.h.

Constructor & Destructor Documentation

◆ ActivityAnalyzer()

mlir::enzyme::ActivityAnalyzer::ActivityAnalyzer ( const llvm::SmallPtrSetImpl< Block * > & notForAnalysis_,
llvm::DenseMap< Operation *, bool > & readOnlyCache_,
const llvm::SmallPtrSetImpl< Value > & ConstantValues,
const llvm::SmallPtrSetImpl< Value > & ActiveValues,
llvm::ArrayRef< DIFFE_TYPE > ActiveReturns )
inline

Construct the analyzer from the a previous set of constant and active values and whether returns are active.

The all arguments of the functions being analyzed must be in the set of constant and active values, lest an error occur during analysis

Definition at line 108 of file ActivityAnalysis.h.

Member Function Documentation

◆ isConstantOperation()

bool ActivityAnalyzer::isConstantOperation ( MTypeResults const & TR,
Operation * I )

Return whether this operation is known not to propagate adjoints Note that operations could return an active pointer, but do not propagate adjoints themselves.

Call the function propagateFromOperand on all operands of CI that could impact the activity of the call instruction.

Return whether this operation is known not to propagate adjoints Note that operation could return an active pointer, but do not propagate adjoints themselves

Previously computed inactives remain inactive

A store into all integral memory is inactive

Definition at line 723 of file ActivityAnalysis.cpp.

References EnzymePrintActivity, getFunctionFromCall(), mlir::enzyme::isFunctionReturnLike(), and KnownInactiveFunctionInsts.

◆ isConstantValue()

◆ isReadOnly()

bool ActivityAnalyzer::isReadOnly ( Operation * val)

Definition at line 504 of file ActivityAnalysis.cpp.

References isReadOnly().

◆ isValueActivelyStoredOrReturned()

bool ActivityAnalyzer::isValueActivelyStoredOrReturned ( MTypeResults const & TR,
Value val,
bool outside = false )

Is the value potentially actively returned or stored.

Definition at line 3649 of file ActivityAnalysis.cpp.

References EnzymePrintActivity.

◆ isValueInactiveFromUsers()

bool ActivityAnalyzer::isValueInactiveFromUsers ( MTypeResults const & TR,
Value val,
UseActivity UA,
Operation ** FoundInst = nullptr )

Is the value free of any active uses.

Definition at line 3035 of file ActivityAnalysis.cpp.

References CONSTANT, EnzymePrintActivity, getFunctionFromCall(), getPotentialTerminatorUsers(), isFunctionReturn(), and isReadOnly().

Member Data Documentation

◆ ActiveReturns

const llvm::ArrayRef<DIFFE_TYPE> mlir::enzyme::ActivityAnalyzer::ActiveReturns

Library Information.

Whether the returns of the function being analyzed are active

Definition at line 73 of file ActivityAnalysis.h.


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