diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-20 14:42:50 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-20 14:42:50 -0800 |
| commit | 47715e625337d489f3c0131bbc2b849378b48a5a (patch) | |
| tree | bc737c8f03ef537b2ac39860bbb922c7600edc43 /source/slang/slang-ir-util.cpp | |
| parent | 8b05df4187117d61491f2fdbeb7d744146ad73f7 (diff) | |
Miscellaneous backward autodiff fixes. (#2665)
* Fix differentiable type registration
* Fix use of non-differentiable return value in a differentiable func.
* Fix use of primal inst that does not dominate the diff block.
* Fix primal inst hoisting, and add missing type legalization logic.
* Make `detach` defined on all differentiable T.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir-util.cpp')
| -rw-r--r-- | source/slang/slang-ir-util.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/source/slang/slang-ir-util.cpp b/source/slang/slang-ir-util.cpp index f3c4c2c82..3db036a8d 100644 --- a/source/slang/slang-ir-util.cpp +++ b/source/slang/slang-ir-util.cpp @@ -224,7 +224,7 @@ String dumpIRToString(IRInst* root) StringBuilder sb; StringWriter writer(&sb, Slang::WriterFlag::AutoFlush); IRDumpOptions options = {}; -#if 0 +#if 1 options.flags = IRDumpOptions::Flag::DumpDebugIds; #endif dumpIR(root, options, nullptr, &writer); @@ -487,6 +487,34 @@ IROp getSwapSideComparisonOp(IROp op) } } +void setInsertBeforeOrdinaryInst(IRBuilder* builder, IRInst* inst) +{ + if (as<IRParam>(inst)) + { + SLANG_RELEASE_ASSERT(as<IRBlock>(inst->getParent())); + auto lastParam = as<IRBlock>(inst->getParent())->getLastParam(); + builder->setInsertAfter(lastParam); + } + else + { + builder->setInsertBefore(inst); + } +} + +void setInsertAfterOrdinaryInst(IRBuilder* builder, IRInst* inst) +{ + if (as<IRParam>(inst)) + { + SLANG_RELEASE_ASSERT(as<IRBlock>(inst->getParent())); + auto lastParam = as<IRBlock>(inst->getParent())->getLastParam(); + builder->setInsertAfter(lastParam); + } + else + { + builder->setInsertAfter(inst); + } +} + bool isPureFunctionalCall(IRCall* call) { auto callee = getResolvedInstForDecorations(call->getCallee()); |
