diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-27 21:21:39 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-27 21:21:39 -0800 |
| commit | f23e36243e9c59c02f66ec2e18b80ba4ea540f45 (patch) | |
| tree | 6bf0e2a3676fe84067f70fcbda4549fa4eb6504d /source/slang/slang-ir-autodiff.cpp | |
| parent | 10e2d9c7c532c204f26bb2c9f383f21b121b2ff2 (diff) | |
Diagnose on storing differentiable value into non-differentiable location. (#2681)
Diffstat (limited to 'source/slang/slang-ir-autodiff.cpp')
| -rw-r--r-- | source/slang/slang-ir-autodiff.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp index b630b798d..fcfbf3bee 100644 --- a/source/slang/slang-ir-autodiff.cpp +++ b/source/slang/slang-ir-autodiff.cpp @@ -933,6 +933,27 @@ bool processAutodiffCalls( return modified; } +struct RemoveDetachInstsPass : InstPassBase +{ + RemoveDetachInstsPass(IRModule* module) : + InstPassBase(module) + { + } + void processModule() + { + processInstsOfType<IRDetachDerivative>(kIROp_DetachDerivative, [&](IRDetachDerivative* detach) + { + detach->replaceUsesWith(detach->getBase()); + }); + } +}; + +void removeDetachInsts(IRModule* module) +{ + RemoveDetachInstsPass pass(module); + pass.processModule(); +} + bool finalizeAutoDiffPass(IRModule* module) { bool modified = false; @@ -947,6 +968,8 @@ bool finalizeAutoDiffPass(IRModule* module) // modified |= processPairTypes(&autodiffContext); + removeDetachInsts(module); + stripNoDiffTypeAttribute(module); // Remove auto-diff related decorations. |
