summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-autodiff.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-01-30 19:24:09 -0800
committerGitHub <noreply@github.com>2023-01-30 19:24:09 -0800
commit499b0253c224e68ceed6e5b6b1ee9cd7d65aad0f (patch)
tree4c570a36d305c8909d633183694e0d1225f044c2 /source/slang/slang-ir-autodiff.cpp
parent134dd7eb26fc7988ae13559d276cbf337b4b9d27 (diff)
Make ArrayExpressionType a DeclRefType and define its autodiff extension in stdlib. (#2615)
* Allow array parameters in forward diff. * Use type canonicalization instead of coersion. * Reimplement array type. * Fix. * Update test case. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-autodiff.cpp')
-rw-r--r--source/slang/slang-ir-autodiff.cpp26
1 files changed, 1 insertions, 25 deletions
diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp
index ae8359251..8952f9756 100644
--- a/source/slang/slang-ir-autodiff.cpp
+++ b/source/slang/slang-ir-autodiff.cpp
@@ -534,31 +534,7 @@ void stripNoDiffTypeAttribute(IRModule* module)
bool isDifferentiableType(DifferentiableTypeConformanceContext& context, IRInst* typeInst)
{
- HashSet<IRInst*> processedSet;
- for (;typeInst;)
- {
- if (as<IRArrayTypeBase>(typeInst) || as<IRPtrTypeBase>(typeInst))
- {
- typeInst = typeInst->getOperand(0);
- if (!processedSet.Add(typeInst))
- return false;
- }
- else
- {
- break;
- }
- }
- if (!typeInst)
- return false;
- switch (typeInst->getOp())
- {
- case kIROp_FloatType:
- case kIROp_DifferentialPairType:
- return true;
- default:
- break;
- }
- if (context.lookUpConformanceForType(typeInst))
+ if (context.isDifferentiableType((IRType*)typeInst))
return true;
// Look for equivalent types.
for (auto type : context.differentiableWitnessDictionary)