3#include "mlir/Analysis/DataFlowFramework.h"
4#include "mlir/IR/IRMapping.h"
5#include "mlir/Interfaces/FunctionInterfaces.h"
8#include "../../Utils.h"
36 bool pointerIntSame =
false)
const {
37 if (isa<IntegerType, IndexType>(val.getType())) {
41 llvm_unreachable(
"something happened");
73 if (std::lexicographical_compare(
77 if (std::lexicographical_compare(
148 if (std::lexicographical_compare(rhs.
retActivity.begin(),
157 if (std::lexicographical_compare(rhs.
argActivity.begin(),
229 bool freeMemory,
size_t width, mlir::Type addedType,
230 MFnTypeInfo type_args, std::vector<bool> overwritten_args,
231 void *augmented,
bool omp, llvm::StringRef postpasses,
232 bool verifyPostPasses,
bool strongZero);
237 std::vector<bool> returnPrimals,
239 bool freeMemory,
bool atomicAdd,
size_t width,
241 std::vector<bool> overwritten_args,
void *augmented,
242 bool omp, llvm::StringRef postpasses,
bool verifyPostPasses,
243 bool strongZero,
bool markReadonly);
251 llvm::function_ref<buildReturnFunction> buildReturnOp);
254 LogicalResult
visitChild(Operation *op, OpBuilder &builder,
261 llvm::function_ref<buildReturnFunction> buildFuncRetrunOp,
262 std::function<std::pair<Value, Value>(Type)> cacheCreator);
Concrete SubType of a given value.
Class representing the underlying types of values as sequences of offsets to a ConcreteType.
void initializeShadowValues(SmallVector< mlir::Block * > &dominatorToposortBlocks, MGradientUtilsReverse *gutils)
void mapInvertArguments(Block *oBB, Block *reverseBB, MGradientUtilsReverse *gutils)
LogicalResult visitChildren(Block *oBB, Block *reverseBB, MGradientUtilsReverse *gutils)
LogicalResult visitChild(Operation *op, OpBuilder &builder, MGradientUtilsReverse *gutils)
std::map< MReverseCacheKey, FunctionOpInterface > ReverseCachedFunctions
std::unique_ptr< DataFlowSolver > solver
FunctionOpInterface CreateForwardDiff(FunctionOpInterface fn, std::vector< DIFFE_TYPE > retType, std::vector< DIFFE_TYPE > constants, MTypeAnalysis &TA, std::vector< bool > returnPrimals, DerivativeMode mode, bool freeMemory, size_t width, mlir::Type addedType, MFnTypeInfo type_args, std::vector< bool > overwritten_args, void *augmented, bool omp, llvm::StringRef postpasses, bool verifyPostPasses, bool strongZero)
MEnzymeLogic(bool dataflowActivity)
FunctionOpInterface CreateReverseDiff(FunctionOpInterface fn, std::vector< DIFFE_TYPE > retType, std::vector< DIFFE_TYPE > constants, MTypeAnalysis &TA, std::vector< bool > returnPrimals, std::vector< bool > returnShadows, DerivativeMode mode, bool freeMemory, bool atomicAdd, size_t width, mlir::Type addedType, MFnTypeInfo type_args, std::vector< bool > overwritten_args, void *augmented, bool omp, llvm::StringRef postpasses, bool verifyPostPasses, bool strongZero, bool markReadonly)
void handlePredecessors(Block *oBB, Block *newBB, Block *reverseBB, MGradientUtilsReverse *gutils, llvm::function_ref< buildReturnFunction > buildReturnOp)
std::map< MForwardCacheKey, FunctionOpInterface > ForwardCachedFunctions
LogicalResult differentiate(MGradientUtilsReverse *gutils, Region &oldRegion, Region &newRegion, llvm::function_ref< buildReturnFunction > buildFuncRetrunOp, std::function< std::pair< Value, Value >(Type)> cacheCreator)
bool operator<(const MFnTypeInfo &rhs) const
MFnTypeInfo getAnalyzedTypeInfo(FunctionOpInterface op) const
TypeTree query(Value) const
ConcreteType intType(size_t num, Value val, bool errIfNotFound=true, bool pointerIntSame=false) const
TypeTree getReturnAnalysis()
void buildReturnFunction(OpBuilder &, mlir::Block *)
const MFnTypeInfo typeInfo
FunctionOpInterface todiff
mlir::Type additionalType
const std::vector< DIFFE_TYPE > retType
const std::vector< DIFFE_TYPE > constant_args
bool operator<(const MForwardCacheKey &rhs) const
std::vector< bool > returnUsed
const std::vector< DIFFE_TYPE > argActivity
const std::vector< bool > returnPrimals
const std::vector< bool > volatileArgs
const std::vector< DIFFE_TYPE > retActivity
mlir::Type additionalType
const MFnTypeInfo typeInfo
bool operator<(const MReverseCacheKey &rhs) const
FunctionOpInterface todiff
const std::vector< bool > returnShadows