From 368ec3116ea0f10f44acbf76b5dc9e34d6ff3d32 Mon Sep 17 00:00:00 2001 From: Edward Liu Date: Mon, 14 Nov 2022 12:08:01 -0800 Subject: 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 --- source/slang/slang-ir.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/slang/slang-ir.cpp') 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( + 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( + this, + kIROp_Neg, + type, + value); + addInst(inst); + return inst; + } + IRInst* IRBuilder::emitAdd(IRType* type, IRInst* left, IRInst* right) { auto inst = createInst( -- cgit v1.2.3