Skip to content

Commit

Permalink
Add finalized keywords for autodiff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yong He committed May 12, 2023
1 parent 65103bc commit 32010d9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions source/slang/core.meta.slang
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ attribute_syntax [ForwardDifferentiable] : ForwardDifferentiableAttribute;
/// Marks a function for backward-mode differentiation.
__attributeTarget(FunctionDeclBase)
attribute_syntax [BackwardDifferentiable] : BackwardDifferentiableAttribute;
__attributeTarget(FunctionDeclBase)
attribute_syntax [Differentiable(order:int = 0)] : BackwardDifferentiableAttribute;


/// Interface to denote types as differentiable.
/// Allows for user-specified differential types as
Expand Down
4 changes: 2 additions & 2 deletions source/slang/slang-ast-support-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ Expr* getInnerMostExprFromHigherOrderExpr(Expr* expr, FunctionDifferentiableLeve
UnownedStringSlice getHigherOrderOperatorName(HigherOrderInvokeExpr* expr)
{
if (as<ForwardDifferentiateExpr>(expr))
return UnownedStringSlice("__fwd_diff");
return UnownedStringSlice("fwd_diff");
else if (as<BackwardDifferentiateExpr>(expr))
return UnownedStringSlice("__bwd_diff");
return UnownedStringSlice("bwd_diff");
return UnownedStringSlice();
}
}
2 changes: 2 additions & 0 deletions source/slang/slang-parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6850,6 +6850,8 @@ namespace Slang
_makeParseExpr("__TaggedUnion", parseTaggedUnionType),
_makeParseExpr("__fwd_diff", parseForwardDifferentiate),
_makeParseExpr("__bwd_diff", parseBackwardDifferentiate),
_makeParseExpr("fwd_diff", parseForwardDifferentiate),
_makeParseExpr("bwd_diff", parseBackwardDifferentiate),
_makeParseExpr("__dispatch_kernel", parseDispatchKernel)
};

Expand Down

0 comments on commit 32010d9

Please sign in to comment.