From 20bd5e7440e3d28715bed449a336003ba02d7d0f Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Wed, 6 Sep 2023 17:21:08 -0400 Subject: Global values are automatically assigned null derivative (#3186) --- source/slang/slang-ir-autodiff-transcriber-base.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source') 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(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(origInst->getParent()) && !as(origInst)) + return InstPair(origInst, nullptr); + auto result = transcribeInstImpl(builder, origInst); if (result.primal == nullptr && result.differential == nullptr) -- cgit v1.2.3