summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-check-expr.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-02-03 16:44:33 -0800
committerGitHub <noreply@github.com>2023-02-03 16:44:33 -0800
commit228e71dab7dfa18ece979f4099ec0c7d1e37e5ff (patch)
treeff357f4aaed2dab25ae9e3665a97a7f3e6be32ef /source/slang/slang-check-expr.cpp
parentee49a62083d28353812185fd0f0c04fb50ca6be0 (diff)
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 <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-expr.cpp')
-rw-r--r--source/slang/slang-check-expr.cpp17
1 files changed, 17 insertions, 0 deletions
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<DeclRefType>(type))
{
+ if (auto builtinRequirement = declRefType->declRef.getDecl()->findModifier<BuiltinRequirementModifier>())
+ {
+ 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<SubtypeWitness>(tryGetInterfaceConformanceWitness(type, builder->getDifferentiableInterface())))
{
auto diffTypeLookupResult = lookUpMember(
@@ -2328,6 +2338,13 @@ namespace Slang
{
for (auto param : funcDecl->getParameters())
{
+ if (param->findModifier<NoDiffModifier>())
+ {
+ if (param->findModifier<OutModifier>() &&
+ !param->findModifier<InModifier>() &&
+ !param->findModifier<InOutModifier>())
+ continue;
+ }
resultDiffExpr->newParameterNames.add(param->getName());
}
resultDiffExpr->newParameterNames.add(semantics->getName("resultGradient"));