Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Enzyme is a plugin that performs automatic differentiation (AD) of statically analyzable LLVM. It is highly-efficient and its ability perform AD on optimized code allows Enzyme to meet or exceed the performance of state-of-the-art AD tools.

Enzyme can be used by calling `__enzyme_autodiff_` on a function to be differentiated as shown below:
Enzyme can be used by calling `__enzyme_autodiff` on a function to be differentiated as shown below:
```c
double foo(double);

Expand All @@ -20,11 +20,11 @@ To get involved or if you have questions, please join our [mailing list](https:/

If using this code in an academic setting, please cite the following:
```
@misc{enzymeGithub,
author = {William S. Moses and Valentin Churavy},
title = {Enzyme: High Performance Automatic Differentiation of LLVM},
year = {2020},
howpublished = {\url{https://github.com/wsmoses/Enzyme}},
note = {commit xxxxxxx}
@incollection{enzymeNeurips,
title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
author = {Moses, William S. and Churavy, Valentin},
booktitle = {Advances in Neural Information Processing Systems 33},
year = {2020},
note = {To appear in},
}
```
12 changes: 6 additions & 6 deletions enzyme/Enzyme/ActiveVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/ActiveVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/AdjointGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/DifferentialUseAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
16 changes: 8 additions & 8 deletions enzyme/Enzyme/Enzyme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand All @@ -31,7 +31,6 @@

#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
//#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstrTypes.h"
Expand Down Expand Up @@ -96,7 +95,6 @@ void HandleAutoDiff(CallInst *CI, TargetLibraryInfo &TLI, AAResults &AA) {
} else if (MS == "diffe_dupnoneed") {
ty = DIFFE_TYPE::DUP_NONEED;
} else if (MS == "diffe_out") {
llvm::errs() << "saw metadata for diffe_out\n";
ty = DIFFE_TYPE::OUT_DIFF;
} else if (MS == "diffe_const") {
ty = DIFFE_TYPE::CONSTANT;
Expand Down Expand Up @@ -222,6 +220,8 @@ void HandleAutoDiff(CallInst *CI, TargetLibraryInfo &TLI, AAResults &AA) {
} else if (et->isPointerTy()) {
dt = TypeTree(ConcreteType(BaseType::Pointer)).Only(-1);
}
} else if (a.getType()->isIntOrIntVectorTy()) {
dt = ConcreteType(BaseType::Integer);
}
type_args.Arguments.insert(std::pair<Argument *, TypeTree>(&a, dt.Only(-1)));
// TODO note that here we do NOT propagate constants in type info (and
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/EnzymeLogic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/EnzymeLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/FunctionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/FunctionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/GradientUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/GradientUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
21 changes: 13 additions & 8 deletions enzyme/Enzyme/LibraryFuncs.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand All @@ -28,7 +28,8 @@
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/IR/Instructions.h"

// For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp
/// Return whether a given function is a known C/C++ memory allocation function
/// For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp
static inline bool isAllocationFunction(const llvm::Function &F,
const llvm::TargetLibraryInfo &TLI) {
using namespace llvm;
Expand Down Expand Up @@ -93,7 +94,8 @@ static inline bool isAllocationFunction(const llvm::Function &F,
}
}

// For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp
/// Return whether a given function is a known C/C++ memory deallocation function
/// For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp
static inline bool isDeallocationFunction(const llvm::Function &F,
const llvm::TargetLibraryInfo &TLI) {
using namespace llvm;
Expand Down Expand Up @@ -168,6 +170,8 @@ static inline bool isDeallocationFunction(const llvm::Function &F,
}
}

/// Perform the corresponding deallocation of tofree, given it was allocated by
/// allocationfn
// For updating below one should read MemoryBuiltins.cpp, TargetLibraryInfo.cpp
static inline llvm::CallInst *
freeKnownAllocation(llvm::IRBuilder<> &builder, llvm::Value *tofree,
Expand Down Expand Up @@ -276,6 +280,7 @@ freeKnownAllocation(llvm::IRBuilder<> &builder, llvm::Value *tofree,
return freecall;
}

/// Return whether maybeReader can read from memory written to by maybeWriter
static inline bool writesToMemoryReadBy(llvm::AAResults &AA, llvm::Instruction *maybeReader,
llvm::Instruction *maybeWriter) {
using namespace llvm;
Expand Down
12 changes: 6 additions & 6 deletions enzyme/Enzyme/TypeAnalysis/BaseType.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// If using this code in an academic setting, please cite the following:
// @misc{enzymeGithub,
// author = {William S. Moses and Valentin Churavy},
// title = {Enzyme: High Performance Automatic Differentiation of LLVM},
// year = {2020},
// howpublished = {\url{https://github.com/wsmoses/Enzyme}},
// note = {commit xxxxxxx}
// @incollection{enzymeNeurips,
// title = {Instead of Rewriting Foreign Code for Machine Learning, Automatically Synthesize Fast Gradients},
// author = {Moses, William S. and Churavy, Valentin},
// booktitle = {Advances in Neural Information Processing Systems 33},
// year = {2020},
// note = {To appear in},
// }
//
//===----------------------------------------------------------------------===//
Expand Down
Loading