Skip to content

Commit

Permalink
add width attribute to autodiff as well
Browse files Browse the repository at this point in the history
  • Loading branch information
jumerckx committed Nov 20, 2024
1 parent c9451b0 commit a6cbcbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions enzyme/Enzyme/MLIR/Dialect/EnzymeOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def PlaceholderOp : Enzyme_Op<"placeholder",
def ForwardDiffOp : Enzyme_Op<"fwddiff",
[DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
let summary = "Perform forward mode AD on a funcop";
let arguments = (ins FlatSymbolRefAttr:$fn, Variadic<AnyType>:$inputs, ActivityArrayAttr:$activity, ActivityArrayAttr:$ret_activity, DefaultValuedAttr<I64Attr, "1">:$width); let results = (outs Variadic<AnyType>:$outputs);
let arguments = (ins FlatSymbolRefAttr:$fn, Variadic<AnyType>:$inputs, ActivityArrayAttr:$activity, ActivityArrayAttr:$ret_activity, DefaultValuedAttr<I64Attr, "1">:$width);
let results = (outs Variadic<AnyType>:$outputs);

let assemblyFormat = [{
$fn `(` $inputs `)` attr-dict `:` functional-type($inputs, results)
Expand All @@ -89,7 +90,7 @@ def ForwardDiffOp : Enzyme_Op<"fwddiff",
def AutoDiffOp : Enzyme_Op<"autodiff",
[DeclareOpInterfaceMethods<SymbolUserOpInterface>]> {
let summary = "Perform reverse mode AD on a funcop";
let arguments = (ins FlatSymbolRefAttr:$fn, Variadic<AnyType>:$inputs, ActivityArrayAttr:$activity, ActivityArrayAttr:$ret_activity);
let arguments = (ins FlatSymbolRefAttr:$fn, Variadic<AnyType>:$inputs, ActivityArrayAttr:$activity, ActivityArrayAttr:$ret_activity, DefaultValuedAttr<I64Attr, "1">:$width);
let results = (outs Variadic<AnyType>:$outputs);

let assemblyFormat = [{
Expand Down
2 changes: 1 addition & 1 deletion enzyme/Enzyme/MLIR/Passes/EnzymeMLIRPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct DifferentiatePass : public DifferentiatePassBase<DifferentiatePass> {
MTypeAnalysis TA;
auto type_args = TA.getAnalyzedTypeInfo(fn);
bool freeMemory = true;
size_t width = 1;
size_t width = CI.getWidth();

std::vector<bool> volatile_args;
for (auto &a : fn.getFunctionBody().getArguments()) {
Expand Down

0 comments on commit a6cbcbe

Please sign in to comment.