summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2023-04-05 14:08:04 -0400
committerGitHub <noreply@github.com>2023-04-05 11:08:04 -0700
commit5d0fe48c01e84f2f6247145ea92da9a63ce03734 (patch)
treed0cffe5181084192ea9d9840027f2b7f7933ef8f /source
parent492c6f2fd1a64c9d60a968b55bfd1000cc2ae8e7 (diff)
Register `IDifferentiable` witnesses for the differential associated types of registered types. (#2777)
* Create high-order-forward-diff-struct.slang * Add a small pass to register differentials for differentials of registered types * Remove type reg pass and apply logic in differentiable type loading instead * Update slang-ir-autodiff.cpp * Fix comments. --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-autodiff.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp
index 024d31fd8..3257ee102 100644
--- a/source/slang/slang-ir-autodiff.cpp
+++ b/source/slang/slang-ir-autodiff.cpp
@@ -399,6 +399,16 @@ void DifferentiableTypeConformanceContext::setFunc(IRGlobalValueWithCode* func)
else
{
differentiableWitnessDictionary.Add((IRType*)item->getConcreteType(), item->getWitness());
+
+ // Also register the type's differential type with the same witness.
+ IRBuilder subBuilder(item->getConcreteType());
+ if (!as<IRInterfaceType>(item->getConcreteType()))
+ {
+ differentiableWitnessDictionary.AddIfNotExists(
+ (IRType*)_lookupWitness(&subBuilder, item->getWitness(), sharedContext->differentialAssocTypeStructKey),
+ item->getWitness());
+ }
+
if (auto diffPairType = as<IRDifferentialPairTypeBase>(item->getConcreteType()))
{
// For differential pair types, register the differential type as well.