Skip to content

Commit

Permalink
Rename ForwardModeAdjoint to ForwardModeTangent to stay in line with …
Browse files Browse the repository at this point in the history
…literature. (rust-lang#933)

Co-authored-by: Tim Gymnich <timgymnich@me.com>
  • Loading branch information
ludgerpaehler and tgymnich committed Dec 1, 2022
1 parent dddf6c6 commit ccfb103
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
Expand Up @@ -25,7 +25,7 @@ namespace {
struct MulFOpInterface
: public AutoDiffOpInterface::ExternalModel<MulFOpInterface,
arith::MulFOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
// Derivative of r = a * b -> dr = a * db + da * b
auto mulOp = cast<arith::MulFOp>(op);
Expand Down Expand Up @@ -53,7 +53,7 @@ struct MulFOpInterface
struct AddFOpInterface
: public AutoDiffOpInterface::ExternalModel<AddFOpInterface,
arith::AddFOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
// Derivative of r = a + b -> dr = da + db
auto addOp = cast<arith::AddFOp>(op);
Expand Down
Expand Up @@ -25,7 +25,7 @@ using namespace mlir::enzyme;
namespace {
struct LoadOpInterface
: public AutoDiffOpInterface::ExternalModel<LoadOpInterface, LLVM::LoadOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
auto loadOp = cast<LLVM::LoadOp>(op);
if (!gutils->isConstantValue(loadOp)) {
Expand All @@ -41,7 +41,7 @@ struct LoadOpInterface
struct StoreOpInterface
: public AutoDiffOpInterface::ExternalModel<StoreOpInterface,
LLVM::StoreOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
auto storeOp = cast<LLVM::StoreOp>(op);
if (!gutils->isConstantValue(storeOp.getAddr())) {
Expand All @@ -57,7 +57,7 @@ struct StoreOpInterface
struct AllocaOpInterface
: public AutoDiffOpInterface::ExternalModel<AllocaOpInterface,
LLVM::AllocaOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
auto allocOp = cast<LLVM::AllocaOp>(op);
if (!gutils->isConstantValue(allocOp)) {
Expand Down
Expand Up @@ -26,7 +26,7 @@ namespace {
struct LoadOpInterface
: public AutoDiffOpInterface::ExternalModel<LoadOpInterface,
memref::LoadOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
auto loadOp = cast<memref::LoadOp>(op);
if (!gutils->isConstantValue(loadOp)) {
Expand All @@ -46,7 +46,7 @@ struct LoadOpInterface
struct StoreOpInterface
: public AutoDiffOpInterface::ExternalModel<StoreOpInterface,
memref::StoreOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
auto storeOp = cast<memref::StoreOp>(op);
if (!gutils->isConstantValue(storeOp.getMemref())) {
Expand All @@ -65,7 +65,7 @@ struct StoreOpInterface
struct AllocOpInterface
: public AutoDiffOpInterface::ExternalModel<AllocOpInterface,
memref::AllocOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
auto allocOp = cast<memref::AllocOp>(op);
if (!gutils->isConstantValue(allocOp)) {
Expand Down
Expand Up @@ -25,7 +25,7 @@ using namespace mlir::enzyme;
namespace {
struct ForOpInterface
: public AutoDiffOpInterface::ExternalModel<ForOpInterface, scf::ForOp> {
LogicalResult createForwardModeAdjoint(Operation *op, OpBuilder &builder,
LogicalResult createForwardModeTangent(Operation *op, OpBuilder &builder,
MGradientUtils *gutils) const {
auto forOp = cast<scf::ForOp>(op);
auto nFor = cast<scf::ForOp>(gutils->getNewFromOriginal(op));
Expand Down
4 changes: 2 additions & 2 deletions enzyme/Enzyme/MLIR/Interfaces/AutoDiffOpInterface.td
Expand Up @@ -26,7 +26,7 @@ def AutoDiffOpInterface : OpInterface<"AutoDiffOpInterface"> {
let methods = [
InterfaceMethod<
/*desc=*/[{
Emits a forward-mode adjoint of the given function. All IR manipulation
Emits a forward-mode tangent of the given function. All IR manipulation
must go through the supplied arguments: `builder` is preset to insert new
IR in the correct location and should be used to construct any new IR;
`gutils` provides the mapping between main and derivative computation for
Expand All @@ -35,7 +35,7 @@ def AutoDiffOpInterface : OpInterface<"AutoDiffOpInterface"> {
was successful.
}],
/*retTy=*/"::mlir::LogicalResult",
/*methodName=*/"createForwardModeAdjoint",
/*methodName=*/"createForwardModeTangent",
/*args=*/(ins "::mlir::OpBuilder &":$builder, "::mlir::enzyme::MGradientUtils *":$gutils)
>
];
Expand Down
2 changes: 1 addition & 1 deletion enzyme/Enzyme/MLIR/Interfaces/GradientUtils.cpp
Expand Up @@ -306,7 +306,7 @@ LogicalResult MGradientUtils::visitChild(Operation *op) {
if (auto iface = dyn_cast<AutoDiffOpInterface>(op)) {
OpBuilder builder(op->getContext());
builder.setInsertionPoint(getNewFromOriginal(op));
return iface.createForwardModeAdjoint(builder, this);
return iface.createForwardModeTangent(builder, this);
}
}
return failure();
Expand Down

0 comments on commit ccfb103

Please sign in to comment.