summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2023-09-06 17:21:08 -0400
committerGitHub <noreply@github.com>2023-09-06 14:21:08 -0700
commit20bd5e7440e3d28715bed449a336003ba02d7d0f (patch)
treec8cfa540f1093d1248bf38407b7cdbcfa775e669
parent9333d23e5a8febfd6d340ec402e29490f216ad01 (diff)
Global values are automatically assigned null derivative (#3186)
-rw-r--r--source/slang/slang-ir-autodiff-transcriber-base.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp
index 24e26f943..53bb30f54 100644
--- a/source/slang/slang-ir-autodiff-transcriber-base.cpp
+++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp
@@ -1161,6 +1161,12 @@ InstPair AutoDiffTranscriberBase::transcribeInst(IRBuilder* builder, IRInst* ori
return transcribeGeneric(builder, as<IRGeneric>(origInst));
}
+ // At this point we should not see any global insts that are differentiable.
+ // If the inst's parent is IRModule, return (inst, null).
+ //
+ if (as<IRModuleInst>(origInst->getParent()) && !as<IRType>(origInst))
+ return InstPair(origInst, nullptr);
+
auto result = transcribeInstImpl(builder, origInst);
if (result.primal == nullptr && result.differential == nullptr)