From 47715e625337d489f3c0131bbc2b849378b48a5a Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 20 Feb 2023 14:42:50 -0800 Subject: Miscellaneous backward autodiff fixes. (#2665) * Fix differentiable type registration * Fix use of non-differentiable return value in a differentiable func. * Fix use of primal inst that does not dominate the diff block. * Fix primal inst hoisting, and add missing type legalization logic. * Make `detach` defined on all differentiable T. --------- Co-authored-by: Yong He --- source/slang/slang-check-expr.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'source/slang/slang-check-expr.cpp') diff --git a/source/slang/slang-check-expr.cpp b/source/slang/slang-check-expr.cpp index 75a3c2ff1..3567e2593 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -1024,6 +1024,23 @@ namespace Slang }); } } + for (auto subst = declRefType->declRef.substitutions.substitutions; subst; subst = subst->outer) + { + if (auto genSubst = as(subst)) + { + for (auto arg : genSubst->getArgs()) + { + if (auto typeArg = as(arg)) + { + maybeRegisterDifferentiableTypeRecursive(m_astBuilder, typeArg, workingSet); + } + } + } + else if (auto thisSubst = as(subst)) + { + maybeRegisterDifferentiableTypeRecursive(m_astBuilder, thisSubst->witness->sub, workingSet); + } + } return; } } -- cgit v1.2.3