summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-autodiff-transcriber-base.cpp
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2025-03-14 17:15:36 -0700
committerGitHub <noreply@github.com>2025-03-15 00:15:36 +0000
commit78517dc392f0d2ebba25f0ac3f4d4e004b0f0ab0 (patch)
tree104b48da3fc54e43cd7c5ce51cc66b4e2dc26d55 /source/slang/slang-ir-autodiff-transcriber-base.cpp
parentc8c9e424e91e72e718529ed76df14f7586624cd6 (diff)
Fix lowering of associated types in generic interfaces (#6600)
* Fix lowering of associated types in generic interfaces. * Update diff-assoctype-generic-interface.slang * Fix-up lowering of differentiable witnesses for implicit ops * Update slang-ir-autodiff-transcriber-base.cpp * Fix issue with differentiating type-packs
Diffstat (limited to 'source/slang/slang-ir-autodiff-transcriber-base.cpp')
-rw-r--r--source/slang/slang-ir-autodiff-transcriber-base.cpp36
1 files changed, 4 insertions, 32 deletions
diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp
index 8356e5f81..d67d75997 100644
--- a/source/slang/slang-ir-autodiff-transcriber-base.cpp
+++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp
@@ -720,9 +720,7 @@ IRInst* AutoDiffTranscriberBase::getDifferentialZeroOfType(IRBuilder* builder, I
if (auto diffType = differentiateType(builder, originalType))
{
- IRInst* diffWitnessTable = nullptr;
- IRType* diffOuterType = nullptr;
- if (isExistentialType(diffType))
+ if (isExistentialType(diffType) && !as<IRLookupWitnessMethod>(diffType))
{
// Emit null differential & pack it into an IDifferentiable existential.
@@ -789,25 +787,8 @@ IRInst* AutoDiffTranscriberBase::getDifferentialZeroOfType(IRBuilder* builder, I
return result;
}
- // Since primalType has a corresponding differential type, we can lookup the
- // definition for zero().
- IRInst* zeroMethod = nullptr;
- if (auto lookupInterface = as<IRLookupWitnessMethod>(diffType))
- {
- // if the differential type itself comes from a witness lookup, we can just lookup the
- // zero method from the same witness table.
- auto wt = lookupInterface->getWitnessTable();
- zeroMethod = builder->emitLookupInterfaceMethodInst(
- builder->getFuncType(List<IRType*>(), diffType),
- wt,
- autoDiffSharedContext->zeroMethodStructKey);
- builder->markInstAsPrimal(zeroMethod);
- }
- else
- {
- zeroMethod =
- differentiableTypeConformanceContext.getZeroMethodForType(builder, originalType);
- }
+ auto zeroMethod =
+ differentiableTypeConformanceContext.getZeroMethodForType(builder, originalType);
SLANG_RELEASE_ASSERT(zeroMethod);
auto emptyArgList = List<IRInst*>();
@@ -815,16 +796,7 @@ IRInst* AutoDiffTranscriberBase::getDifferentialZeroOfType(IRBuilder* builder, I
auto callInst = builder->emitCallInst((IRType*)diffType, zeroMethod, emptyArgList);
builder->markInstAsDifferential(callInst, primalType);
- if (diffOuterType && isExistentialType(diffOuterType))
- {
- // Need to wrap the result back into an existential.
- auto existentialZero =
- builder->emitMakeExistential(diffOuterType, callInst, diffWitnessTable);
- builder->markInstAsDifferential(existentialZero, primalType);
- return existentialZero;
- }
- else
- return callInst;
+ return callInst;
}
else
{