From 5d0fe48c01e84f2f6247145ea92da9a63ce03734 Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Wed, 5 Apr 2023 14:08:04 -0400 Subject: 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 --- source/slang/slang-ir-autodiff.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source') 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(item->getConcreteType())) + { + differentiableWitnessDictionary.AddIfNotExists( + (IRType*)_lookupWitness(&subBuilder, item->getWitness(), sharedContext->differentialAssocTypeStructKey), + item->getWitness()); + } + if (auto diffPairType = as(item->getConcreteType())) { // For differential pair types, register the differential type as well. -- cgit v1.2.3