From 228e71dab7dfa18ece979f4099ec0c7d1e37e5ff Mon Sep 17 00:00:00 2001 From: Yong He Date: Fri, 3 Feb 2023 16:44:33 -0800 Subject: Overhaul `transposeParameterBlock` to support `inout` params. (#2621) * Overhaul `transposeParameterBlock` to support `inout` params. * Small bug fixes. * Bug fix on differentiable intrinsic specialization. * Fixes. * Run autodiff tests on CPU. * Clean up. * More bug fixes., * Add test coverage on inout param. * Fix language server hinting for transcribed mutable params. --------- 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 b89eb85c4..a52a08f15 100644 --- a/source/slang/slang-check-expr.cpp +++ b/source/slang/slang-check-expr.cpp @@ -478,6 +478,7 @@ namespace Slang if (!parent) return nullptr; + // If we reach here, we are expecting a synthesized decl defined in `subType`. // Instead of returning a DeclRefExpr to the requirement decl, we synthesize a placeholder decl // in `subType` and return a DeclRefExpr to the synthesized decl. @@ -862,6 +863,15 @@ namespace Slang if (auto declRefType = as(type)) { + if (auto builtinRequirement = declRefType->declRef.getDecl()->findModifier()) + { + if (builtinRequirement->kind == BuiltinRequirementKind::DifferentialType) + { + // We are trying to get differential type from a differential type. + // The result is itself. + return type; + } + } if (auto witness = as(tryGetInterfaceConformanceWitness(type, builder->getDifferentiableInterface()))) { auto diffTypeLookupResult = lookUpMember( @@ -2328,6 +2338,13 @@ namespace Slang { for (auto param : funcDecl->getParameters()) { + if (param->findModifier()) + { + if (param->findModifier() && + !param->findModifier() && + !param->findModifier()) + continue; + } resultDiffExpr->newParameterNames.add(param->getName()); } resultDiffExpr->newParameterNames.add(semantics->getName("resultGradient")); -- cgit v1.2.3