diff options
| author | Edward Liu <shiqiu1105@gmail.com> | 2022-11-14 12:08:01 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-14 12:08:01 -0800 |
| commit | 368ec3116ea0f10f44acbf76b5dc9e34d6ff3d32 (patch) | |
| tree | 3d9def111db278affb8413bddb5aab9ce3cf73a6 /source/slang/slang-ir.cpp | |
| parent | 623f5c36e0dc8190753aa5fa2e89f1010c367c67 (diff) | |
Minimum binary arithmetic reverse autodiff working. (#2514)
* Initial plumbing of backward autodiff in the frontend.
* More plumbing.
* Initial reverse autodiff working.
* Bug fixes.
* Misc.
* Remove redundant code.
* More clean up.
* Misc.
* Rebase and add backward diff test.
* Disable test.
* Clean up.
* Minor fix.
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-ir.cpp')
| -rw-r--r-- | source/slang/slang-ir.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 9d538a774..6112beaf2 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -3109,6 +3109,17 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitBackwardDifferentiateInst(IRType* type, IRInst* baseFn) + { + auto inst = createInst<IRBackwardDifferentiate>( + this, + kIROp_BackwardDifferentiate, + type, + baseFn); + addInst(inst); + return inst; + } + IRInst* IRBuilder::emitMakeDifferentialPair(IRType* type, IRInst* primal, IRInst* differential) { IRInst* args[] = {primal, differential}; @@ -4556,6 +4567,17 @@ namespace Slang return inst; } + IRInst* IRBuilder::emitNeg(IRType* type, IRInst* value) + { + auto inst = createInst<IRInst>( + this, + kIROp_Neg, + type, + value); + addInst(inst); + return inst; + } + IRInst* IRBuilder::emitAdd(IRType* type, IRInst* left, IRInst* right) { auto inst = createInst<IRInst>( |
