summaryrefslogtreecommitdiff
path: root/source/slang/slang-ast-support-types.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-03-07 11:22:32 -0800
committerGitHub <noreply@github.com>2023-03-07 11:22:32 -0800
commit257733f328f38a763c8b0c8830ff4c0d34ec9491 (patch)
tree87e444746f353d69a365380904f3f8caf15fbfec /source/slang/slang-ast-support-types.cpp
parent6f31eae79d5b4297d0099c5779a9806a786cf9f8 (diff)
Reuse higher-order `ResolveInvoke` logic to resolve func refs in `[*DerivativeOf]` attribs. (#2688)
* Reuse higher-order `ResolveInvoke` logic to resolve func refs in [*DerivativeOf] attribs. * Add diff implementation matrix versions of binary and ternary intrinsics. * Add diff impl for legacy intrinsics. * Fix diagnostics of using non-differentiable function in a diff operator. * Add diff implementation for `determinant`. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ast-support-types.cpp')
-rw-r--r--source/slang/slang-ast-support-types.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/source/slang/slang-ast-support-types.cpp b/source/slang/slang-ast-support-types.cpp
index aa0513569..3feed7541 100644
--- a/source/slang/slang-ast-support-types.cpp
+++ b/source/slang/slang-ast-support-types.cpp
@@ -36,11 +36,16 @@ void removeModifier(ModifiableSyntaxNode* syntax, Modifier* toRemove)
}
}
-Expr* getInnerMostExprFromHigherOrderExpr(Expr* expr)
+Expr* getInnerMostExprFromHigherOrderExpr(Expr* expr, FunctionDifferentiableLevel& outLevel)
{
HashSet<Expr*> workListSet;
+ outLevel = FunctionDifferentiableLevel::None;
while (auto higherOrder = as<HigherOrderInvokeExpr>(expr))
{
+ if (as<BackwardDifferentiateExpr>(expr))
+ outLevel = FunctionDifferentiableLevel::Backward;
+ else if (as<ForwardDifferentiateExpr>(expr) && outLevel == FunctionDifferentiableLevel::None)
+ outLevel = FunctionDifferentiableLevel::Forward;
if (workListSet.Add(higherOrder))
{
expr = higherOrder->baseFunction;