38 IRMapping &invertedPointers_,
const llvm::ArrayRef<bool> returnPrimals,
39 const llvm::ArrayRef<bool> returnShadows,
40 const SmallPtrSetImpl<mlir::Value> &constantvalues_,
41 const SmallPtrSetImpl<mlir::Value> &activevals_,
42 ArrayRef<DIFFE_TYPE> ReturnActivity, ArrayRef<DIFFE_TYPE> ArgDiffeTypes_,
43 IRMapping &originalToNewFn_,
44 std::map<Operation *, Operation *> &originalToNewFnOps_,
45 DerivativeMode mode,
unsigned width,
bool omp, llvm::StringRef postpasses,
46 bool verifyPostPasses,
bool strongZero)
47 : newFunc(newFunc_), Logic(Logic), AtomicAdd(false), mode(mode),
48 oldFunc(oldFunc_), invertedPointers(invertedPointers_),
49 originalToNewFn(originalToNewFn_),
50 originalToNewFnOps(originalToNewFnOps_), blocksNotForAnalysis(),
52 blocksNotForAnalysis, readOnlyCache, constantvalues_, activevals_,
54 TA(TA_), TR(TR_), omp(omp), verifyPostPasses(verifyPostPasses),
55 postpasses(postpasses), strongZero(strongZero),
56 returnPrimals(returnPrimals), returnShadows(returnShadows), width(width),
57 ArgDiffeTypes(ArgDiffeTypes_), RetDiffeTypes(ReturnActivity) {
59 dataflowSolver = std::make_unique<DataFlowSolver>(
60 DataFlowConfig().setInterprocedural(false));
61 dataflowActivityAnalyzer =
62 std::make_unique<enzyme::DataFlowActivityAnalyzer>(
63 *dataflowSolver, oldFunc_, ArgDiffeTypes_, ReturnActivity);
101 auto found = originalToNewFnOps.find(originst);
102 if (found == originalToNewFnOps.end()) {
103 llvm::errs() << oldFunc <<
"\n";
104 llvm::errs() << newFunc <<
"\n";
105 for (
auto &pair : originalToNewFnOps) {
106 llvm::errs() <<
" map[" << pair.first <<
"] = " << pair.second <<
"\n";
107 llvm::errs() <<
" map[" << *pair.first <<
"] = " << *pair.second <<
"\n";
109 llvm::errs() << originst <<
" - " << *originst <<
"\n";
110 llvm_unreachable(
"Could not get new op from original");
112 return found->second;
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)