summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-autodiff-rev.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-09-28 18:07:40 -0700
committerGitHub <noreply@github.com>2023-09-28 18:07:40 -0700
commitb7d318f48db2cb83a41d665f1727ae93fc555124 (patch)
treed81d69cbba264cd059bbe67f29235226032c4793 /source/slang/slang-ir-autodiff-rev.cpp
parente7238942ea003e134b325fa65296df8e19368e90 (diff)
Support `constref` parameters passing. (#3249)
* Support `constref` parameters passing. * Fix. * Fix. * Add test and diagnostic on mix use of __constref and no_diff. * check for [constref] on differentiable member method. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-autodiff-rev.cpp')
-rw-r--r--source/slang/slang-ir-autodiff-rev.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp
index 335b6572e..ed70862d1 100644
--- a/source/slang/slang-ir-autodiff-rev.cpp
+++ b/source/slang/slang-ir-autodiff-rev.cpp
@@ -415,9 +415,9 @@ namespace Slang
// Fetch primal values to use as arguments in primal func call.
IRInst* primalArg = param;
- if (!as<IROutType>(primalParamType))
+ if (!as<IROutType>(primalParamType) && !as<IRConstRefType>(primalParamType))
{
- // As long as the primal parameter is not an out type,
+ // As long as the primal parameter is not an out or constref type,
// we need to fetch the primal value from the parameter.
if (as<IRPtrTypeBase>(propagateParamType))
{
@@ -428,7 +428,7 @@ namespace Slang
primalArg = builder.emitDifferentialPairGetPrimal(primalArg);
}
}
- if (auto primalParamPtrType = as<IRPtrTypeBase>(primalParamType))
+ if (auto primalParamPtrType = isMutablePointerType(primalParamType))
{
// If primal parameter is mutable, we need to pass in a temp var.
auto tempVar = builder.emitVar(primalParamPtrType->getValueType());