summaryrefslogtreecommitdiff
path: root/source/slang/slang-ir-autodiff-rev.cpp
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2023-01-30 11:46:36 -0500
committerGitHub <noreply@github.com>2023-01-30 08:46:36 -0800
commit134dd7eb26fc7988ae13559d276cbf337b4b9d27 (patch)
tree35bd06e6bebb4518bca805e14e85f8f9ef4341c6 /source/slang/slang-ir-autodiff-rev.cpp
parent4a66e9729175a89833e5db784bb64e6a7f60cdf2 (diff)
Overhauled reverse-mode control flow handling (#2608)
* Added switch-case support; fixed non-diff parameter transposition * Made region propagation much more robust. Partial loop unzip implementation * WIP: Added most loop handling code, and a test. Still untested * Added CFG Normalization pass + CFG Reversal Pass + Loop Unzipping + most loop transcription * Add single-iter-loop test. * proj files * removed comments * Update reverse-loop.slang * Removed out-of-date code * Disabled IR validation during constructSSA phase of normalizeCFG. constructSSA now reuses sharedBuilder * Moved normalizeCFG() call to prepareFuncForBackwardDiff()
Diffstat (limited to 'source/slang/slang-ir-autodiff-rev.cpp')
-rw-r--r--source/slang/slang-ir-autodiff-rev.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp
index fce2043eb..6f18a3d8a 100644
--- a/source/slang/slang-ir-autodiff-rev.cpp
+++ b/source/slang/slang-ir-autodiff-rev.cpp
@@ -3,6 +3,7 @@
#include "slang-ir-clone.h"
#include "slang-ir-dce.h"
#include "slang-ir-eliminate-phis.h"
+#include "slang-ir-autodiff-cfg-norm.h"
#include "slang-ir-util.h"
#include "slang-ir-inst-pass-base.h"
#include "slang-ir-ssa-simplification.h"
@@ -16,7 +17,7 @@ namespace Slang
IRFuncType* BackwardDiffTranscriberBase::differentiateFunctionTypeImpl(IRBuilder* builder, IRFuncType* funcType, IRInst* intermeidateType)
{
List<IRType*> newParameterTypes;
- IRType* diffReturnType;
+ IRType* diffReturnType;
for (UIndex i = 0; i < funcType->getParamCount(); i++)
{
@@ -509,6 +510,9 @@ namespace Slang
}
eliminateMultiLevelBreakForFunc(func->getModule(), func);
+ IRCFGNormalizationPass cfgPass = {this->getSink()};
+ normalizeCFG(func);
+
AutoDiffAddressConversionPolicy cvtPolicty;
cvtPolicty.diffTypeContext = &diffTypeContext;
auto result = eliminateAddressInsts(sharedBuilder, &cvtPolicty, func, sink);