From 61c34d0d556023124c9b20c7776b1c628050ffa8 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Fri, 6 Sep 2024 12:30:33 -0700 Subject: [PATCH 01/32] Transferring source locations when creating phi instructions --- ad-report | 1306 +++++++++++++++++ out.glsl | 146 ++ out.hlsl | 146 ++ reverse-loop.slang-ast | 1154 +++++++++++++++ source/slang/slang-emit.cpp | 28 + source/slang/slang-ir-autodiff-fwd.cpp | 17 + .../slang/slang-ir-autodiff-primal-hoist.cpp | 33 + source/slang/slang-ir-autodiff-rev.cpp | 48 + .../slang-ir-autodiff-transcriber-base.cpp | 24 + source/slang/slang-ir-autodiff.cpp | 3 + source/slang/slang-ir-clone.cpp | 2 + source/slang/slang-ir-ssa.cpp | 63 +- source/slang/slang-lower-to-ir.cpp | 15 + 13 files changed, 2983 insertions(+), 2 deletions(-) create mode 100644 ad-report create mode 100644 out.glsl create mode 100644 out.hlsl create mode 100644 reverse-loop.slang-ast diff --git a/ad-report b/ad-report new file mode 100644 index 0000000000..9677515982 --- /dev/null +++ b/ad-report @@ -0,0 +1,1306 @@ +BACKWARD DIFFERENTIATE + + +transcribing an original instruction: 154 (1) + > +result: +BACKWARD DIFFERENTIATE +BACKWARD DIFFERENTIATE PRIMAL +BACKWARD DIFFERENTIATE PROPOGATE + + +transcribing an original instruction: 154 (1) + > +result: +(primalFunc)=============================== +[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] +[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] +[primalInstDecoration] +[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %1( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%2, %3, %4, %y, 0 : Int) + +block %2( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %5 : Bool = cmpLT(%i, 3 : Int) + ifElse(%5, %6, %3, %6) + +block %6: + let %7 : Float = mul(%t, %t) + unconditionalBranch(%4) + +block %4: + let %8 : Int = add(%i, 1 : Int) + unconditionalBranch(%2, %7, %8) + +block %3: + return_val(%t) +} + +inst with location: 1514954 (1) +[nameHint("y")] +let %y : Float = param + +tests/autodiff/reverse-loop.slang(12): note: see declaration of 'y' +float test_simple_loop(float y) + ^~~~~~~~~~~~~~~~ +inst with location: 1515008 (1) +[loopMaxIters(3 : Int)] +loop(%1, %2, %3, %y, 0 : Int) + +tests/autodiff/reverse-loop.slang(16): note: see declaration of '' + for (int i = 0; i < 3; i++) + ^~~ +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Float = param + +tests/autodiff/reverse-loop.slang(14): note: see declaration of 't' + float t = y; + ^ +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Int = param + +tests/autodiff/reverse-loop.slang(16): note: see declaration of 'i' + for (int i = 0; i < 3; i++) + ^ +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%i, 3 : Int) + +tests/autodiff/reverse-loop.slang(16): note: see declaration of '' + for (int i = 0; i < 3; i++) + ^ +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %2) + +tests/autodiff/reverse-loop.slang(16): note: see declaration of '' + for (int i = 0; i < 3; i++) + ^~~ +inst with location: 1515058 (1) +let %1 : Float = mul(%t, %t) + +tests/autodiff/reverse-loop.slang(18): note: see declaration of '' + t = t * t; + ^ +inst with location: 1515008 (1) +unconditionalBranch(%1) + +tests/autodiff/reverse-loop.slang(16): note: see declaration of '' + for (int i = 0; i < 3; i++) + ^~~ +inst with location: 1515032 (1) +let %1 : Int = add(%i, 1 : Int) + +tests/autodiff/reverse-loop.slang(16): note: see declaration of '' + for (int i = 0; i < 3; i++) + ^~ +inst with location: 1515008 (1) +unconditionalBranch(%1, %2, %3) + +tests/autodiff/reverse-loop.slang(16): note: see declaration of '' + for (int i = 0; i < 3; i++) + ^~~ +inst with location: 1515077 (1) +return_val(%t) + +tests/autodiff/reverse-loop.slang(21): note: see declaration of '' + return t; + ^~~~~~ +(result from cloneInst)=============================== +inst with location: 1514954 (1) +[nameHint("y")] +let %y : Float = param + +inst with location: 1515008 (1) +[loopMaxIters(3 : Int)] +loop(%1, %2, %3, %y, 0 : Int) + +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Int = param + +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %2) + +inst with location: 1515058 (1) +let %1 : Float = mul(%t, %t) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515032 (1) +let %1 : Int = add(%i, 1 : Int) + +inst with location: 1515008 (1) +unconditionalBranch(%1, %2, %3) + +inst with location: 1515077 (1) +return_val(%t) + + + +transcribing an original instruction: 154 (1) + > +result: +(result from prepareFuncForForwardDiff)=============================== +inst with location: 1514954 (1) +[nameHint("y")] +let %y : Float = param + +inst with location: 0 (0) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %y, 0 : Int) + +inst with location: 0 (0) +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +let %1 : Bool = logicalAnd(true, %x5Fbflag) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515077 (1) +return_val(%t) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +let %1 : Int = undefined + +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, true, %2) + +inst with location: 0 (0) +unconditionalBranch(%1, false, 0 : Int) + +inst with location: 0 (0) +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +let %1 : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, 0 : Float) + +inst with location: 1515058 (1) +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +unconditionalBranch(%1, 1 : Int, %2) + +inst with location: 0 (0) +let %1 : Int = param + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %t, %i) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515032 (1) +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, %3) + +inst with location: 0 (0) +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag, %t, %i) + +inst with location: 0 (0) +unreachable + +(result from forward diff transcribe blocks)=============================== + + +transcribing an original instruction: 1514954 (1) + >[nameHint("y")] +let %y : Float = param + +result: + >let %1 : Float = GetPrimal(%dpy) + + [P] source loc: 1514954 (1) + >let %1 : Float = GetDifferential(%dpy) + + [D] source loc: 1514954 (1) + + +transcribing an original instruction: 0 (0) + >[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %y, 0 : Int) + + + +transcribing an original instruction: 3068 (1) + > +result: + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %3, %4, 0 : Int) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %3, %4, 0 : Int) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >[nameHint("_bflag")] +let %x5Fbflag : Bool = param + + + +transcribing an original instruction: 3068 (1) + > +result: +result: + >[nameHint("_bflag")] +let %x5Fbflag : Bool = param + + [P] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >[nameHint("t")] +let %t : Float = param + +result: + >[nameHint("t")] +let %t : Float = param + + [P] source loc: 0 (0) + >let %1 : Float = param + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >[nameHint("i")] +let %i : Int = param + + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[nameHint("i")] +let %i : Int = param + + [P] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >ifElse(%x5Fbflag, %1, %2, %1) + +result: + >[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %1) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %1) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1) + +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 1515077 (1) + >return_val(%t) + +result: + >[mixedDiffInstDecoration(DiffPair(Float, %1))] +return_val(%2) + + [P] source loc: 1515077 (1) + >[mixedDiffInstDecoration(DiffPair(Float, %1))] +return_val(%2) + + [D] source loc: 1515077 (1) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1) + +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 1515026 (1) + >let %1 : Bool = cmpLT(%i, 3 : Int) + +result: + >let %1 : Bool = cmpLT(%i, 3 : Int) + + [P] source loc: 1515026 (1) + + +transcribing an original instruction: 0 (0) + >ifElse(%1, %2, %3, %4) + +result: + >[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1, 0 : Int, 0 : Float) + + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, 0 : Int, 0 : Float, %2) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, 0 : Int, 0 : Float, %2) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 1515058 (1) + >let %1 : Float = mul(%t, %t) + +result: + >let %1 : Float = mul(%t, %t) + + [P] source loc: 1515058 (1) + >[diffInstDecoration(Float)] +let %1 : Float = add(%2, %3) + + [D] source loc: 1515058 (1) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1, 1 : Int, %2) + + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, 1 : Int, %2, %3) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, 1 : Int, %2, %3) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >let %1 : Int = param + + + +transcribing an original instruction: 204 (1) + > +result: +result: + >let %1 : Int = param + + [P] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >let %1 : Float = param + +result: + >let %1 : Float = param + + [P] source loc: 0 (0) + >let %1 : Float = param + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1) + +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >let %1 : Bool = cmpNE(%2, 1 : Int) + +result: + >let %1 : Bool = cmpNE(%2, 1 : Int) + + [P] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >ifElse(%1, %2, %3, %4) + +result: + >[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1, %x5Fbflag) + + + +transcribing an original instruction: 3068 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1, false) + + + +transcribing an original instruction: 3068 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, false) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, false) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >[nameHint("_bflag")] +let %x5Fbflag : Bool = param + + + +transcribing an original instruction: 3068 (1) + > +result: +result: + >[nameHint("_bflag")] +let %x5Fbflag : Bool = param + + [P] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1) + +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >ifElse(%x5Fbflag, %1, %2, %3) + +result: + >[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %3) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %3) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1, %t, %i) + + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 1515032 (1) + >let %1 : Int = add(%i, 1 : Int) + +result: + >let %1 : Int = add(%i, 1 : Int) + + [P] source loc: 1515032 (1) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1, %2, %3) + + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %2, %3, %4) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %2, %3, %4) + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >[nameHint("t")] +let %t : Float = param + +result: + >[nameHint("t")] +let %t : Float = param + + [P] source loc: 0 (0) + >let %1 : Float = param + + [D] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >[nameHint("i")] +let %i : Int = param + + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[nameHint("i")] +let %i : Int = param + + [P] source loc: 0 (0) + + +transcribing an original instruction: 0 (0) + >unconditionalBranch(%1, %x5Fbflag, %t, %i) + + + +transcribing an original instruction: 3068 (1) + > +result: + + +transcribing an original instruction: 204 (1) + > +result: +result: + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) + + [P] source loc: 0 (0) + >[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) + + [D] source loc: 0 (0) +(fwdDiffFunc)=============================== +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : DiffPair(Float, %1) = param + +inst with location: 1514954 (1) +[diffInstDecoration(Float)] +let %1 : Float = GetDifferential(%dpy) + +inst with location: 1514954 (1) +[primalInstDecoration] +let %1 : Float = GetPrimal(%dpy) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %3, %4, 0 : Int) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 0 (0) +[mixedDiffInstDecoration(DiffPair(Float, %1))] +let %2 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + +inst with location: 1515077 (1) +[mixedDiffInstDecoration(DiffPair(Float, %1))] +return_val(%2) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 1515026 (1) +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, 0 : Int, 0 : Float, %2) + +inst with location: 1515058 (1) +[primalInstDecoration] +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 1515058 (1) +[diffInstDecoration(Float)] +let %1 : Float = add(%2, %3) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, 1 : Int, %2, %3) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Int = param + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Float = param + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) + +inst with location: 1515032 (1) +[primalInstDecoration] +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %2, %3, %4) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) + +(checkpoint policy, got) =============================== +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : Float = param + +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : InOut(DiffPair(Float, %1)) = param + +inst with location: 0 (0) +[nameHint("_s_dOut")] +let %x5Fsx5FdOut : Float = param + +inst with location: 0 (0) +[nameHint("_s_diff_ctx")] +let %x5Fsx5Fdiffx5Fctx : BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop) = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : DiffPair(Float, %2) = load(%dpy) + +inst with location: 0 (0) +[keepAlive] +let %1 : Float = GetPrimal(%2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[loopMaxIters(4 : Int)] +let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[BackwardDerivativePrimalReturnDecoration(%t)] +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +let %1 : Ptr(Float) = var + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +let %1 : Ptr(Float) = var + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %2) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[diffInstDecoration(Void, %1)] +[loopMaxIters(4 : Int)] +loop(%2, %3, %4) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : DiffPair(Float, %2) = load(%dpy) + +inst with location: 0 (0) +let %1 : Float = GetPrimal(%2) + +inst with location: 0 (0) +let %1 : DiffPair(Float, %2) = MakeDiffPair(%3, %4) + +inst with location: 0 (0) +store(%dpy, %1) + +inst with location: 0 (0) +return_val(void_constant) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : Float = mul(%t, %2) + +inst with location: 0 (0) +let %1 : Float = mul(%t, %2) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515026 (1) +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, 0 : Int, 0 : Float) + +inst with location: 1515058 (1) +[primalInstDecoration] +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +unconditionalBranch(%1, 1 : Int, %2) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Int = param + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %t, %i) + +inst with location: 1515032 (1) +[primalInstDecoration] +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, %3) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag, %t, %i) + +### Slang::AutodiffCheckpointPolicyBase::processFunc + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4D8590 to storeSet +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4D8590 to storeSet +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 0 (0) + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DC39DB40 to storeSet +0 +inst with location: 0 (0) + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DC39D710 to storeSet +1 +inst with location: 0 (0) + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4D5760 to storeSet + +inst with location: 0 (0) + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4C3858 to storeSet +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + +inst with location: 0 (0) +****** (before legalization) # of elements in the store set for hoistInfo: 2 +source loc recorded: 0 (0) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +source loc recorded: 0 (0) +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + +****** (after legalization) # of elements in the store set for hoistInfo: 2 +source loc recorded: 0 (0) +let %1 : Ptr(Int) = var + +(0): note: also see pipeline definition +source loc recorded: 0 (0) +let %1 : Ptr(Array(Float, 5 : Int)) = var + +(0): note: also see pipeline definition diff --git a/out.glsl b/out.glsl new file mode 100644 index 0000000000..f236cc337d --- /dev/null +++ b/out.glsl @@ -0,0 +1,146 @@ +#version 450 +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { + float _data[]; +} outputBuffer_0; +struct DiffPair_float_0 +{ + float primal_0; + float differential_0; +}; + +struct s_bwd_prop_test_simple_loop_Intermediates_0 +{ + float _S1[5]; + int _S2; +}; + +float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_0) +{ + float _S3[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; + _s_diff_ctx_0._S1 = _S3; + _s_diff_ctx_0._S2 = 0; + _s_diff_ctx_0._S1[0] = 0.0; + _s_diff_ctx_0._S1[1] = 0.0; + _s_diff_ctx_0._S1[2] = 0.0; + _s_diff_ctx_0._S1[3] = 0.0; + _s_diff_ctx_0._S1[4] = 0.0; + _s_diff_ctx_0._S2 = 0; + bool _bflag_0 = true; + float t_0 = dpy_0; + int i_0 = 0; + int _pc_0 = 0; + for(;;) + { + _s_diff_ctx_0._S1[_pc_0] = t_0; + _s_diff_ctx_0._S2 = _pc_0; + if(_bflag_0) + { + } + else + { + break; + } + float _S4; + int _S5; + if(i_0 < 3) + { + float _S6 = t_0 * t_0; + _S5 = 1; + _S4 = _S6; + } + else + { + _S5 = 0; + _S4 = 0.0; + } + if(_S5 != 1) + { + _bflag_0 = false; + } + if(_bflag_0) + { + int _S7 = i_0 + 1; + t_0 = _S4; + i_0 = _S7; + } + _pc_0 = _pc_0 + 1; + } + return t_0; +} + +void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0, s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_1) +{ + int _dc_0 = _s_diff_ctx_1._S2 - 1; + float _S8 = _s_dOut_0; + for(;;) + { + if(_dc_0 >= 0) + { + } + else + { + break; + } + bool _S9 = _dc_0 < 3; + int _S10; + if(_S9) + { + _S10 = 1; + } + else + { + _S10 = 0; + } + float _S11; + float _S12; + if(!(_S10 != 1)) + { + _S11 = _S8; + _S12 = 0.0; + } + else + { + _S11 = 0.0; + _S12 = _S8; + } + if(_S9) + { + _S8 = _s_diff_ctx_1._S1[_dc_0] * _S11 + _s_diff_ctx_1._S1[_dc_0] * _S11 + _S12; + } + else + { + _S8 = _S12; + } + _dc_0 = _dc_0 - 1; + } + dpy_1.primal_0 = dpy_1.primal_0; + dpy_1.differential_0 = _S8; + return; +} + +void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S13, float _S14) +{ + s_bwd_prop_test_simple_loop_Intermediates_0 _S15; + float _S16 = s_primal_ctx_test_simple_loop_0(_S13.primal_0, _S15); + s_bwd_prop_test_simple_loop_0(_S13, _S14, _S15); + return; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() +{ + DiffPair_float_0 dpa_0; + dpa_0.primal_0 = 1.0; + dpa_0.differential_0 = 0.0; + s_bwd_test_simple_loop_0(dpa_0, 1.0); + outputBuffer_0._data[uint(0)] = dpa_0.differential_0; + DiffPair_float_0 dpa_1; + dpa_1.primal_0 = 0.40000000596046448; + dpa_1.differential_0 = 0.0; + s_bwd_test_simple_loop_0(dpa_1, 1.0); + outputBuffer_0._data[uint(1)] = dpa_1.differential_0; + return; +} + diff --git a/out.hlsl b/out.hlsl new file mode 100644 index 0000000000..f236cc337d --- /dev/null +++ b/out.hlsl @@ -0,0 +1,146 @@ +#version 450 +layout(row_major) uniform; +layout(row_major) buffer; +layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { + float _data[]; +} outputBuffer_0; +struct DiffPair_float_0 +{ + float primal_0; + float differential_0; +}; + +struct s_bwd_prop_test_simple_loop_Intermediates_0 +{ + float _S1[5]; + int _S2; +}; + +float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_0) +{ + float _S3[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; + _s_diff_ctx_0._S1 = _S3; + _s_diff_ctx_0._S2 = 0; + _s_diff_ctx_0._S1[0] = 0.0; + _s_diff_ctx_0._S1[1] = 0.0; + _s_diff_ctx_0._S1[2] = 0.0; + _s_diff_ctx_0._S1[3] = 0.0; + _s_diff_ctx_0._S1[4] = 0.0; + _s_diff_ctx_0._S2 = 0; + bool _bflag_0 = true; + float t_0 = dpy_0; + int i_0 = 0; + int _pc_0 = 0; + for(;;) + { + _s_diff_ctx_0._S1[_pc_0] = t_0; + _s_diff_ctx_0._S2 = _pc_0; + if(_bflag_0) + { + } + else + { + break; + } + float _S4; + int _S5; + if(i_0 < 3) + { + float _S6 = t_0 * t_0; + _S5 = 1; + _S4 = _S6; + } + else + { + _S5 = 0; + _S4 = 0.0; + } + if(_S5 != 1) + { + _bflag_0 = false; + } + if(_bflag_0) + { + int _S7 = i_0 + 1; + t_0 = _S4; + i_0 = _S7; + } + _pc_0 = _pc_0 + 1; + } + return t_0; +} + +void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0, s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_1) +{ + int _dc_0 = _s_diff_ctx_1._S2 - 1; + float _S8 = _s_dOut_0; + for(;;) + { + if(_dc_0 >= 0) + { + } + else + { + break; + } + bool _S9 = _dc_0 < 3; + int _S10; + if(_S9) + { + _S10 = 1; + } + else + { + _S10 = 0; + } + float _S11; + float _S12; + if(!(_S10 != 1)) + { + _S11 = _S8; + _S12 = 0.0; + } + else + { + _S11 = 0.0; + _S12 = _S8; + } + if(_S9) + { + _S8 = _s_diff_ctx_1._S1[_dc_0] * _S11 + _s_diff_ctx_1._S1[_dc_0] * _S11 + _S12; + } + else + { + _S8 = _S12; + } + _dc_0 = _dc_0 - 1; + } + dpy_1.primal_0 = dpy_1.primal_0; + dpy_1.differential_0 = _S8; + return; +} + +void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S13, float _S14) +{ + s_bwd_prop_test_simple_loop_Intermediates_0 _S15; + float _S16 = s_primal_ctx_test_simple_loop_0(_S13.primal_0, _S15); + s_bwd_prop_test_simple_loop_0(_S13, _S14, _S15); + return; +} + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void main() +{ + DiffPair_float_0 dpa_0; + dpa_0.primal_0 = 1.0; + dpa_0.differential_0 = 0.0; + s_bwd_test_simple_loop_0(dpa_0, 1.0); + outputBuffer_0._data[uint(0)] = dpa_0.differential_0; + DiffPair_float_0 dpa_1; + dpa_1.primal_0 = 0.40000000596046448; + dpa_1.differential_0 = 0.0; + s_bwd_test_simple_loop_0(dpa_1, 1.0); + outputBuffer_0._data[uint(1)] = dpa_1.differential_0; + return; +} + diff --git a/reverse-loop.slang-ast b/reverse-loop.slang-ast new file mode 100644 index 0000000000..f3861ed3f6 --- /dev/null +++ b/reverse-loop.slang-ast @@ -0,0 +1,1154 @@ +ModuleDecl:0 { + astNodeType : ModuleDecl + loc : SourceLoc(1514807) tests/autodiff/reverse-loop.slang:6 + modifiers : { + } + parentDecl : null + nameAndLoc : NameLoc{"reverse-loop", SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + VarDecl:1, + TypeDefDecl:2, + EmptyDecl:3, + TypeDefDecl:4, + EmptyDecl:5, + FuncDecl:6, + FuncDecl:7 + } + closingSourceLoc : SourceLoc(1515508) tests/autodiff/reverse-loop.slang:41 + ownedScope : ::?::reverse-loop + module : Unknown@0x000001f7c8db17f0 + mapDeclToAssociatedDecls : { + } + isInLegacyLanguage : 1 +} +VarDecl:1 { + astNodeType : VarDecl + loc : SourceLoc(1514833) tests/autodiff/reverse-loop.slang:6 + modifiers : { + } + parentDecl : ModuleDecl:0 + nameAndLoc : NameLoc{"outputBuffer", SourceLoc(1514833) tests/autodiff/reverse-loop.slang:6 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + GenericAppExpr:8, + null + } + initExpr : null + val : null +} +TypeDefDecl:2 { + astNodeType : TypeDefDecl + loc : SourceLoc(1514882) tests/autodiff/reverse-loop.slang:8 + modifiers : { + } + parentDecl : ModuleDecl:0 + nameAndLoc : NameLoc{"dpfloat", SourceLoc(1514882) tests/autodiff/reverse-loop.slang:8 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + GenericAppExpr:9, + null + } +} +EmptyDecl:3 { + astNodeType : EmptyDecl + loc : SourceLoc(1514889) tests/autodiff/reverse-loop.slang:8 + modifiers : { + } + parentDecl : ModuleDecl:0 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null +} +TypeDefDecl:4 { + astNodeType : TypeDefDecl + loc : SourceLoc(1514919) tests/autodiff/reverse-loop.slang:9 + modifiers : { + } + parentDecl : ModuleDecl:0 + nameAndLoc : NameLoc{"dfloat", SourceLoc(1514919) tests/autodiff/reverse-loop.slang:9 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + MemberExpr:10, + null + } +} +EmptyDecl:5 { + astNodeType : EmptyDecl + loc : SourceLoc(1514925) tests/autodiff/reverse-loop.slang:9 + modifiers : { + } + parentDecl : ModuleDecl:0 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null +} +FuncDecl:6 { + astNodeType : FuncDecl + loc : SourceLoc(1514954) tests/autodiff/reverse-loop.slang:12 + modifiers : { + UncheckedAttribute:11 + } + parentDecl : ModuleDecl:0 + nameAndLoc : NameLoc{"test_simple_loop", SourceLoc(1514954) tests/autodiff/reverse-loop.slang:12 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + ParamDecl:12 + } + closingSourceLoc : SourceLoc(1515088) tests/autodiff/reverse-loop.slang:22 + ownedScope : ::?::reverse-loop::test_simple_loop + returnType : { + VarExpr:13, + null + } + errorType : { + null, + null + } + primaryDecl : null + nextDecl : null + body : BlockStmt:14 +} +FuncDecl:7 { + astNodeType : FuncDecl + loc : SourceLoc(1515121) tests/autodiff/reverse-loop.slang:25 + modifiers : { + UncheckedAttribute:15 + } + parentDecl : ModuleDecl:0 + nameAndLoc : NameLoc{"computeMain", SourceLoc(1515121) tests/autodiff/reverse-loop.slang:25 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + ParamDecl:16 + } + closingSourceLoc : SourceLoc(1515505) tests/autodiff/reverse-loop.slang:40 + ownedScope : ::?::reverse-loop::computeMain + returnType : { + VarExpr:17, + null + } + errorType : { + null, + null + } + primaryDecl : null + nextDecl : null + body : BlockStmt:18 +} +GenericAppExpr:8 { + astNodeType : GenericAppExpr + loc : SourceLoc(1514807) tests/autodiff/reverse-loop.slang:6 + type : rvalue null + arguments : { + VarExpr:19 + } + functionExpr : VarExpr:20 + originalFunctionExpr : null + argumentDelimeterLocs : { + } +} +GenericAppExpr:9 { + astNodeType : GenericAppExpr + loc : SourceLoc(1514858) tests/autodiff/reverse-loop.slang:8 + type : rvalue null + arguments : { + VarExpr:21 + } + functionExpr : VarExpr:22 + originalFunctionExpr : null + argumentDelimeterLocs : { + } +} +MemberExpr:10 { + astNodeType : MemberExpr + loc : SourceLoc(1514906) tests/autodiff/reverse-loop.slang:9 + type : rvalue null + declRef : + name : "Differential" + originalExpr : null + baseExpression : VarExpr:23 + memberOperatorLoc : SourceLoc(1514905) tests/autodiff/reverse-loop.slang:9 +} +UncheckedAttribute:11 { + astNodeType : UncheckedAttribute + loc : SourceLoc(1514931) tests/autodiff/reverse-loop.slang:11 + next : null + keywordName : "Differentiable" + attributeDecl : null + originalIdentifierToken : { identifier, SourceLoc(1514931) tests/autodiff/reverse-loop.slang:11, "Differentiable" } + args : { + } +} +ParamDecl:12 { + astNodeType : ParamDecl + loc : SourceLoc(1514977) tests/autodiff/reverse-loop.slang:12 + modifiers : { + } + parentDecl : FuncDecl:6 + nameAndLoc : NameLoc{"y", SourceLoc(1514977) tests/autodiff/reverse-loop.slang:12 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + VarExpr:24, + null + } + initExpr : null + val : null +} +VarExpr:13 { + astNodeType : VarExpr + loc : SourceLoc(1514948) tests/autodiff/reverse-loop.slang:12 + type : rvalue null + declRef : + name : "float" + originalExpr : null +} +BlockStmt:14 { + astNodeType : BlockStmt + loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 + modifiers : { + } + scopeDecl : ScopeDecl:25 + closingSourceLoc : SourceLoc(1515088) tests/autodiff/reverse-loop.slang:22 + body : SeqStmt:26 +} +UncheckedAttribute:15 { + astNodeType : UncheckedAttribute + loc : SourceLoc(1515094) tests/autodiff/reverse-loop.slang:24 + next : null + keywordName : "numthreads" + attributeDecl : null + originalIdentifierToken : { identifier, SourceLoc(1515094) tests/autodiff/reverse-loop.slang:24, "numthreads" } + args : { + IntegerLiteralExpr:27, + IntegerLiteralExpr:28, + IntegerLiteralExpr:29 + } +} +ParamDecl:16 { + astNodeType : ParamDecl + loc : SourceLoc(1515139) tests/autodiff/reverse-loop.slang:25 + modifiers : { + HLSLSimpleSemantic:30 + } + parentDecl : FuncDecl:7 + nameAndLoc : NameLoc{"dispatchThreadID", SourceLoc(1515139) tests/autodiff/reverse-loop.slang:25 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + VarExpr:31, + null + } + initExpr : null + val : null +} +VarExpr:17 { + astNodeType : VarExpr + loc : SourceLoc(1515116) tests/autodiff/reverse-loop.slang:25 + type : rvalue null + declRef : + name : "void" + originalExpr : null +} +BlockStmt:18 { + astNodeType : BlockStmt + loc : SourceLoc(1515187) tests/autodiff/reverse-loop.slang:27 + modifiers : { + } + scopeDecl : ScopeDecl:32 + closingSourceLoc : SourceLoc(1515505) tests/autodiff/reverse-loop.slang:40 + body : SeqStmt:33 +} +VarExpr:19 { + astNodeType : VarExpr + loc : SourceLoc(1514826) tests/autodiff/reverse-loop.slang:6 + type : rvalue null + declRef : + name : "float" + originalExpr : null +} +VarExpr:20 { + astNodeType : VarExpr + loc : SourceLoc(1514807) tests/autodiff/reverse-loop.slang:6 + type : rvalue null + declRef : + name : "RWStructuredBuffer" + originalExpr : null +} +VarExpr:21 { + astNodeType : VarExpr + loc : SourceLoc(1514875) tests/autodiff/reverse-loop.slang:8 + type : rvalue null + declRef : + name : "float" + originalExpr : null +} +VarExpr:22 { + astNodeType : VarExpr + loc : SourceLoc(1514858) tests/autodiff/reverse-loop.slang:8 + type : rvalue null + declRef : + name : "DifferentialPair" + originalExpr : null +} +VarExpr:23 { + astNodeType : VarExpr + loc : SourceLoc(1514900) tests/autodiff/reverse-loop.slang:9 + type : rvalue null + declRef : + name : "float" + originalExpr : null +} +VarExpr:24 { + astNodeType : VarExpr + loc : SourceLoc(1514971) tests/autodiff/reverse-loop.slang:12 + type : rvalue null + declRef : + name : "float" + originalExpr : null +} +ScopeDecl:25 { + astNodeType : ScopeDecl + loc : SourceLoc(0) + modifiers : { + } + parentDecl : FuncDecl:6 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + VarDecl:34 + } + closingSourceLoc : SourceLoc(0) + ownedScope : ::?::reverse-loop::test_simple_loop::? +} +SeqStmt:26 { + astNodeType : SeqStmt + loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 + modifiers : { + } + stmts : { + DeclStmt:35, + ForStmt:36, + ReturnStmt:37 + } +} +IntegerLiteralExpr:27 { + astNodeType : IntegerLiteralExpr + loc : SourceLoc(1515105) tests/autodiff/reverse-loop.slang:24 + type : rvalue null + token : { integer literal, SourceLoc(1515105) tests/autodiff/reverse-loop.slang:24, "1" } + suffixType : int + value : 1 +} +IntegerLiteralExpr:28 { + astNodeType : IntegerLiteralExpr + loc : SourceLoc(1515108) tests/autodiff/reverse-loop.slang:24 + type : rvalue null + token : { integer literal, SourceLoc(1515108) tests/autodiff/reverse-loop.slang:24, "1" } + suffixType : int + value : 1 +} +IntegerLiteralExpr:29 { + astNodeType : IntegerLiteralExpr + loc : SourceLoc(1515111) tests/autodiff/reverse-loop.slang:24 + type : rvalue null + token : { integer literal, SourceLoc(1515111) tests/autodiff/reverse-loop.slang:24, "1" } + suffixType : int + value : 1 +} +HLSLSimpleSemantic:30 { + astNodeType : HLSLSimpleSemantic + loc : SourceLoc(1515158) tests/autodiff/reverse-loop.slang:25 + next : null + keywordName : null + name : { identifier, SourceLoc(1515158) tests/autodiff/reverse-loop.slang:25, "SV_DispatchThreadID" } +} +VarExpr:31 { + astNodeType : VarExpr + loc : SourceLoc(1515133) tests/autodiff/reverse-loop.slang:25 + type : rvalue null + declRef : + name : "uint3" + originalExpr : null +} +ScopeDecl:32 { + astNodeType : ScopeDecl + loc : SourceLoc(0) + modifiers : { + } + parentDecl : FuncDecl:7 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + } + closingSourceLoc : SourceLoc(0) + ownedScope : ::?::reverse-loop::computeMain::? +} +SeqStmt:33 { + astNodeType : SeqStmt + loc : SourceLoc(1515187) tests/autodiff/reverse-loop.slang:27 + modifiers : { + } + stmts : { + BlockStmt:38, + BlockStmt:39 + } +} +VarDecl:34 { + astNodeType : VarDecl + loc : SourceLoc(1514994) tests/autodiff/reverse-loop.slang:14 + modifiers : { + } + parentDecl : ScopeDecl:25 + nameAndLoc : NameLoc{"t", SourceLoc(1514994) tests/autodiff/reverse-loop.slang:14 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + VarExpr:40, + null + } + initExpr : VarExpr:41 + val : null +} +DeclStmt:35 { + astNodeType : DeclStmt + loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 + modifiers : { + } + decl : VarDecl:34 +} +ForStmt:36 { + astNodeType : ForStmt + loc : SourceLoc(1515008) tests/autodiff/reverse-loop.slang:16 + modifiers : { + } + scopeDecl : ScopeDecl:42 + initialStatement : DeclStmt:43 + sideEffectExpression : PostfixExpr:44 + predicateExpression : InfixExpr:45 + statement : BlockStmt:46 +} +ReturnStmt:37 { + astNodeType : ReturnStmt + loc : SourceLoc(1515077) tests/autodiff/reverse-loop.slang:21 + modifiers : { + } + expression : VarExpr:47 +} +BlockStmt:38 { + astNodeType : BlockStmt + loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 + modifiers : { + } + scopeDecl : ScopeDecl:48 + closingSourceLoc : SourceLoc(1515337) tests/autodiff/reverse-loop.slang:32 + body : SeqStmt:49 +} +BlockStmt:39 { + astNodeType : BlockStmt + loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 + modifiers : { + } + scopeDecl : ScopeDecl:50 + closingSourceLoc : SourceLoc(1515502) tests/autodiff/reverse-loop.slang:39 + body : SeqStmt:51 +} +VarExpr:40 { + astNodeType : VarExpr + loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 + type : rvalue null + declRef : + name : "float" + originalExpr : null +} +VarExpr:41 { + astNodeType : VarExpr + loc : SourceLoc(1514998) tests/autodiff/reverse-loop.slang:14 + type : rvalue null + declRef : + name : "y" + originalExpr : null +} +ScopeDecl:42 { + astNodeType : ScopeDecl + loc : SourceLoc(0) + modifiers : { + } + parentDecl : ScopeDecl:25 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + VarDecl:52 + } + closingSourceLoc : SourceLoc(0) + ownedScope : ::?::reverse-loop::test_simple_loop::?::? +} +DeclStmt:43 { + astNodeType : DeclStmt + loc : SourceLoc(1515013) tests/autodiff/reverse-loop.slang:16 + modifiers : { + } + decl : VarDecl:52 +} +PostfixExpr:44 { + astNodeType : PostfixExpr + loc : SourceLoc(1515032) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + arguments : { + VarExpr:53 + } + functionExpr : VarExpr:54 + originalFunctionExpr : null + argumentDelimeterLocs : { + } +} +InfixExpr:45 { + astNodeType : InfixExpr + loc : SourceLoc(1515026) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + arguments : { + VarExpr:55, + IntegerLiteralExpr:56 + } + functionExpr : VarExpr:57 + originalFunctionExpr : null + argumentDelimeterLocs : { + } +} +BlockStmt:46 { + astNodeType : BlockStmt + loc : SourceLoc(1515052) tests/autodiff/reverse-loop.slang:18 + modifiers : { + } + scopeDecl : ScopeDecl:58 + closingSourceLoc : SourceLoc(1515068) tests/autodiff/reverse-loop.slang:19 + body : ExpressionStmt:59 +} +VarExpr:47 { + astNodeType : VarExpr + loc : SourceLoc(1515084) tests/autodiff/reverse-loop.slang:21 + type : rvalue null + declRef : + name : "t" + originalExpr : null +} +ScopeDecl:48 { + astNodeType : ScopeDecl + loc : SourceLoc(0) + modifiers : { + } + parentDecl : ScopeDecl:32 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + VarDecl:60 + } + closingSourceLoc : SourceLoc(0) + ownedScope : ::?::reverse-loop::computeMain::?::? +} +SeqStmt:49 { + astNodeType : SeqStmt + loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 + modifiers : { + } + stmts : { + DeclStmt:61, + ExpressionStmt:62, + ExpressionStmt:63 + } +} +ScopeDecl:50 { + astNodeType : ScopeDecl + loc : SourceLoc(0) + modifiers : { + } + parentDecl : ScopeDecl:32 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + VarDecl:64 + } + closingSourceLoc : SourceLoc(0) + ownedScope : ::?::reverse-loop::computeMain::?::? +} +SeqStmt:51 { + astNodeType : SeqStmt + loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 + modifiers : { + } + stmts : { + DeclStmt:65, + ExpressionStmt:66, + ExpressionStmt:67 + } +} +VarDecl:52 { + astNodeType : VarDecl + loc : SourceLoc(1515017) tests/autodiff/reverse-loop.slang:16 + modifiers : { + } + parentDecl : ScopeDecl:42 + nameAndLoc : NameLoc{"i", SourceLoc(1515017) tests/autodiff/reverse-loop.slang:16 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + VarExpr:68, + null + } + initExpr : IntegerLiteralExpr:69 + val : null +} +VarExpr:53 { + astNodeType : VarExpr + loc : SourceLoc(1515031) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + declRef : + name : "i" + originalExpr : null +} +VarExpr:54 { + astNodeType : VarExpr + loc : SourceLoc(1515032) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + declRef : + name : "++" + originalExpr : null +} +VarExpr:55 { + astNodeType : VarExpr + loc : SourceLoc(1515024) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + declRef : + name : "i" + originalExpr : null +} +IntegerLiteralExpr:56 { + astNodeType : IntegerLiteralExpr + loc : SourceLoc(1515028) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + token : { integer literal, SourceLoc(1515028) tests/autodiff/reverse-loop.slang:16, "3" } + suffixType : int + value : 3 +} +VarExpr:57 { + astNodeType : VarExpr + loc : SourceLoc(1515026) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + declRef : + name : "<" + originalExpr : null +} +ScopeDecl:58 { + astNodeType : ScopeDecl + loc : SourceLoc(0) + modifiers : { + } + parentDecl : ScopeDecl:42 + nameAndLoc : NameLoc{null, SourceLoc(0) } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + members : { + } + closingSourceLoc : SourceLoc(0) + ownedScope : ::?::reverse-loop::test_simple_loop::?::?::? +} +ExpressionStmt:59 { + astNodeType : ExpressionStmt + loc : SourceLoc(1515052) tests/autodiff/reverse-loop.slang:18 + modifiers : { + } + expression : AssignExpr:70 +} +VarDecl:60 { + astNodeType : VarDecl + loc : SourceLoc(1515206) tests/autodiff/reverse-loop.slang:28 + modifiers : { + } + parentDecl : ScopeDecl:48 + nameAndLoc : NameLoc{"dpa", SourceLoc(1515206) tests/autodiff/reverse-loop.slang:28 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + VarExpr:71, + null + } + initExpr : InvokeExpr:72 + val : null +} +DeclStmt:61 { + astNodeType : DeclStmt + loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 + modifiers : { + } + decl : VarDecl:60 +} +ExpressionStmt:62 { + astNodeType : ExpressionStmt + loc : SourceLoc(1515242) tests/autodiff/reverse-loop.slang:30 + modifiers : { + } + expression : InvokeExpr:73 +} +ExpressionStmt:63 { + astNodeType : ExpressionStmt + loc : SourceLoc(1515292) tests/autodiff/reverse-loop.slang:31 + modifiers : { + } + expression : AssignExpr:74 +} +VarDecl:64 { + astNodeType : VarDecl + loc : SourceLoc(1515365) tests/autodiff/reverse-loop.slang:35 + modifiers : { + } + parentDecl : ScopeDecl:50 + nameAndLoc : NameLoc{"dpa", SourceLoc(1515365) tests/autodiff/reverse-loop.slang:35 } + inferredCapabilityRequirements : capability_set() + markup : null + checkState : DeclCheckStateExt{0, 0} + nextInContainerWithSameName : null + type : { + VarExpr:75, + null + } + initExpr : InvokeExpr:76 + val : null +} +DeclStmt:65 { + astNodeType : DeclStmt + loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 + modifiers : { + } + decl : VarDecl:64 +} +ExpressionStmt:66 { + astNodeType : ExpressionStmt + loc : SourceLoc(1515401) tests/autodiff/reverse-loop.slang:37 + modifiers : { + } + expression : InvokeExpr:77 +} +ExpressionStmt:67 { + astNodeType : ExpressionStmt + loc : SourceLoc(1515451) tests/autodiff/reverse-loop.slang:38 + modifiers : { + } + expression : AssignExpr:78 +} +VarExpr:68 { + astNodeType : VarExpr + loc : SourceLoc(1515013) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + declRef : + name : "int" + originalExpr : null +} +IntegerLiteralExpr:69 { + astNodeType : IntegerLiteralExpr + loc : SourceLoc(1515021) tests/autodiff/reverse-loop.slang:16 + type : rvalue null + token : { integer literal, SourceLoc(1515021) tests/autodiff/reverse-loop.slang:16, "0" } + suffixType : int + value : 0 +} +AssignExpr:70 { + astNodeType : AssignExpr + loc : SourceLoc(1515054) tests/autodiff/reverse-loop.slang:18 + type : rvalue null + left : VarExpr:79 + right : InfixExpr:80 +} +VarExpr:71 { + astNodeType : VarExpr + loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 + type : rvalue null + declRef : + name : "dpfloat" + originalExpr : null +} +InvokeExpr:72 { + astNodeType : InvokeExpr + loc : SourceLoc(1515219) tests/autodiff/reverse-loop.slang:28 + type : rvalue null + arguments : { + FloatingPointLiteralExpr:81, + FloatingPointLiteralExpr:82 + } + functionExpr : VarExpr:83 + originalFunctionExpr : null + argumentDelimeterLocs : { + SourceLoc(1515219) tests/autodiff/reverse-loop.slang:28, + SourceLoc(1515223) tests/autodiff/reverse-loop.slang:28, + SourceLoc(1515228) tests/autodiff/reverse-loop.slang:28 + } +} +InvokeExpr:73 { + astNodeType : InvokeExpr + loc : SourceLoc(1515270) tests/autodiff/reverse-loop.slang:30 + type : rvalue null + arguments : { + VarExpr:84, + FloatingPointLiteralExpr:85 + } + functionExpr : BackwardDifferentiateExpr:86 + originalFunctionExpr : null + argumentDelimeterLocs : { + SourceLoc(1515270) tests/autodiff/reverse-loop.slang:30, + SourceLoc(1515274) tests/autodiff/reverse-loop.slang:30, + SourceLoc(1515280) tests/autodiff/reverse-loop.slang:30 + } +} +AssignExpr:74 { + astNodeType : AssignExpr + loc : SourceLoc(1515308) tests/autodiff/reverse-loop.slang:31 + type : rvalue null + left : IndexExpr:87 + right : MemberExpr:88 +} +VarExpr:75 { + astNodeType : VarExpr + loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 + type : rvalue null + declRef : + name : "dpfloat" + originalExpr : null +} +InvokeExpr:76 { + astNodeType : InvokeExpr + loc : SourceLoc(1515378) tests/autodiff/reverse-loop.slang:35 + type : rvalue null + arguments : { + FloatingPointLiteralExpr:89, + FloatingPointLiteralExpr:90 + } + functionExpr : VarExpr:91 + originalFunctionExpr : null + argumentDelimeterLocs : { + SourceLoc(1515378) tests/autodiff/reverse-loop.slang:35, + SourceLoc(1515382) tests/autodiff/reverse-loop.slang:35, + SourceLoc(1515387) tests/autodiff/reverse-loop.slang:35 + } +} +InvokeExpr:77 { + astNodeType : InvokeExpr + loc : SourceLoc(1515429) tests/autodiff/reverse-loop.slang:37 + type : rvalue null + arguments : { + VarExpr:92, + FloatingPointLiteralExpr:93 + } + functionExpr : BackwardDifferentiateExpr:94 + originalFunctionExpr : null + argumentDelimeterLocs : { + SourceLoc(1515429) tests/autodiff/reverse-loop.slang:37, + SourceLoc(1515433) tests/autodiff/reverse-loop.slang:37, + SourceLoc(1515439) tests/autodiff/reverse-loop.slang:37 + } +} +AssignExpr:78 { + astNodeType : AssignExpr + loc : SourceLoc(1515467) tests/autodiff/reverse-loop.slang:38 + type : rvalue null + left : IndexExpr:95 + right : MemberExpr:96 +} +VarExpr:79 { + astNodeType : VarExpr + loc : SourceLoc(1515052) tests/autodiff/reverse-loop.slang:18 + type : rvalue null + declRef : + name : "t" + originalExpr : null +} +InfixExpr:80 { + astNodeType : InfixExpr + loc : SourceLoc(1515058) tests/autodiff/reverse-loop.slang:18 + type : rvalue null + arguments : { + VarExpr:97, + VarExpr:98 + } + functionExpr : VarExpr:99 + originalFunctionExpr : null + argumentDelimeterLocs : { + } +} +FloatingPointLiteralExpr:81 { + astNodeType : FloatingPointLiteralExpr + loc : SourceLoc(1515220) tests/autodiff/reverse-loop.slang:28 + type : rvalue null + token : { floating-point literal, SourceLoc(1515220) tests/autodiff/reverse-loop.slang:28, "1.0" } + suffixType : float + value : 1.0 +} +FloatingPointLiteralExpr:82 { + astNodeType : FloatingPointLiteralExpr + loc : SourceLoc(1515225) tests/autodiff/reverse-loop.slang:28 + type : rvalue null + token : { floating-point literal, SourceLoc(1515225) tests/autodiff/reverse-loop.slang:28, "0.0" } + suffixType : float + value : 0.0 +} +VarExpr:83 { + astNodeType : VarExpr + loc : SourceLoc(1515212) tests/autodiff/reverse-loop.slang:28 + type : rvalue null + declRef : + name : "dpfloat" + originalExpr : null +} +VarExpr:84 { + astNodeType : VarExpr + loc : SourceLoc(1515271) tests/autodiff/reverse-loop.slang:30 + type : rvalue null + declRef : + name : "dpa" + originalExpr : null +} +FloatingPointLiteralExpr:85 { + astNodeType : FloatingPointLiteralExpr + loc : SourceLoc(1515276) tests/autodiff/reverse-loop.slang:30 + type : rvalue null + token : { floating-point literal, SourceLoc(1515276) tests/autodiff/reverse-loop.slang:30, "1.0f" } + suffixType : float + value : 1.0 +} +BackwardDifferentiateExpr:86 { + astNodeType : BackwardDifferentiateExpr + loc : SourceLoc(1515242) tests/autodiff/reverse-loop.slang:30 + type : rvalue null + baseFunction : VarExpr:100 + newParameterNames : { + } +} +IndexExpr:87 { + astNodeType : IndexExpr + loc : SourceLoc(1515304) tests/autodiff/reverse-loop.slang:31 + type : rvalue null + baseExpression : VarExpr:101 + indexExprs : { + IntegerLiteralExpr:102 + } + argumentDelimeterLocs : { + SourceLoc(1515304) tests/autodiff/reverse-loop.slang:31, + SourceLoc(1515306) tests/autodiff/reverse-loop.slang:31 + } +} +MemberExpr:88 { + astNodeType : MemberExpr + loc : SourceLoc(1515314) tests/autodiff/reverse-loop.slang:31 + type : rvalue null + declRef : + name : "d" + originalExpr : null + baseExpression : VarExpr:103 + memberOperatorLoc : SourceLoc(1515313) tests/autodiff/reverse-loop.slang:31 +} +FloatingPointLiteralExpr:89 { + astNodeType : FloatingPointLiteralExpr + loc : SourceLoc(1515379) tests/autodiff/reverse-loop.slang:35 + type : rvalue null + token : { floating-point literal, SourceLoc(1515379) tests/autodiff/reverse-loop.slang:35, "0.4" } + suffixType : float + value : 0.40000000000000002 +} +FloatingPointLiteralExpr:90 { + astNodeType : FloatingPointLiteralExpr + loc : SourceLoc(1515384) tests/autodiff/reverse-loop.slang:35 + type : rvalue null + token : { floating-point literal, SourceLoc(1515384) tests/autodiff/reverse-loop.slang:35, "0.0" } + suffixType : float + value : 0.0 +} +VarExpr:91 { + astNodeType : VarExpr + loc : SourceLoc(1515371) tests/autodiff/reverse-loop.slang:35 + type : rvalue null + declRef : + name : "dpfloat" + originalExpr : null +} +VarExpr:92 { + astNodeType : VarExpr + loc : SourceLoc(1515430) tests/autodiff/reverse-loop.slang:37 + type : rvalue null + declRef : + name : "dpa" + originalExpr : null +} +FloatingPointLiteralExpr:93 { + astNodeType : FloatingPointLiteralExpr + loc : SourceLoc(1515435) tests/autodiff/reverse-loop.slang:37 + type : rvalue null + token : { floating-point literal, SourceLoc(1515435) tests/autodiff/reverse-loop.slang:37, "1.0f" } + suffixType : float + value : 1.0 +} +BackwardDifferentiateExpr:94 { + astNodeType : BackwardDifferentiateExpr + loc : SourceLoc(1515401) tests/autodiff/reverse-loop.slang:37 + type : rvalue null + baseFunction : VarExpr:104 + newParameterNames : { + } +} +IndexExpr:95 { + astNodeType : IndexExpr + loc : SourceLoc(1515463) tests/autodiff/reverse-loop.slang:38 + type : rvalue null + baseExpression : VarExpr:105 + indexExprs : { + IntegerLiteralExpr:106 + } + argumentDelimeterLocs : { + SourceLoc(1515463) tests/autodiff/reverse-loop.slang:38, + SourceLoc(1515465) tests/autodiff/reverse-loop.slang:38 + } +} +MemberExpr:96 { + astNodeType : MemberExpr + loc : SourceLoc(1515473) tests/autodiff/reverse-loop.slang:38 + type : rvalue null + declRef : + name : "d" + originalExpr : null + baseExpression : VarExpr:107 + memberOperatorLoc : SourceLoc(1515472) tests/autodiff/reverse-loop.slang:38 +} +VarExpr:97 { + astNodeType : VarExpr + loc : SourceLoc(1515056) tests/autodiff/reverse-loop.slang:18 + type : rvalue null + declRef : + name : "t" + originalExpr : null +} +VarExpr:98 { + astNodeType : VarExpr + loc : SourceLoc(1515060) tests/autodiff/reverse-loop.slang:18 + type : rvalue null + declRef : + name : "t" + originalExpr : null +} +VarExpr:99 { + astNodeType : VarExpr + loc : SourceLoc(1515058) tests/autodiff/reverse-loop.slang:18 + type : rvalue null + declRef : + name : "*" + originalExpr : null +} +VarExpr:100 { + astNodeType : VarExpr + loc : SourceLoc(1515253) tests/autodiff/reverse-loop.slang:30 + type : rvalue null + declRef : + name : "test_simple_loop" + originalExpr : null +} +VarExpr:101 { + astNodeType : VarExpr + loc : SourceLoc(1515292) tests/autodiff/reverse-loop.slang:31 + type : rvalue null + declRef : + name : "outputBuffer" + originalExpr : null +} +IntegerLiteralExpr:102 { + astNodeType : IntegerLiteralExpr + loc : SourceLoc(1515305) tests/autodiff/reverse-loop.slang:31 + type : rvalue null + token : { integer literal, SourceLoc(1515305) tests/autodiff/reverse-loop.slang:31, "0" } + suffixType : int + value : 0 +} +VarExpr:103 { + astNodeType : VarExpr + loc : SourceLoc(1515310) tests/autodiff/reverse-loop.slang:31 + type : rvalue null + declRef : + name : "dpa" + originalExpr : null +} +VarExpr:104 { + astNodeType : VarExpr + loc : SourceLoc(1515412) tests/autodiff/reverse-loop.slang:37 + type : rvalue null + declRef : + name : "test_simple_loop" + originalExpr : null +} +VarExpr:105 { + astNodeType : VarExpr + loc : SourceLoc(1515451) tests/autodiff/reverse-loop.slang:38 + type : rvalue null + declRef : + name : "outputBuffer" + originalExpr : null +} +IntegerLiteralExpr:106 { + astNodeType : IntegerLiteralExpr + loc : SourceLoc(1515464) tests/autodiff/reverse-loop.slang:38 + type : rvalue null + token : { integer literal, SourceLoc(1515464) tests/autodiff/reverse-loop.slang:38, "1" } + suffixType : int + value : 1 +} +VarExpr:107 { + astNodeType : VarExpr + loc : SourceLoc(1515469) tests/autodiff/reverse-loop.slang:38 + type : rvalue null + declRef : + name : "dpa" + originalExpr : null +} diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index cdd2ca5b66..8881deedc5 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -757,6 +757,34 @@ Result linkAndOptimizeIR( if (requiredLoweringPassSet.autodiff) { dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-AUTODIFF"); + + //printf("Module (bwd diff functions) before autodiff pass:\n"); + ////irModule->getModuleInst()->dump(); + //IRModuleInst* module = irModule->getModuleInst(); + //for (auto inst : module->getGlobalInsts()) { + // auto func = as(inst); + // if (!func) + // continue; + + // if (!isBackwardDifferentiableFunc(func)) + // continue; + + // printf("=============================================\n"); + // func->dump(); + + // for (auto block : func->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + // inst->dump(); + + // if (inst->sourceLoc.isValid()) + // sink->diagnose(inst->sourceLoc, Diagnostics::seeDeclarationOf, inst); + // } + // } + //} + enableIRValidationAtInsert(); changed |= processAutodiffCalls(targetProgram, irModule, sink); disableIRValidationAtInsert(); diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index fe7c77ba06..f067ab303e 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -1607,6 +1607,9 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) auto tempVar = builder.emitVar(ptrType->getValueType()); param->replaceUsesWith(tempVar); mapParamToTempVar[param] = tempVar; + // TODO: link source locations for this? + printf("%s -> param:\n", __FUNCTION__); + param->dump(); if (ptrType->getOp() != kIROp_OutType) { builder.emitStore(tempVar, builder.emitLoad(param)); @@ -1716,6 +1719,18 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr // Create a clone for original func and run additional transformations on the clone. IRCloneEnv env; auto primalFuncClone = as(cloneInst(&env, &builder, primalFunc)); + + printf("(result from prepareFuncForForwardDiff)===============================\n"); + for (auto block : primalFuncClone->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } + prepareFuncForForwardDiff(primalFuncClone); builder.setInsertInto(diffFunc); @@ -1731,6 +1746,8 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr mapPrimalInst(block, diffBlock); mapDifferentialInst(block, diffBlock); } + + printf("(result from forward diff transcribe blocks)===============================\n"); // Now actually transcribe the content of each block. for (auto block = primalFuncClone->getFirstBlock(); block; block = block->getNextBlock()) diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index 9fe4ec70b6..b57e4441d3 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -316,6 +316,8 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( } }; + printf("### %s\n", __FUNCTION__); + // Populate recompute/store/invert sets with insts, by applying the policy // to them. // @@ -371,6 +373,13 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( if (result.mode == HoistResult::Mode::Store) { SLANG_ASSERT(!checkpointInfo->recomputeSet.contains(result.instToStore)); + printf("\n[#] %s, adding %p to storeSet\n", __FUNCTION__, result.instToStore); + result.instToStore->dump(); + IRInst* inst = result.instToStore; + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + checkpointInfo->storeSet.add(result.instToStore); } else if (result.mode == HoistResult::Mode::Recompute) @@ -465,6 +474,7 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( { checkpointInfo->recomputeSet.add(callUser); checkpointInfo->storeSet.remove(callUser); + printf("storeSet removing %p\n", callUser); if (instWorkListSet.add(callUser)) instWorkList.add(callUser); } @@ -472,6 +482,7 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( { checkpointInfo->recomputeSet.add(storeUser); checkpointInfo->storeSet.remove(storeUser); + printf("storeSet removing %p\n", storeUser); if (instWorkListSet.add(callUser)) instWorkList.add(callUser); } @@ -485,6 +496,7 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( { checkpointInfo->recomputeSet.add(varArg); checkpointInfo->storeSet.remove(varArg); + printf("storeSet removing %p\n", varArg); if (instWorkListSet.add(varArg)) instWorkList.add(varArg); } @@ -1875,6 +1887,17 @@ RefPtr applyCheckpointPolicy(IRGlobalValueWithCode* func) { sortBlocksInFunc(func); + printf("(checkpoint policy, got) ===============================\n"); + for (auto block : func->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } + // Insert loop counters and establish loop regions. // Also makes the reverse loops counting downwards from the final iteration count. // @@ -1896,10 +1919,20 @@ RefPtr applyCheckpointPolicy(IRGlobalValueWithCode* func) chkPolicy->preparePolicy(func); auto primalsInfo = chkPolicy->processFunc(func, recomputeBlockMap, cloneCtx, indexedBlockInfo); + // NOTE: (Mostly) original instructions are here... + printf("****** (before legalization) # of elements in the store set for hoistInfo: %d\n", primalsInfo->storeSet.getCount()); + for (auto stored : primalsInfo->storeSet) { + printf("source loc recorded: %d (%d)\n", + stored->sourceLoc.getRaw(), + stored->sourceLoc.isValid()); + stored->dump(); + } + // Legalize the primal inst accesses by introducing local variables / arrays and emitting // necessary load/store logic. // primalsInfo = ensurePrimalAvailability(primalsInfo, func, indexedBlockInfo); + return primalsInfo; } diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index 35a197f29b..abe4eb5f13 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -573,6 +573,16 @@ namespace Slang IRCloneEnv originalCloneEnv; primalOuterParent = cloneInst(&originalCloneEnv, builder, primalOuterParent); auto primalFunc = as(getGenericReturnVal(primalOuterParent)); + printf("(result from cloneInst)===============================\n"); + for (auto block : primalFunc->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } // Strip any existing derivative decorations off the clone. stripDerivativeDecorations(primalFunc); @@ -588,6 +598,7 @@ namespace Slang autoDiffSharedContext->transcriberSet.forwardTranscriber); auto oldCount = autoDiffSharedContext->followUpFunctionsToTranscribe.getCount(); IRFunc* fwdDiffFunc = as(getGenericReturnVal(fwdTranscriber.transcribe(builder, primalOuterParent))); + SLANG_ASSERT(fwdDiffFunc); auto newCount = autoDiffSharedContext->followUpFunctionsToTranscribe.getCount(); for (auto i = oldCount; i < newCount; i++) @@ -666,6 +677,21 @@ namespace Slang // Transcribe a function definition. void BackwardDiffTranscriberBase::transcribeFuncImpl(IRBuilder* builder, IRFunc* primalFunc, IRFunc* diffPropagateFunc) { + printf("(primalFunc)===============================\n"); + primalFunc->dump(); + + for (auto block : primalFunc->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + inst->dump(); + + if (inst->sourceLoc.isValid()) + getSink()->diagnose(inst->sourceLoc, Diagnostics::seeDeclarationOf, inst); + } + } + SLANG_ASSERT(primalFunc); SLANG_ASSERT(diffPropagateFunc); // Reverse-mode transcription uses 4 separate steps: @@ -686,6 +712,17 @@ namespace Slang if (!fwdDiffFunc) return; + printf("(fwdDiffFunc)===============================\n"); + for (auto block : fwdDiffFunc->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } + bool isResultDifferentiable = as(fwdDiffFunc->getResultType()); // Split first block into a paramter block. @@ -732,6 +769,17 @@ namespace Slang auto primalsInfo = applyCheckpointPolicy(diffPropagateFunc); eliminateDeadCode(diffPropagateFunc); + + printf("****** (after legalization) # of elements in the store set for hoistInfo: %d\n", primalsInfo->storeSet.getCount()); + for (auto stored : primalsInfo->storeSet) { + printf("source loc recorded: %d (%d)\n", + stored->sourceLoc.getRaw(), + stored->sourceLoc.isValid()); + stored->dump(); + getSink()->diagnose(stored->sourceLoc, Diagnostics::alsoSeePipelineDefinition); + + IRType* type = stored->getFullType(); + } // Extracts the primal computations into its own func, turn all accesses to stored primal insts into // explicit intermediate data structure reads and writes. diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp index da69ed8aea..51c35300ac 100644 --- a/source/slang/slang-ir-autodiff-transcriber-base.cpp +++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp @@ -1032,9 +1032,33 @@ InstPair AutoDiffTranscriberBase::transcribeInst(IRBuilder* builder, IRInst* ori // if (as(origInst->getParent()) && !as(origInst)) return InstPair(origInst, nullptr); + + printf("\n\ntranscribing an original instruction: %d (%d)\n", + origInst->sourceLoc.getRaw(), origInst->sourceLoc.isValid()); + printf(" >"); + origInst->dump(); auto result = transcribeInstImpl(builder, origInst); + printf("result:\n"); + if (result.primal) { + printf(" >"); + result.primal->dump(); + result.primal->sourceLoc = origInst->sourceLoc; + printf(" [P] source loc: %d (%d)\n", + result.primal->sourceLoc.getRaw(), + result.primal->sourceLoc.isValid()); + } + + if (result.differential) { + printf(" >"); + result.differential->dump(); + result.differential->sourceLoc = origInst->sourceLoc; + printf(" [D] source loc: %d (%d)\n", + result.differential->sourceLoc.getRaw(), + result.differential->sourceLoc.isValid()); + } + if (result.primal == nullptr && result.differential == nullptr) { if (auto origType = as(origInst)) diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp index 0979c097c4..02498ee10e 100644 --- a/source/slang/slang-ir-autodiff.cpp +++ b/source/slang/slang-ir-autodiff.cpp @@ -1951,18 +1951,21 @@ struct AutoDiffPass : public InstPassBase break; case kIROp_BackwardDifferentiatePrimal: { + printf("BACKWARD DIFFERENTIATE PRIMAL\n"); auto baseFunc = differentiateInst->getOperand(0); diffFunc = backwardPrimalTranscriber.transcribe(&subBuilder, baseFunc); } break; case kIROp_BackwardDifferentiatePropagate: { + printf("BACKWARD DIFFERENTIATE PROPOGATE\n"); auto baseFunc = differentiateInst->getOperand(0); diffFunc = backwardPropagateTranscriber.transcribe(&subBuilder, baseFunc); } break; case kIROp_BackwardDifferentiate: { + printf("BACKWARD DIFFERENTIATE\n"); auto baseFunc = differentiateInst->getOperand(0); diffFunc = backwardTranscriber.transcribe(&subBuilder, baseFunc); } diff --git a/source/slang/slang-ir-clone.cpp b/source/slang/slang-ir-clone.cpp index e2297bcb2c..c8ab23f83a 100644 --- a/source/slang/slang-ir-clone.cpp +++ b/source/slang/slang-ir-clone.cpp @@ -220,6 +220,8 @@ static void _cloneInstDecorationsAndChildren( auto oldType = oldParam->getFullType(); auto newType = (IRType*)findCloneForOperand(env, oldType); newParam->setFullType(newType); + + newParam->sourceLoc = oldParam->sourceLoc; } } diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index e44c4079b4..2c0790ccf8 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -431,6 +431,7 @@ PhiInfo* addPhi( RefPtr phiInfo = new PhiInfo(); context->phiInfos.add(phi, phiInfo); + phi->sourceLoc = var->sourceLoc; phiInfo->phi = phi; phiInfo->var = var; @@ -1107,6 +1108,24 @@ bool constructSSA(ConstructSSAContext* context) // and stores of promotable variables with simple values. auto globalVal = context->globalVal; + + auto func = as(globalVal); + bool dump = func->findDecoration (); + + //if (dump) { + // printf("(globalVal)===============================\n"); + // func->dump(); + + // //for (auto block : func->getBlocks()) { + // // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // // printf("inst with location: %d (%d)\n", + // // inst->sourceLoc.getRaw(), + // // inst->sourceLoc.isValid()); + // // inst->dump(); + // // } + // //} + //} + for(auto bb : globalVal->getBlocks()) { auto blockInfo = new SSABlockInfo(); @@ -1135,9 +1154,21 @@ bool constructSSA(ConstructSSAContext* context) auto blockInfo = *context->blockInfos.tryGetValue(bb); // First remove phis from their parent blocks. - for (auto phiInfo : blockInfo->phis) + for (auto phiInfo : blockInfo->phis) { + //if (dump) { + // printf("phiInfo:\n"); + // phiInfo->var->dump(); + // phiInfo->phi->dump(); + // printf(">> locations: %d (%d) & %d (%d)\n", + // phiInfo->var->sourceLoc.getRaw(), + // phiInfo->var->sourceLoc.isValid(), + // phiInfo->phi->sourceLoc.getRaw(), + // phiInfo->phi->sourceLoc.isValid()); + //} + if (!phiInfo->replacement) phiInfo->phi->removeFromParent(); + } // Then, add them back in a consistent order, and add predecessor // args in the same order. @@ -1237,7 +1268,13 @@ bool constructSSA(ConstructSSAContext* context) // TODO: do we need to be careful here in case one // of thes operations still has uses, as part of // another to-be-remvoed instruction? - + //if (dump) { + // printf("removing instruction:\n"); + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + // inst->dump(); + //} inst->removeAndDeallocate(); } @@ -1245,8 +1282,30 @@ bool constructSSA(ConstructSSAContext* context) // of of the variables for (auto var : context->promotableVars) { + //if (dump) { + // printf("removing variable:\n"); + // printf("inst with location: %d (%d)\n", + // var->sourceLoc.getRaw(), + // var->sourceLoc.isValid()); + // var->dump(); + //} var->removeAndDeallocate(); } + + //if (dump) { + // printf("<<<< (globalVal-END)===============================\n"); + // func->dump(); + + // for (auto block : func->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + // inst->dump(); + // } + // } + //} + return true; } diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 8134677437..dec214e60a 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -10318,6 +10318,21 @@ struct DeclLoweringVisitor : DeclVisitor // of global values. irFunc->moveToEnd(); + //printf("(lowered function) =============================================\n"); + //irFunc->dump(); + + //for (auto block : irFunc->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + // inst->dump(); + + // if (inst->sourceLoc.isValid()) + // getSink()->diagnose(inst->sourceLoc, Diagnostics::seeDeclarationOf, inst); + // } + //} + // If this function is defined inside an interface, add a reference to the IRFunc from // the interface's type definition. auto finalVal = finishOuterGenerics(subBuilder, irFunc, outerGeneric); From 95532d2551dbb4775e559c18faf8be01b48ae977 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Fri, 6 Sep 2024 13:18:42 -0700 Subject: [PATCH 02/32] Tracking for simple variables --- ad-report | 657 +++++++++++++++++- reverse-loop.slang-ast | 2 +- .../slang/slang-ir-autodiff-primal-hoist.cpp | 13 +- source/slang/slang-ir-autodiff-rev.cpp | 36 +- .../slang-ir-eliminate-multilevel-break.cpp | 36 + source/slang/slang-ir-eliminate-phis.cpp | 1 + source/slang/slang-ir-loop-unroll.cpp | 6 +- source/slang/slang-ir-ssa.cpp | 3 +- 8 files changed, 706 insertions(+), 48 deletions(-) diff --git a/ad-report b/ad-report index 9677515982..c5a5ab426e 100644 --- a/ad-report +++ b/ad-report @@ -120,7 +120,41 @@ return_val(%t) tests/autodiff/reverse-loop.slang(21): note: see declaration of '' return t; ^~~~~~ -(result from cloneInst)=============================== +(result before prepareFuncForBackwardDiff)=============================== +[primalInstDecoration] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %1( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%2, %3, %4, %y, 0 : Int) + +block %2( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %5 : Bool = cmpLT(%i, 3 : Int) + ifElse(%5, %6, %3, %6) + +block %6: + let %7 : Float = mul(%t, %t) + unconditionalBranch(%4) + +block %4: + let %8 : Int = add(%i, 1 : Int) + unconditionalBranch(%2, %7, %8) + +block %3: + return_val(%t) +} + inst with location: 1514954 (1) [nameHint("y")] let %y : Float = param @@ -158,11 +192,516 @@ unconditionalBranch(%1, %2, %3) inst with location: 1515077 (1) return_val(%t) +(result before eliminating phis)=============================== +[primalInstDecoration] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %1( + [nameHint("y")] + param %y : Float): + [loopMaxIters(4 : Int)] + loop(%2, %3, %2, %y, 0 : Int) + +block %2( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + loop(%4, %5, %4) + +block %4: + let %6 : Bool = cmpLT(%i, 3 : Int) + ifElse(%6, %7, %8, %7) + +block %8: + unconditionalBranch(%3) + +block %7: + let %9 : Float = mul(%t, %t) + unconditionalBranch(%5) + +block %5: + unconditionalBranch(%10) + +block %10: + let %11 : Int = add(%i, 1 : Int) + unconditionalBranch(%2, %9, %11) + +block %3: + return_val(%t) +} + +inst with location: 1514954 (1) +[nameHint("y")] +let %y : Float = param + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, %y, 0 : Int) + +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Int = param + +inst with location: 1515008 (1) +loop(%1, %2, %1) + +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %2) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515058 (1) +let %1 : Float = mul(%t, %t) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515032 (1) +let %1 : Int = add(%i, 1 : Int) + +inst with location: 1515008 (1) +unconditionalBranch(%1, %2, %3) + +inst with location: 1515077 (1) +return_val(%t) + +(result after eliminating phis)=============================== +[primalInstDecoration] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %1( + [nameHint("y")] + param %y : Float): + [nameHint("t")] + let %t : Ptr(Float) = var + [nameHint("i")] + let %i : Ptr(Int) = var + store(%t, %y) + store(%i, 0 : Int) + [loopMaxIters(4 : Int)] + loop(%2, %3, %2) + +block %2: + loop(%4, %5, %4) + +block %4: + let %6 : Int = load(%i) + let %7 : Bool = cmpLT(%6, 3 : Int) + ifElse(%7, %8, %9, %8) + +block %9: + unconditionalBranch(%3) + +block %8: + let %10 : Float = load(%t) + let %11 : Float = load(%t) + let %12 : Float = mul(%11, %10) + unconditionalBranch(%5) + +block %5: + unconditionalBranch(%13) + +block %13: + let %14 : Int = load(%i) + let %15 : Int = add(%14, 1 : Int) + store(%t, %12) + store(%i, %15) + unconditionalBranch(%2) + +block %3: + let %16 : Float = load(%t) + return_val(%16) +} + +inst with location: 1514954 (1) +[nameHint("y")] +let %y : Float = param + +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Ptr(Float) = var + +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Ptr(Int) = var + +inst with location: 0 (0) +store(%t, %y) + +inst with location: 0 (0) +store(%i, 0 : Int) + +inst with location: 0 (0) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1) + +inst with location: 1515008 (1) +loop(%1, %2, %1) + +inst with location: 0 (0) +let %1 : Int = load(%i) + +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%2, 3 : Int) + +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %2) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Float = load(%t) + +inst with location: 0 (0) +let %1 : Float = load(%t) + +inst with location: 1515058 (1) +let %1 : Float = mul(%2, %3) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Int = load(%i) + +inst with location: 1515032 (1) +let %1 : Int = add(%2, 1 : Int) + +inst with location: 0 (0) +store(%t, %1) + +inst with location: 0 (0) +store(%i, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Float = load(%t) + +inst with location: 1515077 (1) +return_val(%1) + +(result before normalizeCFG)=============================== +[primalInstDecoration] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %1( + [nameHint("y")] + param %y : Float): + [nameHint("t")] + let %t : Ptr(Float) = var + [nameHint("i")] + let %i : Ptr(Int) = var + store(%t, %y) + store(%i, 0 : Int) + [loopMaxIters(4 : Int)] + loop(%2, %3, %2) + +block %2: + loop(%4, %5, %4) + +block %4: + let %6 : Int = load(%i) + let %7 : Bool = cmpLT(%6, 3 : Int) + ifElse(%7, %8, %9, %8) + +block %9: + unconditionalBranch(%5, 0 : Int) + +block %8: + let %10 : Float = load(%t) + let %11 : Float = load(%t) + let %12 : Float = mul(%11, %10) + unconditionalBranch(%5, 1 : Int) + +block %5( + param %13 : Int): + unconditionalBranch(%14) + +block %15: + unconditionalBranch(%3) + +block %16: + unconditionalBranch(%17) + +block %14: + let %18 : Bool = cmpNE(%13, 1 : Int) + ifElse(%18, %15, %16, %16) + +block %17: + let %19 : Int = load(%i) + let %20 : Int = add(%19, 1 : Int) + store(%t, %12) + store(%i, %20) + unconditionalBranch(%2) + +block %3: + let %21 : Float = load(%t) + return_val(%21) + +block %22: + unreachable +} + +inst with location: 1514954 (1) +[nameHint("y")] +let %y : Float = param + +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Ptr(Float) = var + +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Ptr(Int) = var + +inst with location: 0 (0) +store(%t, %y) + +inst with location: 0 (0) +store(%i, 0 : Int) + +inst with location: 0 (0) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1) + +inst with location: 1515008 (1) +loop(%1, %2, %1) + +inst with location: 0 (0) +let %1 : Int = load(%i) + +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%2, 3 : Int) + +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %2) + +inst with location: 0 (0) +unconditionalBranch(%1, 0 : Int) + +inst with location: 0 (0) +let %1 : Float = load(%t) + +inst with location: 0 (0) +let %1 : Float = load(%t) + +inst with location: 1515058 (1) +let %1 : Float = mul(%2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, 1 : Int) + +inst with location: 0 (0) +let %1 : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %3) + +inst with location: 0 (0) +let %1 : Int = load(%i) + +inst with location: 1515032 (1) +let %1 : Int = add(%2, 1 : Int) + +inst with location: 0 (0) +store(%t, %1) + +inst with location: 0 (0) +store(%i, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Float = load(%t) + +inst with location: 1515077 (1) +return_val(%1) + +inst with location: 0 (0) +unreachable + +(result after prepareFuncForBackwardDiff)=============================== +inst with location: 1514954 (1) +[nameHint("y")] +let %y : Float = param + +inst with location: 0 (0) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %y, 0 : Int) + +inst with location: 0 (0) +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +let %1 : Bool = logicalAnd(true, %x5Fbflag) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515077 (1) +return_val(%t) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +let %1 : Int = undefined + +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %4) + +inst with location: 1515008 (1) +unconditionalBranch(%1, true, %2) + +inst with location: 0 (0) +unconditionalBranch(%1, false, 0 : Int) + +inst with location: 0 (0) +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +let %1 : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, 0 : Float) + +inst with location: 1515058 (1) +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +unconditionalBranch(%1, 1 : Int, %2) + +inst with location: 0 (0) +let %1 : Int = param + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %t, %i) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515032 (1) +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, %3) + +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag, %t, %i) + +inst with location: 0 (0) +unreachable + transcribing an original instruction: 154 (1) > result: +transcribing function with fwd mode: 0 (0, 1) (result from prepareFuncForForwardDiff)=============================== inst with location: 1514954 (1) [nameHint("y")] @@ -176,11 +715,11 @@ inst with location: 0 (0) [nameHint("_bflag")] let %x5Fbflag : Bool = param -inst with location: 0 (0) +inst with location: 1514994 (1) [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1515017 (1) [nameHint("i")] let %i : Int = param @@ -208,7 +747,7 @@ let %1 : Int = undefined inst with location: 1515008 (1) ifElse(%1, %2, %3, %4) -inst with location: 0 (0) +inst with location: 1515008 (1) unconditionalBranch(%1, true, %2) inst with location: 0 (0) @@ -273,7 +812,7 @@ ifElse(%x5Fbflag, %1, %2, %3) inst with location: 0 (0) unconditionalBranch(%1, %t, %i) -inst with location: 0 (0) +inst with location: 1515008 (1) unconditionalBranch(%1) inst with location: 1515032 (1) @@ -282,11 +821,11 @@ let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) unconditionalBranch(%1, %2, %3) -inst with location: 0 (0) +inst with location: 1514994 (1) [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1515017 (1) [nameHint("i")] let %i : Int = param @@ -355,7 +894,7 @@ let %x5Fbflag : Bool = param [P] source loc: 0 (0) -transcribing an original instruction: 0 (0) +transcribing an original instruction: 1514994 (1) >[nameHint("t")] let %t : Float = param @@ -363,13 +902,13 @@ result: >[nameHint("t")] let %t : Float = param - [P] source loc: 0 (0) + [P] source loc: 1514994 (1) >let %1 : Float = param - [D] source loc: 0 (0) + [D] source loc: 1514994 (1) -transcribing an original instruction: 0 (0) +transcribing an original instruction: 1515017 (1) >[nameHint("i")] let %i : Int = param @@ -382,7 +921,7 @@ result: >[nameHint("i")] let %i : Int = param - [P] source loc: 0 (0) + [P] source loc: 1515017 (1) transcribing an original instruction: 0 (0) @@ -707,7 +1246,7 @@ unconditionalBranch(%1, %2, %3, %4) [D] source loc: 0 (0) -transcribing an original instruction: 0 (0) +transcribing an original instruction: 1514994 (1) >[nameHint("t")] let %t : Float = param @@ -715,13 +1254,13 @@ result: >[nameHint("t")] let %t : Float = param - [P] source loc: 0 (0) + [P] source loc: 1514994 (1) >let %1 : Float = param - [D] source loc: 0 (0) + [D] source loc: 1514994 (1) -transcribing an original instruction: 0 (0) +transcribing an original instruction: 1515017 (1) >[nameHint("i")] let %i : Int = param @@ -734,7 +1273,7 @@ result: >[nameHint("i")] let %i : Int = param - [P] source loc: 0 (0) + [P] source loc: 1515017 (1) transcribing an original instruction: 0 (0) @@ -782,17 +1321,17 @@ inst with location: 0 (0) [nameHint("_bflag")] let %x5Fbflag : Bool = param -inst with location: 0 (0) +inst with location: 1514994 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1514994 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param -inst with location: 0 (0) +inst with location: 1515017 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -910,17 +1449,17 @@ inst with location: 0 (0) [mixedDiffInstDecoration()] unconditionalBranch(%1, %2, %3, %4) -inst with location: 0 (0) +inst with location: 1514994 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1514994 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param -inst with location: 0 (0) +inst with location: 1515017 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -968,12 +1507,12 @@ inst with location: 0 (0) [nameHint("_bflag")] let %x5Fbflag : Bool = param -inst with location: 0 (0) +inst with location: 1514994 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1515017 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -1235,12 +1774,12 @@ let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) unconditionalBranch(%1, %2, %3) -inst with location: 0 (0) +inst with location: 1514994 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1515017 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -1250,33 +1789,33 @@ unconditionalBranch(%1, %x5Fbflag, %t, %i) ### Slang::AutodiffCheckpointPolicyBase::processFunc -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4D8590 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40999E5E0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1514994 (1) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4D8590 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40999E5E0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 0 (0) +inst with location: 1514994 (1) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DC39DB40 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40997FB20 to storeSet 0 inst with location: 0 (0) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DC39D710 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40997F6F0 to storeSet 1 inst with location: 0 (0) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4D5760 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A4099977A0 to storeSet inst with location: 0 (0) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001F7DF4C3858 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A4099898A8 to storeSet [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] @@ -1284,7 +1823,7 @@ let %x5Fpc : Int = param inst with location: 0 (0) ****** (before legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 0 (0) +source loc recorded: 1514994 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param @@ -1295,12 +1834,54 @@ source loc recorded: 0 (0) [loopCounterDecoration] let %x5Fpc : Int = param +****** ensureInstAvailable +ensureInstAvailable, worklist element: +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + +>> LOOP COUNTER! +% localVar: +let %1 : Ptr(Int) = var + +ensureInstAvailable, worklist element: +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +% localVar: +let %1 : Ptr(Array(Float, 5 : Int)) = var + +ensureInstAvailable, worklist element: +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +>> NO OUT OF SCOPE USES +ensureInstAvailable, worklist element: +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +>> NO OUT OF SCOPE USES +ensureInstAvailable, worklist element: +[primalInstDecoration] +let %1 : Int = param + +>> NO OUT OF SCOPE USES +ensureInstAvailable, worklist element: +[primalInstDecoration] +let %1 : Bool = cmpLT(%2, 3 : Int) + +>> NO OUT OF SCOPE USES ****** (after legalization) # of elements in the store set for hoistInfo: 2 source loc recorded: 0 (0) let %1 : Ptr(Int) = var (0): note: also see pipeline definition -source loc recorded: 0 (0) +source loc recorded: 1514994 (1) let %1 : Ptr(Array(Float, 5 : Int)) = var -(0): note: also see pipeline definition +tests/autodiff/reverse-loop.slang(14): note: also see pipeline definition + float t = y; + ^ diff --git a/reverse-loop.slang-ast b/reverse-loop.slang-ast index f3861ed3f6..e11b448be8 100644 --- a/reverse-loop.slang-ast +++ b/reverse-loop.slang-ast @@ -20,7 +20,7 @@ ModuleDecl:0 { } closingSourceLoc : SourceLoc(1515508) tests/autodiff/reverse-loop.slang:41 ownedScope : ::?::reverse-loop - module : Unknown@0x000001f7c8db17f0 + module : Unknown@0x000001a479aaa050 mapDeclToAssociatedDecls : { } isInLegacyLanguage : 1 diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index b57e4441d3..92b33cc44c 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -1463,6 +1463,8 @@ RefPtr ensurePrimalAvailability( OrderedHashSet processedStoreSet; + printf("****** ensureInstAvailable\n"); + auto ensureInstAvailable = [&](OrderedHashSet& instSet, bool isRecomputeInst) { SLANG_ASSERT(!isDifferentialBlock(defaultVarBlock)); @@ -1476,6 +1478,9 @@ RefPtr ensurePrimalAvailability( { auto instToStore = workList.getLast(); workList.removeLast(); + + printf("ensureInstAvailable, worklist element:\n"); + instToStore->dump(); if (seenInstSet.contains(instToStore)) continue; @@ -1544,6 +1549,7 @@ RefPtr ensurePrimalAvailability( if (outOfScopeUses.getCount() == 0) { + printf(">> NO OUT OF SCOPE USES\n"); if (!isRecomputeInst) processedStoreSet.add(instToStore); seenInstSet.add(instToStore); @@ -1645,6 +1651,7 @@ RefPtr ensurePrimalAvailability( bool isLoopCounter = (instToStore->findDecoration() != nullptr); if (isLoopCounter) { + printf(">> LOOP COUNTER!\n"); defBlockIndices.removeAt(0); } else @@ -1655,6 +1662,7 @@ RefPtr ensurePrimalAvailability( setInsertAfterOrdinaryInst(&builder, instToStore); auto localVar = storeIndexedValue(&builder, varBlock, instToStore, defBlockIndices); + localVar->sourceLoc = instToStore->sourceLoc; for (auto use : outOfScopeUses) { @@ -1665,8 +1673,11 @@ RefPtr ensurePrimalAvailability( loadIndexedValue(&builder, localVar, defBlock, defBlockIndices, useBlockIndices)); } - if (!isRecomputeInst) + if (!isRecomputeInst) { + printf("%% localVar:\n"); + localVar->dump(); processedStoreSet.add(localVar); + } } seenInstSet.add(instToStore); diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index abe4eb5f13..189d662fb4 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -553,6 +553,18 @@ namespace Slang eliminateContinueBlocksInFunc(func->getModule(), func); eliminateMultiLevelBreakForFunc(func->getModule(), func); + + printf("(result before normalizeCFG)===============================\n"); + func->dump(); + for (auto block : func->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } IRCFGNormalizationPass cfgPass = {this->getSink()}; normalizeCFG(autoDiffSharedContext->moduleInst->getModule(), func, cfgPass); @@ -573,7 +585,13 @@ namespace Slang IRCloneEnv originalCloneEnv; primalOuterParent = cloneInst(&originalCloneEnv, builder, primalOuterParent); auto primalFunc = as(getGenericReturnVal(primalOuterParent)); - printf("(result from cloneInst)===============================\n"); + + // Strip any existing derivative decorations off the clone. + stripDerivativeDecorations(primalFunc); + eliminateDeadCode(primalOuterParent); + + printf("(result before prepareFuncForBackwardDiff)===============================\n"); + primalFunc->dump(); for (auto block : primalFunc->getBlocks()) { for (auto inst = block->getFirstInst(); inst; inst = inst->next) { printf("inst with location: %d (%d)\n", @@ -584,14 +602,21 @@ namespace Slang } } - // Strip any existing derivative decorations off the clone. - stripDerivativeDecorations(primalFunc); - eliminateDeadCode(primalOuterParent); - // Perform required transformations and simplifications on the original func to make it // reversible. if (SLANG_FAILED(prepareFuncForBackwardDiff(primalFunc))) return diffPropagateFunc; + + printf("(result after prepareFuncForBackwardDiff)===============================\n"); + for (auto block : primalFunc->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } // Forward transcribe the clone of the original func. ForwardDiffTranscriber& fwdTranscriber = *static_cast( @@ -603,6 +628,7 @@ namespace Slang auto newCount = autoDiffSharedContext->followUpFunctionsToTranscribe.getCount(); for (auto i = oldCount; i < newCount; i++) { + printf("transcribing function with fwd mode: %d (%d, %d)\n", i, oldCount, newCount); auto pendingTask = autoDiffSharedContext->followUpFunctionsToTranscribe.getLast(); autoDiffSharedContext->followUpFunctionsToTranscribe.removeLast(); SLANG_RELEASE_ASSERT(pendingTask.type == FuncBodyTranscriptionTaskType::Forward); diff --git a/source/slang/slang-ir-eliminate-multilevel-break.cpp b/source/slang/slang-ir-eliminate-multilevel-break.cpp index eafdbbcec6..210debef77 100644 --- a/source/slang/slang-ir-eliminate-multilevel-break.cpp +++ b/source/slang/slang-ir-eliminate-multilevel-break.cpp @@ -303,6 +303,18 @@ struct EliminateMultiLevelBreakContext void processFunc(IRGlobalValueWithCode* func) { + //printf("(result before branch normalization)===============================\n"); + //func->dump(); + //for (auto block : func->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + + // inst->dump(); + // } + //} + normalizeBranchesIntoBreakBlocks(func); // If func does not have any multi-level breaks, return. @@ -313,9 +325,33 @@ struct EliminateMultiLevelBreakContext if (funcInfo.multiLevelBreaks.getCount() == 0) return; } + + printf("(result before eliminating phis)===============================\n"); + func->dump(); + for (auto block : func->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } // To make things easy, eliminate Phis before perform transformations. eliminatePhisInFunc(LivenessMode::Disabled, irModule, func, PhiEliminationOptions::getFast()); + + printf("(result after eliminating phis)===============================\n"); + func->dump(); + for (auto block : func->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } // Before modifying the cfg, we gather all required info from the existing cfg. FuncContext funcInfo; diff --git a/source/slang/slang-ir-eliminate-phis.cpp b/source/slang/slang-ir-eliminate-phis.cpp index b17fad6ec0..e62b88f0d7 100644 --- a/source/slang/slang-ir-eliminate-phis.cpp +++ b/source/slang/slang-ir-eliminate-phis.cpp @@ -462,6 +462,7 @@ struct PhiEliminationContext // to the temporary that will replace it. // param->transferDecorationsTo(temp); + temp->sourceLoc = param->sourceLoc; } // The other main auxilliary sxtructure is used to track diff --git a/source/slang/slang-ir-loop-unroll.cpp b/source/slang/slang-ir-loop-unroll.cpp index 753c930a86..c3aadac0fd 100644 --- a/source/slang/slang-ir-loop-unroll.cpp +++ b/source/slang/slang-ir-loop-unroll.cpp @@ -544,13 +544,15 @@ void eliminateContinueBlocks(IRModule* module, IRLoop* loopInst) moveParams(innerBreakableRegionHeader, targetBlock); builder.setInsertInto(innerBreakableRegionHeader); - builder.emitLoop(targetBlock, innerBreakableRegionBreakBlock, targetBlock); + auto innerLoop = builder.emitLoop(targetBlock, innerBreakableRegionBreakBlock, targetBlock); + innerLoop->sourceLoc = loopInst->sourceLoc; continueBlock->replaceUsesWith(innerBreakableRegionBreakBlock); builder.setInsertInto(innerBreakableRegionBreakBlock); moveParams(innerBreakableRegionBreakBlock, continueBlock); - builder.emitBranch(continueBlock); + auto unconditionalBranch = builder.emitBranch(continueBlock); + unconditionalBranch->sourceLoc = loopInst->sourceLoc; // If the original loop can be executed up to N times, the new loop may be executed // upto N+1 times (although most insts are skipped in the last traversal) diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index 2c0790ccf8..8ff1b0f286 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -985,7 +985,8 @@ void IRBuilder::insertBlockAlongEdge( // The edge block should branch (unconditionally) // to the successor block. builder.setInsertInto(edgeBlock); - builder.emitBranch(succ); + auto unconditionalBranch = builder.emitBranch(succ); + unconditionalBranch->sourceLoc = edgeUse->getUser()->sourceLoc; // Insert the new block into the block list // for the function. From bae1c7135ff03981d1ee8ef3cf20bb4b547c1693 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Fri, 6 Sep 2024 15:39:29 -0700 Subject: [PATCH 03/32] Deriving source locations for loop counters --- ad-report | 1683 ++++++----------- reverse-loop.slang-ast | 2 +- source/slang/slang-ir-autodiff-fwd.cpp | 35 +- .../slang/slang-ir-autodiff-primal-hoist.cpp | 34 +- source/slang/slang-ir-autodiff-region.cpp | 2 +- source/slang/slang-ir-autodiff-rev.cpp | 103 +- .../slang-ir-autodiff-transcriber-base.cpp | 30 +- source/slang/slang-ir-autodiff-unzip.h | 28 +- .../slang-ir-eliminate-multilevel-break.cpp | 14 +- source/slang/slang-ir-eliminate-phis.cpp | 6 +- 10 files changed, 760 insertions(+), 1177 deletions(-) diff --git a/ad-report b/ad-report index c5a5ab426e..1c9825ec86 100644 --- a/ad-report +++ b/ad-report @@ -1,240 +1,8 @@ BACKWARD DIFFERENTIATE - - -transcribing an original instruction: 154 (1) - > -result: BACKWARD DIFFERENTIATE BACKWARD DIFFERENTIATE PRIMAL BACKWARD DIFFERENTIATE PROPOGATE - - -transcribing an original instruction: 154 (1) - > -result: -(primalFunc)=============================== -[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] -[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] -[primalInstDecoration] -[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %1( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%2, %3, %4, %y, 0 : Int) - -block %2( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %5 : Bool = cmpLT(%i, 3 : Int) - ifElse(%5, %6, %3, %6) - -block %6: - let %7 : Float = mul(%t, %t) - unconditionalBranch(%4) - -block %4: - let %8 : Int = add(%i, 1 : Int) - unconditionalBranch(%2, %7, %8) - -block %3: - return_val(%t) -} - -inst with location: 1514954 (1) -[nameHint("y")] -let %y : Float = param - -tests/autodiff/reverse-loop.slang(12): note: see declaration of 'y' -float test_simple_loop(float y) - ^~~~~~~~~~~~~~~~ -inst with location: 1515008 (1) -[loopMaxIters(3 : Int)] -loop(%1, %2, %3, %y, 0 : Int) - -tests/autodiff/reverse-loop.slang(16): note: see declaration of '' - for (int i = 0; i < 3; i++) - ^~~ -inst with location: 1514994 (1) -[nameHint("t")] -let %t : Float = param - -tests/autodiff/reverse-loop.slang(14): note: see declaration of 't' - float t = y; - ^ -inst with location: 1515017 (1) -[nameHint("i")] -let %i : Int = param - -tests/autodiff/reverse-loop.slang(16): note: see declaration of 'i' - for (int i = 0; i < 3; i++) - ^ -inst with location: 1515026 (1) -let %1 : Bool = cmpLT(%i, 3 : Int) - -tests/autodiff/reverse-loop.slang(16): note: see declaration of '' - for (int i = 0; i < 3; i++) - ^ -inst with location: 1515008 (1) -ifElse(%1, %2, %3, %2) - -tests/autodiff/reverse-loop.slang(16): note: see declaration of '' - for (int i = 0; i < 3; i++) - ^~~ -inst with location: 1515058 (1) -let %1 : Float = mul(%t, %t) - -tests/autodiff/reverse-loop.slang(18): note: see declaration of '' - t = t * t; - ^ -inst with location: 1515008 (1) -unconditionalBranch(%1) - -tests/autodiff/reverse-loop.slang(16): note: see declaration of '' - for (int i = 0; i < 3; i++) - ^~~ -inst with location: 1515032 (1) -let %1 : Int = add(%i, 1 : Int) - -tests/autodiff/reverse-loop.slang(16): note: see declaration of '' - for (int i = 0; i < 3; i++) - ^~ -inst with location: 1515008 (1) -unconditionalBranch(%1, %2, %3) - -tests/autodiff/reverse-loop.slang(16): note: see declaration of '' - for (int i = 0; i < 3; i++) - ^~~ -inst with location: 1515077 (1) -return_val(%t) - -tests/autodiff/reverse-loop.slang(21): note: see declaration of '' - return t; - ^~~~~~ -(result before prepareFuncForBackwardDiff)=============================== -[primalInstDecoration] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %1( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%2, %3, %4, %y, 0 : Int) - -block %2( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %5 : Bool = cmpLT(%i, 3 : Int) - ifElse(%5, %6, %3, %6) - -block %6: - let %7 : Float = mul(%t, %t) - unconditionalBranch(%4) - -block %4: - let %8 : Int = add(%i, 1 : Int) - unconditionalBranch(%2, %7, %8) - -block %3: - return_val(%t) -} - -inst with location: 1514954 (1) -[nameHint("y")] -let %y : Float = param - -inst with location: 1515008 (1) -[loopMaxIters(3 : Int)] -loop(%1, %2, %3, %y, 0 : Int) - -inst with location: 1514994 (1) -[nameHint("t")] -let %t : Float = param - -inst with location: 1515017 (1) -[nameHint("i")] -let %i : Int = param - -inst with location: 1515026 (1) -let %1 : Bool = cmpLT(%i, 3 : Int) - -inst with location: 1515008 (1) -ifElse(%1, %2, %3, %2) - -inst with location: 1515058 (1) -let %1 : Float = mul(%t, %t) - -inst with location: 1515008 (1) -unconditionalBranch(%1) - -inst with location: 1515032 (1) -let %1 : Int = add(%i, 1 : Int) - -inst with location: 1515008 (1) -unconditionalBranch(%1, %2, %3) - -inst with location: 1515077 (1) -return_val(%t) - (result before eliminating phis)=============================== -[primalInstDecoration] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %1( - [nameHint("y")] - param %y : Float): - [loopMaxIters(4 : Int)] - loop(%2, %3, %2, %y, 0 : Int) - -block %2( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - loop(%4, %5, %4) - -block %4: - let %6 : Bool = cmpLT(%i, 3 : Int) - ifElse(%6, %7, %8, %7) - -block %8: - unconditionalBranch(%3) - -block %7: - let %9 : Float = mul(%t, %t) - unconditionalBranch(%5) - -block %5: - unconditionalBranch(%10) - -block %10: - let %11 : Int = add(%i, 1 : Int) - unconditionalBranch(%2, %9, %11) - -block %3: - return_val(%t) -} - inst with location: 1514954 (1) [nameHint("y")] let %y : Float = param @@ -281,513 +49,392 @@ unconditionalBranch(%1, %2, %3) inst with location: 1515077 (1) return_val(%t) -(result after eliminating phis)=============================== -[primalInstDecoration] -[readNone] +(fwdDiffFunc from generateNewForwardDerivative)=============================== +[FloatingPointModeOverride(1 : Int)] [DifferentiableTypeDictionaryDecoration] [backwardDifferentiable] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) +[forwardDifferentiable] +[nameHint("s_fwd_test_simple_loop")] +func %sx5Ffwdx5Ftestx5Fsimplex5Floop : Func(DiffPair(Float, %1), DiffPair(Float, %1)) { -block %1( - [nameHint("y")] - param %y : Float): - [nameHint("t")] - let %t : Ptr(Float) = var - [nameHint("i")] - let %i : Ptr(Int) = var - store(%t, %y) - store(%i, 0 : Int) +block %2( + [nameHint("dpy")] + param %dpy : DiffPair(Float, %1)): + [diffInstDecoration(Float)] + let %3 : Float = GetDifferential(%dpy) + [primalInstDecoration] + let %4 : Float = GetPrimal(%dpy) + [mixedDiffInstDecoration()] [loopMaxIters(4 : Int)] - loop(%2, %3, %2) + loop(%5, %6, %5, true, %4, %3, 0 : Int) -block %2: - loop(%4, %5, %4) +block %5( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t : Float, + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft : Float, + [primalInstDecoration] + [nameHint("i")] + param %i : Int): + [mixedDiffInstDecoration()] + ifElse(%x5Fbflag, %7, %8, %7) -block %4: - let %6 : Int = load(%i) - let %7 : Bool = cmpLT(%6, 3 : Int) - ifElse(%7, %8, %9, %8) +block %8: + [mixedDiffInstDecoration()] + unconditionalBranch(%6) -block %9: - unconditionalBranch(%3) +block %6: + [mixedDiffInstDecoration(DiffPair(Float, %1))] + let %9 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + [mixedDiffInstDecoration(DiffPair(Float, %1))] + return_val(%9) -block %8: - let %10 : Float = load(%t) - let %11 : Float = load(%t) - let %12 : Float = mul(%11, %10) - unconditionalBranch(%5) +block %7: + [mixedDiffInstDecoration()] + unconditionalBranch(%10) -block %5: - unconditionalBranch(%13) +block %10: + [primalInstDecoration] + let %11 : Bool = cmpLT(%i, 3 : Int) + [mixedDiffInstDecoration()] + ifElse(%11, %12, %13, %14) block %13: - let %14 : Int = load(%i) - let %15 : Int = add(%14, 1 : Int) - store(%t, %12) - store(%i, %15) - unconditionalBranch(%2) - -block %3: - let %16 : Float = load(%t) - return_val(%16) + [diffInstDecoration(Float)] + let %15 : Float = call %floatx5Fdzero() + [mixedDiffInstDecoration()] + unconditionalBranch(%14, 0 : Int, 0 : Float, %15) + +block %12: + [primalInstDecoration] + let %16 : Float = mul(%t, %t) + [diffInstDecoration(Float)] + let %17 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %18 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %19 : Float = add(%17, %18) + [mixedDiffInstDecoration()] + unconditionalBranch(%14, 1 : Int, %16, %19) + +block %14( + [primalInstDecoration] + param %20 : Int, + [primalInstDecoration] + param %21 : Float, + [diffInstDecoration(Float)] + param %22 : Float): + [mixedDiffInstDecoration()] + unconditionalBranch(%23) + +block %23: + [primalInstDecoration] + let %24 : Bool = cmpNE(%20, 1 : Int) + [mixedDiffInstDecoration()] + ifElse(%24, %25, %26, %27) + +block %26: + [mixedDiffInstDecoration()] + unconditionalBranch(%27, %x5Fbflag) + +block %25: + [mixedDiffInstDecoration()] + unconditionalBranch(%27, false) + +block %27( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + [mixedDiffInstDecoration()] + unconditionalBranch(%28) + +block %28: + [mixedDiffInstDecoration()] + ifElse(%x5Fbflag1, %29, %30, %31) + +block %30: + [mixedDiffInstDecoration()] + unconditionalBranch(%31, %t, %sx5Fdiffx5Ft, %i) + +block %29: + [primalInstDecoration] + let %32 : Int = add(%i, 1 : Int) + [mixedDiffInstDecoration()] + unconditionalBranch(%31, %21, %22, %32) + +block %31( + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int): + [mixedDiffInstDecoration()] + unconditionalBranch(%5, %x5Fbflag1, %t1, %sx5Fdiffx5Ft1, %i1) } -inst with location: 1514954 (1) -[nameHint("y")] -let %y : Float = param - -inst with location: 1514994 (1) -[nameHint("t")] -let %t : Ptr(Float) = var - -inst with location: 1515017 (1) -[nameHint("i")] -let %i : Ptr(Int) = var - -inst with location: 0 (0) -store(%t, %y) - -inst with location: 0 (0) -store(%i, 0 : Int) - -inst with location: 0 (0) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1) - -inst with location: 1515008 (1) -loop(%1, %2, %1) - -inst with location: 0 (0) -let %1 : Int = load(%i) - -inst with location: 1515026 (1) -let %1 : Bool = cmpLT(%2, 3 : Int) - -inst with location: 1515008 (1) -ifElse(%1, %2, %3, %2) - -inst with location: 1515008 (1) -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : Float = load(%t) - -inst with location: 0 (0) -let %1 : Float = load(%t) - -inst with location: 1515058 (1) -let %1 : Float = mul(%2, %3) - -inst with location: 1515008 (1) -unconditionalBranch(%1) - -inst with location: 1515008 (1) -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : Int = load(%i) - -inst with location: 1515032 (1) -let %1 : Int = add(%2, 1 : Int) - inst with location: 0 (0) -store(%t, %1) - -inst with location: 0 (0) -store(%i, %1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : Float = load(%t) - -inst with location: 1515077 (1) -return_val(%1) - -(result before normalizeCFG)=============================== -[primalInstDecoration] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %1( - [nameHint("y")] - param %y : Float): - [nameHint("t")] - let %t : Ptr(Float) = var - [nameHint("i")] - let %i : Ptr(Int) = var - store(%t, %y) - store(%i, 0 : Int) - [loopMaxIters(4 : Int)] - loop(%2, %3, %2) - -block %2: - loop(%4, %5, %4) - -block %4: - let %6 : Int = load(%i) - let %7 : Bool = cmpLT(%6, 3 : Int) - ifElse(%7, %8, %9, %8) - -block %9: - unconditionalBranch(%5, 0 : Int) - -block %8: - let %10 : Float = load(%t) - let %11 : Float = load(%t) - let %12 : Float = mul(%11, %10) - unconditionalBranch(%5, 1 : Int) - -block %5( - param %13 : Int): - unconditionalBranch(%14) - -block %15: - unconditionalBranch(%3) - -block %16: - unconditionalBranch(%17) - -block %14: - let %18 : Bool = cmpNE(%13, 1 : Int) - ifElse(%18, %15, %16, %16) - -block %17: - let %19 : Int = load(%i) - let %20 : Int = add(%19, 1 : Int) - store(%t, %12) - store(%i, %20) - unconditionalBranch(%2) - -block %3: - let %21 : Float = load(%t) - return_val(%21) - -block %22: - unreachable -} +[nameHint("dpy")] +let %dpy : DiffPair(Float, %1) = param inst with location: 1514954 (1) -[nameHint("y")] -let %y : Float = param - -inst with location: 1514994 (1) -[nameHint("t")] -let %t : Ptr(Float) = var - -inst with location: 1515017 (1) -[nameHint("i")] -let %i : Ptr(Int) = var - -inst with location: 0 (0) -store(%t, %y) - -inst with location: 0 (0) -store(%i, 0 : Int) - -inst with location: 0 (0) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1) - -inst with location: 1515008 (1) -loop(%1, %2, %1) - -inst with location: 0 (0) -let %1 : Int = load(%i) - -inst with location: 1515026 (1) -let %1 : Bool = cmpLT(%2, 3 : Int) - -inst with location: 1515008 (1) -ifElse(%1, %2, %3, %2) - -inst with location: 0 (0) -unconditionalBranch(%1, 0 : Int) - -inst with location: 0 (0) -let %1 : Float = load(%t) - -inst with location: 0 (0) -let %1 : Float = load(%t) - -inst with location: 1515058 (1) -let %1 : Float = mul(%2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int) - -inst with location: 0 (0) -let %1 : Int = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 1515008 (1) -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : Bool = cmpNE(%2, 1 : Int) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %3) - -inst with location: 0 (0) -let %1 : Int = load(%i) - -inst with location: 1515032 (1) -let %1 : Int = add(%2, 1 : Int) - -inst with location: 0 (0) -store(%t, %1) - -inst with location: 0 (0) -store(%i, %1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : Float = load(%t) - -inst with location: 1515077 (1) -return_val(%1) - -inst with location: 0 (0) -unreachable +[diffInstDecoration(Float)] +let %1 : Float = GetDifferential(%dpy) -(result after prepareFuncForBackwardDiff)=============================== inst with location: 1514954 (1) -[nameHint("y")] -let %y : Float = param +[primalInstDecoration] +let %1 : Float = GetPrimal(%dpy) -inst with location: 0 (0) +inst with location: 1515008 (1) +[mixedDiffInstDecoration()] [loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %y, 0 : Int) +loop(%1, %2, %1, true, %3, %4, 0 : Int) inst with location: 0 (0) +[primalInstDecoration] [nameHint("_bflag")] let %x5Fbflag : Bool = param inst with location: 1514994 (1) +[primalInstDecoration] [nameHint("t")] let %t : Float = param +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + inst with location: 1515017 (1) +[primalInstDecoration] [nameHint("i")] let %i : Int = param inst with location: 0 (0) -let %1 : Bool = logicalAnd(true, %x5Fbflag) +[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %1) inst with location: 0 (0) -ifElse(%1, %2, %3, %2) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) inst with location: 0 (0) -unconditionalBranch(%1) +[mixedDiffInstDecoration(DiffPair(Float, %1))] +let %2 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) inst with location: 1515077 (1) -return_val(%t) +[mixedDiffInstDecoration(DiffPair(Float, %1))] +return_val(%2) inst with location: 0 (0) +[mixedDiffInstDecoration()] unconditionalBranch(%1) inst with location: 1515026 (1) +[primalInstDecoration] let %1 : Bool = cmpLT(%i, 3 : Int) inst with location: 0 (0) -let %1 : Int = undefined - -inst with location: 1515008 (1) +[mixedDiffInstDecoration()] ifElse(%1, %2, %3, %4) -inst with location: 1515008 (1) -unconditionalBranch(%1, true, %2) - -inst with location: 0 (0) -unconditionalBranch(%1, false, 0 : Int) - inst with location: 0 (0) -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +[diffInstDecoration(Float)] +let %1 : Float = call %floatx5Fdzero() inst with location: 0 (0) -let %1 : Int = param +[mixedDiffInstDecoration()] +unconditionalBranch(%1, 0 : Int, 0 : Float, %2) -inst with location: 0 (0) -unconditionalBranch(%1) +inst with location: 1515058 (1) +[primalInstDecoration] +let %1 : Float = mul(%t, %t) inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) inst with location: 0 (0) -unconditionalBranch(%1, %2, 0 : Float) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) inst with location: 1515058 (1) -let %1 : Float = mul(%t, %t) +[diffInstDecoration(Float)] +let %1 : Float = add(%2, %3) inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int, %2) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, 1 : Int, %2, %3) inst with location: 0 (0) +[primalInstDecoration] let %1 : Int = param inst with location: 0 (0) +[primalInstDecoration] let %1 : Float = param inst with location: 0 (0) -unconditionalBranch(%1) +[diffInstDecoration(Float)] +let %1 : Float = param inst with location: 0 (0) +[mixedDiffInstDecoration()] unconditionalBranch(%1) inst with location: 0 (0) +[primalInstDecoration] let %1 : Bool = cmpNE(%2, 1 : Int) inst with location: 0 (0) +[mixedDiffInstDecoration()] ifElse(%1, %2, %3, %4) inst with location: 0 (0) +[mixedDiffInstDecoration()] unconditionalBranch(%1, %x5Fbflag) inst with location: 0 (0) +[mixedDiffInstDecoration()] unconditionalBranch(%1, false) inst with location: 0 (0) +[primalInstDecoration] [nameHint("_bflag")] let %x5Fbflag : Bool = param inst with location: 0 (0) +[mixedDiffInstDecoration()] unconditionalBranch(%1) inst with location: 0 (0) +[mixedDiffInstDecoration()] ifElse(%x5Fbflag, %1, %2, %3) inst with location: 0 (0) -unconditionalBranch(%1, %t, %i) - -inst with location: 1515008 (1) -unconditionalBranch(%1) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) inst with location: 1515032 (1) +[primalInstDecoration] let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) -unconditionalBranch(%1, %2, %3) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %2, %3, %4) inst with location: 1514994 (1) +[primalInstDecoration] [nameHint("t")] let %t : Float = param +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + inst with location: 1515017 (1) +[primalInstDecoration] [nameHint("i")] let %i : Int = param inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag, %t, %i) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) + +(diffPropagateFunc after unzipping)=============================== +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)); -inst with location: 0 (0) -unreachable +(unzipDiffInsts)=============================== +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : DiffPair(Float, %1) = param +inst with location: 0 (0) +let %1 : Float = PrimalParamRef(%dpy) -transcribing an original instruction: 154 (1) - > -result: -transcribing function with fwd mode: 0 (0, 1) -(result from prepareFuncForForwardDiff)=============================== -inst with location: 1514954 (1) -[nameHint("y")] -let %y : Float = param +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = DiffParamRef(%dpy) inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515008 (1) [loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %y, 0 : Int) +loop(%1, %2, %1, true, %3, 0 : Int) inst with location: 0 (0) +[primalInstDecoration] [nameHint("_bflag")] let %x5Fbflag : Bool = param inst with location: 1514994 (1) +[primalInstDecoration] [nameHint("t")] let %t : Float = param inst with location: 1515017 (1) +[primalInstDecoration] [nameHint("i")] let %i : Int = param inst with location: 0 (0) -let %1 : Bool = logicalAnd(true, %x5Fbflag) +ifElse(%x5Fbflag, %1, %2, %1) inst with location: 0 (0) -ifElse(%1, %2, %3, %2) +unconditionalBranch(%1) inst with location: 0 (0) +[BackwardDerivativePrimalReturnDecoration(%t)] unconditionalBranch(%1) -inst with location: 1515077 (1) -return_val(%t) - inst with location: 0 (0) unconditionalBranch(%1) inst with location: 1515026 (1) +[primalInstDecoration] let %1 : Bool = cmpLT(%i, 3 : Int) inst with location: 0 (0) -let %1 : Int = undefined - -inst with location: 1515008 (1) ifElse(%1, %2, %3, %4) -inst with location: 1515008 (1) -unconditionalBranch(%1, true, %2) - -inst with location: 0 (0) -unconditionalBranch(%1, false, 0 : Int) - -inst with location: 0 (0) -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 0 (0) -let %1 : Int = param - inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %2, 0 : Float) +unconditionalBranch(%1, 0 : Int, 0 : Float) inst with location: 1515058 (1) +[primalInstDecoration] let %1 : Float = mul(%t, %t) inst with location: 0 (0) unconditionalBranch(%1, 1 : Int, %2) inst with location: 0 (0) +[primalInstDecoration] let %1 : Int = param inst with location: 0 (0) +[primalInstDecoration] let %1 : Float = param inst with location: 0 (0) unconditionalBranch(%1) inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) +[primalInstDecoration] let %1 : Bool = cmpNE(%2, 1 : Int) inst with location: 0 (0) @@ -800,6 +447,7 @@ inst with location: 0 (0) unconditionalBranch(%1, false) inst with location: 0 (0) +[primalInstDecoration] [nameHint("_bflag")] let %x5Fbflag : Bool = param @@ -812,509 +460,300 @@ ifElse(%x5Fbflag, %1, %2, %3) inst with location: 0 (0) unconditionalBranch(%1, %t, %i) -inst with location: 1515008 (1) -unconditionalBranch(%1) - inst with location: 1515032 (1) +[primalInstDecoration] let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) unconditionalBranch(%1, %2, %3) inst with location: 1514994 (1) +[primalInstDecoration] [nameHint("t")] let %t : Float = param inst with location: 1515017 (1) +[primalInstDecoration] [nameHint("i")] let %i : Int = param inst with location: 0 (0) unconditionalBranch(%1, %x5Fbflag, %t, %i) -inst with location: 0 (0) -unreachable - -(result from forward diff transcribe blocks)=============================== - - -transcribing an original instruction: 1514954 (1) - >[nameHint("y")] -let %y : Float = param - -result: - >let %1 : Float = GetPrimal(%dpy) - - [P] source loc: 1514954 (1) - >let %1 : Float = GetDifferential(%dpy) - - [D] source loc: 1514954 (1) - - -transcribing an original instruction: 0 (0) - >[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %y, 0 : Int) - - - -transcribing an original instruction: 3068 (1) - > -result: - - -transcribing an original instruction: 204 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, %4, 0 : Int) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 1515008 (1) [loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, %4, 0 : Int) - - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >[nameHint("_bflag")] -let %x5Fbflag : Bool = param - - - -transcribing an original instruction: 3068 (1) - > -result: -result: - >[nameHint("_bflag")] -let %x5Fbflag : Bool = param - - [P] source loc: 0 (0) - - -transcribing an original instruction: 1514994 (1) - >[nameHint("t")] -let %t : Float = param - -result: - >[nameHint("t")] -let %t : Float = param - - [P] source loc: 1514994 (1) - >let %1 : Float = param - - [D] source loc: 1514994 (1) - - -transcribing an original instruction: 1515017 (1) - >[nameHint("i")] -let %i : Int = param - - - -transcribing an original instruction: 204 (1) - > -result: -result: - >[nameHint("i")] -let %i : Int = param +loop(%1, %2, %1, %3) - [P] source loc: 1515017 (1) - - -transcribing an original instruction: 0 (0) - >ifElse(%x5Fbflag, %1, %2, %1) - -result: - >[mixedDiffInstDecoration()] -ifElse(%x5Fbflag, %1, %2, %1) +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) ifElse(%x5Fbflag, %1, %2, %1) - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1) - -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) unconditionalBranch(%1) - [D] source loc: 0 (0) - - -transcribing an original instruction: 1515077 (1) - >return_val(%t) - -result: - >[mixedDiffInstDecoration(DiffPair(Float, %1))] -return_val(%2) - - [P] source loc: 1515077 (1) - >[mixedDiffInstDecoration(DiffPair(Float, %1))] -return_val(%2) - - [D] source loc: 1515077 (1) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1) +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1) +inst with location: 0 (0) +[diffInstDecoration(Float)] +return_val(%1) - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) unconditionalBranch(%1) - [D] source loc: 0 (0) - - -transcribing an original instruction: 1515026 (1) - >let %1 : Bool = cmpLT(%i, 3 : Int) - -result: - >let %1 : Bool = cmpLT(%i, 3 : Int) - - [P] source loc: 1515026 (1) - - -transcribing an original instruction: 0 (0) - >ifElse(%1, %2, %3, %4) - -result: - >[mixedDiffInstDecoration()] -ifElse(%1, %2, %3, %4) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) ifElse(%1, %2, %3, %4) - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1, 0 : Int, 0 : Float) - - - -transcribing an original instruction: 204 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, 0 : Int, 0 : Float, %2) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, 0 : Int, 0 : Float, %2) - - [D] source loc: 0 (0) +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = call %floatx5Fdzero() +inst with location: 0 (0) +unconditionalBranch(%1, %2) -transcribing an original instruction: 1515058 (1) - >let %1 : Float = mul(%t, %t) +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) -result: - >let %1 : Float = mul(%t, %t) +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - [P] source loc: 1515058 (1) - >[diffInstDecoration(Float)] +inst with location: 1515058 (1) +[diffInstDecoration(Float)] let %1 : Float = add(%2, %3) - [D] source loc: 1515058 (1) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1, 1 : Int, %2) - - - -transcribing an original instruction: 204 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, 1 : Int, %2, %3) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, 1 : Int, %2, %3) - - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >let %1 : Int = param - - - -transcribing an original instruction: 204 (1) - > -result: -result: - >let %1 : Int = param - - [P] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >let %1 : Float = param - -result: - >let %1 : Float = param - - [P] source loc: 0 (0) - >let %1 : Float = param - - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1) +inst with location: 0 (0) +unconditionalBranch(%1, %2) -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1) +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = param - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) unconditionalBranch(%1) - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >let %1 : Bool = cmpNE(%2, 1 : Int) - -result: - >let %1 : Bool = cmpNE(%2, 1 : Int) - - [P] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >ifElse(%1, %2, %3, %4) - -result: - >[mixedDiffInstDecoration()] -ifElse(%1, %2, %3, %4) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) ifElse(%1, %2, %3, %4) - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1, %x5Fbflag) - - - -transcribing an original instruction: 3068 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag) - - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1, false) - - - -transcribing an original instruction: 3068 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, false) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, false) - - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >[nameHint("_bflag")] -let %x5Fbflag : Bool = param - - - -transcribing an original instruction: 3068 (1) - > -result: -result: - >[nameHint("_bflag")] -let %x5Fbflag : Bool = param - - [P] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1) - -result: - >[mixedDiffInstDecoration()] +inst with location: 0 (0) unconditionalBranch(%1) - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) unconditionalBranch(%1) - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >ifElse(%x5Fbflag, %1, %2, %3) - -result: - >[mixedDiffInstDecoration()] -ifElse(%x5Fbflag, %1, %2, %3) +inst with location: 0 (0) +unconditionalBranch(%1) - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] +inst with location: 0 (0) ifElse(%x5Fbflag, %1, %2, %3) - [D] source loc: 0 (0) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1, %t, %i) - - - -transcribing an original instruction: 204 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) - - [D] source loc: 0 (0) - - -transcribing an original instruction: 1515032 (1) - >let %1 : Int = add(%i, 1 : Int) - -result: - >let %1 : Int = add(%i, 1 : Int) - - [P] source loc: 1515032 (1) - - -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1, %2, %3) - - - -transcribing an original instruction: 204 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %2, %3, %4) - - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %2, %3, %4) +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) - [D] source loc: 0 (0) +inst with location: 0 (0) +unconditionalBranch(%1, %2) +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param -transcribing an original instruction: 1514994 (1) - >[nameHint("t")] -let %t : Float = param +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) -result: - >[nameHint("t")] -let %t : Float = param +(diffPropagateFunc moving blocks)=============================== +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)) +{ +block %2( + [nameHint("dpy")] + param %dpy : DiffPair(Float, %1)): + let %3 : Float = PrimalParamRef(%dpy) + [diffInstDecoration(Float)] + let %4 : Float = DiffParamRef(%dpy) + unconditionalBranch(%5) - [P] source loc: 1514994 (1) - >let %1 : Float = param +block %5: + [loopMaxIters(4 : Int)] + loop(%6, %7, %6, true, %3, 0 : Int) - [D] source loc: 1514994 (1) +block %6( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t : Float, + [primalInstDecoration] + [nameHint("i")] + param %i : Int): + ifElse(%x5Fbflag, %8, %9, %8) +block %9: + unconditionalBranch(%7) -transcribing an original instruction: 1515017 (1) - >[nameHint("i")] -let %i : Int = param +block %7: + [BackwardDerivativePrimalReturnDecoration(%t)] + unconditionalBranch(%10) +block %8: + unconditionalBranch(%11) +block %11: + [primalInstDecoration] + let %12 : Bool = cmpLT(%i, 3 : Int) + ifElse(%12, %13, %14, %15) -transcribing an original instruction: 204 (1) - > -result: -result: - >[nameHint("i")] -let %i : Int = param +block %14: + unconditionalBranch(%15, 0 : Int, 0 : Float) - [P] source loc: 1515017 (1) +block %13: + [primalInstDecoration] + let %16 : Float = mul(%t, %t) + unconditionalBranch(%15, 1 : Int, %16) + +block %15( + [primalInstDecoration] + param %17 : Int, + [primalInstDecoration] + param %18 : Float): + unconditionalBranch(%19) + +block %19: + [primalInstDecoration] + let %20 : Bool = cmpNE(%17, 1 : Int) + ifElse(%20, %21, %22, %23) +block %22: + unconditionalBranch(%23, %x5Fbflag) -transcribing an original instruction: 0 (0) - >unconditionalBranch(%1, %x5Fbflag, %t, %i) +block %21: + unconditionalBranch(%23, false) +block %23( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%24) +block %24: + ifElse(%x5Fbflag1, %25, %26, %27) -transcribing an original instruction: 3068 (1) - > -result: +block %26: + unconditionalBranch(%27, %t, %i) +block %25: + [primalInstDecoration] + let %28 : Int = add(%i, 1 : Int) + unconditionalBranch(%27, %18, %28) -transcribing an original instruction: 204 (1) - > -result: -result: - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) +block %27( + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int): + unconditionalBranch(%6, %x5Fbflag1, %t1, %i1) - [P] source loc: 0 (0) - >[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) +block %10: + [loopMaxIters(4 : Int)] + loop(%29, %30, %29, %4) + +block %29( + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft : Float): + ifElse(%x5Fbflag, %31, %32, %31) + +block %32: + unconditionalBranch(%30) + +block %30: + [diffInstDecoration(Float)] + let %33 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + [diffInstDecoration(Float)] + return_val(%33) + +block %31: + unconditionalBranch(%34) + +block %34: + ifElse(%12, %35, %36, %37) + +block %36: + [diffInstDecoration(Float)] + let %38 : Float = call %floatx5Fdzero() + unconditionalBranch(%37, %38) + +block %35: + [diffInstDecoration(Float)] + let %39 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %40 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %41 : Float = add(%39, %40) + unconditionalBranch(%37, %41) + +block %37( + [diffInstDecoration(Float)] + param %42 : Float): + unconditionalBranch(%43) + +block %43: + ifElse(%20, %44, %45, %46) + +block %45: + unconditionalBranch(%46) + +block %44: + unconditionalBranch(%46) + +block %46: + unconditionalBranch(%47) + +block %47: + ifElse(%x5Fbflag1, %48, %49, %50) + +block %49: + unconditionalBranch(%50, %sx5Fdiffx5Ft) + +block %48: + unconditionalBranch(%50, %42) + +block %50( + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft1 : Float): + unconditionalBranch(%29, %sx5Fdiffx5Ft1) +} - [D] source loc: 0 (0) -(fwdDiffFunc)=============================== inst with location: 0 (0) [nameHint("dpy")] let %dpy : DiffPair(Float, %1) = param -inst with location: 1514954 (1) -[diffInstDecoration(Float)] -let %1 : Float = GetDifferential(%dpy) +inst with location: 0 (0) +let %1 : Float = PrimalParamRef(%dpy) -inst with location: 1514954 (1) -[primalInstDecoration] -let %1 : Float = GetPrimal(%dpy) +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = DiffParamRef(%dpy) inst with location: 0 (0) -[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 1515008 (1) [loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, %4, 0 : Int) +loop(%1, %2, %1, true, %3, 0 : Int) inst with location: 0 (0) [primalInstDecoration] @@ -1326,34 +765,22 @@ inst with location: 1514994 (1) [nameHint("t")] let %t : Float = param -inst with location: 1514994 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param - inst with location: 1515017 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param inst with location: 0 (0) -[mixedDiffInstDecoration()] ifElse(%x5Fbflag, %1, %2, %1) inst with location: 0 (0) -[mixedDiffInstDecoration()] unconditionalBranch(%1) inst with location: 0 (0) -[mixedDiffInstDecoration(DiffPair(Float, %1))] -let %2 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - -inst with location: 1515077 (1) -[mixedDiffInstDecoration(DiffPair(Float, %1))] -return_val(%2) +[BackwardDerivativePrimalReturnDecoration(%t)] +unconditionalBranch(%1) inst with location: 0 (0) -[mixedDiffInstDecoration()] unconditionalBranch(%1) inst with location: 1515026 (1) @@ -1361,36 +788,17 @@ inst with location: 1515026 (1) let %1 : Bool = cmpLT(%i, 3 : Int) inst with location: 0 (0) -[mixedDiffInstDecoration()] ifElse(%1, %2, %3, %4) inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, 0 : Int, 0 : Float, %2) +unconditionalBranch(%1, 0 : Int, 0 : Float) inst with location: 1515058 (1) [primalInstDecoration] let %1 : Float = mul(%t, %t) inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 1515058 (1) -[diffInstDecoration(Float)] -let %1 : Float = add(%2, %3) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, 1 : Int, %2, %3) +unconditionalBranch(%1, 1 : Int, %2) inst with location: 0 (0) [primalInstDecoration] @@ -1401,11 +809,6 @@ inst with location: 0 (0) let %1 : Float = param inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = param - -inst with location: 0 (0) -[mixedDiffInstDecoration()] unconditionalBranch(%1) inst with location: 0 (0) @@ -1413,15 +816,12 @@ inst with location: 0 (0) let %1 : Bool = cmpNE(%2, 1 : Int) inst with location: 0 (0) -[mixedDiffInstDecoration()] ifElse(%1, %2, %3, %4) inst with location: 0 (0) -[mixedDiffInstDecoration()] unconditionalBranch(%1, %x5Fbflag) inst with location: 0 (0) -[mixedDiffInstDecoration()] unconditionalBranch(%1, false) inst with location: 0 (0) @@ -1430,45 +830,122 @@ inst with location: 0 (0) let %x5Fbflag : Bool = param inst with location: 0 (0) -[mixedDiffInstDecoration()] unconditionalBranch(%1) inst with location: 0 (0) -[mixedDiffInstDecoration()] ifElse(%x5Fbflag, %1, %2, %3) inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) +unconditionalBranch(%1, %t, %i) inst with location: 1515032 (1) [primalInstDecoration] let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %2, %3, %4) +unconditionalBranch(%1, %2, %3) inst with location: 1514994 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag, %t, %i) + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, %3) + inst with location: 1514994 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) +unconditionalBranch(%1) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +return_val(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 1515058 (1) +[diffInstDecoration(Float)] +let %1 : Float = add(%2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) -(checkpoint policy, got) =============================== +(applyCheckpointPolicy) =============================== inst with location: 0 (0) [nameHint("dpy")] let %dpy : Float = param @@ -1498,7 +975,7 @@ let %1 : Float = GetPrimal(%2) inst with location: 0 (0) unconditionalBranch(%1) -inst with location: 0 (0) +inst with location: 1515008 (1) [loopMaxIters(4 : Int)] let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) @@ -1787,48 +1264,122 @@ let %i : Int = param inst with location: 0 (0) unconditionalBranch(%1, %x5Fbflag, %t, %i) +Adding counter for primalLoop: +[loopMaxIters(4 : Int)] +let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) + + > sourceLoc: 1515008 (1) +>> Counter for primalLoop: +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + + > sourceLoc: 1515008 (1) ### Slang::AutodiffCheckpointPolicyBase::processFunc +processing workList +use with usedVal: +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40999E5E0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513345E0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param inst with location: 1514994 (1) +use with usedVal: +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40999E5E0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513345E0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param inst with location: 1514994 (1) +use with usedVal: +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +use with usedVal: +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +use with usedVal: +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +use with usedVal: +[primalInstDecoration] +let %1 : Int = param + +use with usedVal: +0 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40997FB20 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C51311B10 to storeSet 0 inst with location: 0 (0) +use with usedVal: +1 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A40997F6F0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513116E0 to storeSet 1 inst with location: 0 (0) +use with usedVal: +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A4099977A0 to storeSet +use with usedVal: +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +use with usedVal: + + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513397D0 to storeSet inst with location: 0 (0) +use with usedVal: +[nameHint("dpy")] +let %dpy : InOut(DiffPair(Float, %1)) = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001A4099898A8 to storeSet +use with usedVal: +[nameHint("dpy")] +let %dpy : InOut(DiffPair(Float, %1)) = param + +use with usedVal: [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] let %x5Fpc : Int = param -inst with location: 0 (0) + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C5133F928 to storeSet +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + +inst with location: 1515008 (1) +use with usedVal: +[nameHint("_s_dOut")] +let %x5Fsx5FdOut : Float = param + ****** (before legalization) # of elements in the store set for hoistInfo: 2 source loc recorded: 1514994 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -source loc recorded: 0 (0) +source loc recorded: 1515008 (1) [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] @@ -1875,10 +1426,12 @@ let %1 : Bool = cmpLT(%2, 3 : Int) >> NO OUT OF SCOPE USES ****** (after legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 0 (0) +source loc recorded: 1515008 (1) let %1 : Ptr(Int) = var -(0): note: also see pipeline definition +tests/autodiff/reverse-loop.slang(16): note: also see pipeline definition + for (int i = 0; i < 3; i++) + ^~~ source loc recorded: 1514994 (1) let %1 : Ptr(Array(Float, 5 : Int)) = var diff --git a/reverse-loop.slang-ast b/reverse-loop.slang-ast index e11b448be8..73e228d57a 100644 --- a/reverse-loop.slang-ast +++ b/reverse-loop.slang-ast @@ -20,7 +20,7 @@ ModuleDecl:0 { } closingSourceLoc : SourceLoc(1515508) tests/autodiff/reverse-loop.slang:41 ownedScope : ::?::reverse-loop - module : Unknown@0x000001a479aaa050 + module : Unknown@0x0000020c43be4040 mapDeclToAssociatedDecls : { } isInLegacyLanguage : 1 diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index f067ab303e..bad8ea44c3 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -1720,16 +1720,17 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr IRCloneEnv env; auto primalFuncClone = as(cloneInst(&env, &builder, primalFunc)); - printf("(result from prepareFuncForForwardDiff)===============================\n"); - for (auto block : primalFuncClone->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } + // printf("(prepareFuncForForwardDiff)===============================\n"); + // primalFuncClone->dump(); + // for (auto block : primalFuncClone->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + + // inst->dump(); + // } + // } prepareFuncForForwardDiff(primalFuncClone); @@ -1746,8 +1747,6 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr mapPrimalInst(block, diffBlock); mapDifferentialInst(block, diffBlock); } - - printf("(result from forward diff transcribe blocks)===============================\n"); // Now actually transcribe the content of each block. for (auto block = primalFuncClone->getFirstBlock(); block; block = block->getNextBlock()) @@ -1794,6 +1793,18 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr #if _DEBUG checkAutodiffInstDecorations(diffFunc); #endif + + // printf("(diffFunc at prepareFuncForForwardDiff)===============================\n"); + // diffFunc->dump(); + // for (auto block : diffFunc->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + + // inst->dump(); + // } + // } return InstPair(primalFunc, diffFunc); } diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index 92b33cc44c..a5f2ec5264 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -281,6 +281,18 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( IROutOfOrderCloneContext* cloneCtx, Dictionary>& blockIndexInfo) { + // printf("(Checkpoint policy)==========================================\n"); + // func->dump(); + // for (auto block : func->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + + // inst->dump(); + // } + // } + collectInductionValues(func); RefPtr checkpointInfo = new CheckpointSetInfo(); @@ -358,6 +370,7 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( addPrimalOperandsToWorkList(block->getTerminator()); } + printf("processing workList\n"); while (workList.getCount() > 0) { auto use = workList.getLast(); @@ -366,6 +379,9 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( if (processedUses.contains(use)) continue; + printf("use with usedVal:\n"); + use.usedVal->dump(); + processedUses.add(use); HoistResult result = this->classify(use); @@ -1761,6 +1777,13 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC primalInitBlock->getTerminator())->getTargetBlock(); builder.setInsertBefore(primalInitBlock->getTerminator()); + printf("Adding counter for primalLoop:\n"); + primalLoop->dump(); + printf(" > sourceLoc: %d (%d)\n", + primalLoop->sourceLoc.getRaw(), + primalLoop->sourceLoc.isValid()); + SourceLoc loc = primalLoop->sourceLoc; + auto phiCounterArgLoopEntryIndex = addPhiOutputArg( &builder, primalInitBlock, @@ -1776,6 +1799,13 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC builder.addLoopCounterDecoration(primalCountParam); builder.addNameHintDecoration(primalCountParam, UnownedStringSlice("_pc")); builder.markInstAsPrimal(primalCountParam); + primalCountParam->sourceLoc = loc; + + printf(">> Counter for primalLoop:\n"); + primalCountParam->dump(); + printf(" > sourceLoc: %d (%d)\n", + primalCountParam->sourceLoc.getRaw(), + primalCountParam->sourceLoc.isValid()); IRBlock* primalUpdateBlock = getUpdateBlock(primalLoop); IRInst* terminator = primalUpdateBlock->getTerminator(); @@ -1827,6 +1857,7 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC diffCountParam, builder.getIntValue(builder.getIntType(), 1)); builder.markInstAsPrimal(decCounterVal); + // TODO: sourceLoc for _dc here? auto phiCounterArgLoopCycleIndex = addPhiOutputArg(&builder, diffUpdateBlock, terminator, decCounterVal); @@ -1898,7 +1929,8 @@ RefPtr applyCheckpointPolicy(IRGlobalValueWithCode* func) { sortBlocksInFunc(func); - printf("(checkpoint policy, got) ===============================\n"); + printf("(applyCheckpointPolicy) ===============================\n"); + // func->dump(); for (auto block : func->getBlocks()) { for (auto inst = block->getFirstInst(); inst; inst = inst->next) { printf("inst with location: %d (%d)\n", diff --git a/source/slang/slang-ir-autodiff-region.cpp b/source/slang/slang-ir-autodiff-region.cpp index 98b64f179a..04182eef23 100644 --- a/source/slang/slang-ir-autodiff-region.cpp +++ b/source/slang/slang-ir-autodiff-region.cpp @@ -50,7 +50,7 @@ namespace Slang{ workList.add(successor); } } - + return regionMap; } }; diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index 189d662fb4..f558a517d9 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -553,18 +553,6 @@ namespace Slang eliminateContinueBlocksInFunc(func->getModule(), func); eliminateMultiLevelBreakForFunc(func->getModule(), func); - - printf("(result before normalizeCFG)===============================\n"); - func->dump(); - for (auto block : func->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } IRCFGNormalizationPass cfgPass = {this->getSink()}; normalizeCFG(autoDiffSharedContext->moduleInst->getModule(), func, cfgPass); @@ -589,34 +577,23 @@ namespace Slang // Strip any existing derivative decorations off the clone. stripDerivativeDecorations(primalFunc); eliminateDeadCode(primalOuterParent); - - printf("(result before prepareFuncForBackwardDiff)===============================\n"); - primalFunc->dump(); - for (auto block : primalFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } // Perform required transformations and simplifications on the original func to make it // reversible. if (SLANG_FAILED(prepareFuncForBackwardDiff(primalFunc))) return diffPropagateFunc; - printf("(result after prepareFuncForBackwardDiff)===============================\n"); - for (auto block : primalFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } + // printf("(result after prepareFuncForBackwardDiff)===============================\n"); + // //primalFunc->dump(); + // for (auto block : primalFunc->getBlocks()) { + // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + // printf("inst with location: %d (%d)\n", + // inst->sourceLoc.getRaw(), + // inst->sourceLoc.isValid()); + + // inst->dump(); + // } + // } // Forward transcribe the clone of the original func. ForwardDiffTranscriber& fwdTranscriber = *static_cast( @@ -628,7 +605,7 @@ namespace Slang auto newCount = autoDiffSharedContext->followUpFunctionsToTranscribe.getCount(); for (auto i = oldCount; i < newCount; i++) { - printf("transcribing function with fwd mode: %d (%d, %d)\n", i, oldCount, newCount); + // printf("transcribing function with fwd mode: %d (%d, %d)\n", i, oldCount, newCount); auto pendingTask = autoDiffSharedContext->followUpFunctionsToTranscribe.getLast(); autoDiffSharedContext->followUpFunctionsToTranscribe.removeLast(); SLANG_RELEASE_ASSERT(pendingTask.type == FuncBodyTranscriptionTaskType::Forward); @@ -703,21 +680,6 @@ namespace Slang // Transcribe a function definition. void BackwardDiffTranscriberBase::transcribeFuncImpl(IRBuilder* builder, IRFunc* primalFunc, IRFunc* diffPropagateFunc) { - printf("(primalFunc)===============================\n"); - primalFunc->dump(); - - for (auto block : primalFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - inst->dump(); - - if (inst->sourceLoc.isValid()) - getSink()->diagnose(inst->sourceLoc, Diagnostics::seeDeclarationOf, inst); - } - } - SLANG_ASSERT(primalFunc); SLANG_ASSERT(diffPropagateFunc); // Reverse-mode transcription uses 4 separate steps: @@ -738,15 +700,16 @@ namespace Slang if (!fwdDiffFunc) return; - printf("(fwdDiffFunc)===============================\n"); + printf("(fwdDiffFunc from generateNewForwardDerivative)===============================\n"); + fwdDiffFunc->dump(); for (auto block : fwdDiffFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); - inst->dump(); - } + inst->dump(); + } } bool isResultDifferentiable = as(fwdDiffFunc->getResultType()); @@ -762,6 +725,20 @@ namespace Slang diffUnzipPass->unzipDiffInsts(fwdDiffFunc); IRFunc* unzippedFwdDiffFunc = fwdDiffFunc; + + printf("(diffPropagateFunc after unzipping)===============================\n"); + diffPropagateFunc->dump(); + + printf("(unzipDiffInsts)===============================\n"); + for (auto block : unzippedFwdDiffFunc->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } // Move blocks from `unzippedFwdDiffFunc` to the `diffPropagateFunc` shell. builder->setInsertInto(diffPropagateFunc->getParent()); @@ -773,6 +750,18 @@ namespace Slang for (auto block : workList) block->insertAtEnd(diffPropagateFunc); } + + printf("(diffPropagateFunc moving blocks)===============================\n"); + diffPropagateFunc->dump(); + for (auto block : diffPropagateFunc->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } // Transpose the first block (parameter block) auto paramTransposeInfo = diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp index 51c35300ac..55e68fff7f 100644 --- a/source/slang/slang-ir-autodiff-transcriber-base.cpp +++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp @@ -1033,30 +1033,30 @@ InstPair AutoDiffTranscriberBase::transcribeInst(IRBuilder* builder, IRInst* ori if (as(origInst->getParent()) && !as(origInst)) return InstPair(origInst, nullptr); - printf("\n\ntranscribing an original instruction: %d (%d)\n", - origInst->sourceLoc.getRaw(), origInst->sourceLoc.isValid()); - printf(" >"); - origInst->dump(); + //printf("\n\ntranscribing an original instruction: %d (%d)\n", + // origInst->sourceLoc.getRaw(), origInst->sourceLoc.isValid()); + //printf(" >"); + //origInst->dump(); auto result = transcribeInstImpl(builder, origInst); - printf("result:\n"); + //printf("result:\n"); if (result.primal) { - printf(" >"); - result.primal->dump(); + //printf(" >"); + //result.primal->dump(); result.primal->sourceLoc = origInst->sourceLoc; - printf(" [P] source loc: %d (%d)\n", - result.primal->sourceLoc.getRaw(), - result.primal->sourceLoc.isValid()); + //printf(" [P] source loc: %d (%d)\n", + // result.primal->sourceLoc.getRaw(), + // result.primal->sourceLoc.isValid()); } if (result.differential) { - printf(" >"); - result.differential->dump(); + //printf(" >"); + //result.differential->dump(); result.differential->sourceLoc = origInst->sourceLoc; - printf(" [D] source loc: %d (%d)\n", - result.differential->sourceLoc.getRaw(), - result.differential->sourceLoc.isValid()); + //printf(" [D] source loc: %d (%d)\n", + // result.differential->sourceLoc.getRaw(), + // result.differential->sourceLoc.isValid()); } if (result.primal == nullptr && result.differential == nullptr) diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index 9f18db6e06..3be1a158c6 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -556,11 +556,15 @@ struct DiffUnzipPass diffBuilder->addLoopMaxItersDecoration(diffLoop, maxItersDecoration->getMaxIters()); } + primalLoop->sourceLoc = mixedLoop->sourceLoc; + diffLoop->sourceLoc = mixedLoop->sourceLoc; + return InstPair(primalLoop, diffLoop); } InstPair splitControlFlow(IRBuilder* primalBuilder, IRBuilder* diffBuilder, IRInst* branchInst) { + // TODO: put the instructions here, then assign source loc at the end switch (branchInst->getOp()) { case kIROp_unconditionalBranch: @@ -578,17 +582,21 @@ struct DiffUnzipPass else primalArgs.add(uncondBranchInst->getArg(ii)); } + + auto primalBranch = primalBuilder->emitBranch( + as(primalMap[targetBlock]), + primalArgs.getCount(), + primalArgs.getBuffer()); + + auto diffBranch = diffBuilder->emitBranch( + as(diffMap[targetBlock]), + diffArgs.getCount(), + diffArgs.getBuffer()); + + primalBranch->sourceLoc = branchInst->sourceLoc; + diffBranch->sourceLoc = branchInst->sourceLoc; - return InstPair( - primalBuilder->emitBranch( - as(primalMap[targetBlock]), - primalArgs.getCount(), - primalArgs.getBuffer()), - diffBuilder->emitBranch( - as(diffMap[targetBlock]), - diffArgs.getCount(), - diffArgs.getBuffer())); - + return InstPair(primalBranch, diffBranch); } case kIROp_conditionalBranch: diff --git a/source/slang/slang-ir-eliminate-multilevel-break.cpp b/source/slang/slang-ir-eliminate-multilevel-break.cpp index 210debef77..7ff5761cf2 100644 --- a/source/slang/slang-ir-eliminate-multilevel-break.cpp +++ b/source/slang/slang-ir-eliminate-multilevel-break.cpp @@ -327,7 +327,7 @@ struct EliminateMultiLevelBreakContext } printf("(result before eliminating phis)===============================\n"); - func->dump(); + //func->dump(); for (auto block : func->getBlocks()) { for (auto inst = block->getFirstInst(); inst; inst = inst->next) { printf("inst with location: %d (%d)\n", @@ -340,18 +340,6 @@ struct EliminateMultiLevelBreakContext // To make things easy, eliminate Phis before perform transformations. eliminatePhisInFunc(LivenessMode::Disabled, irModule, func, PhiEliminationOptions::getFast()); - - printf("(result after eliminating phis)===============================\n"); - func->dump(); - for (auto block : func->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } // Before modifying the cfg, we gather all required info from the existing cfg. FuncContext funcInfo; diff --git a/source/slang/slang-ir-eliminate-phis.cpp b/source/slang/slang-ir-eliminate-phis.cpp index e62b88f0d7..fcf96d3446 100644 --- a/source/slang/slang-ir-eliminate-phis.cpp +++ b/source/slang/slang-ir-eliminate-phis.cpp @@ -120,7 +120,7 @@ struct PhiEliminationContext // for Phi parameters and other insts that benefit from // converting to memory. initializePerFuncState(func); - + // First, we eliminate all the phi instructions (params) // using the result of register allocation. // The first block in a function is always the entry block, @@ -138,7 +138,7 @@ struct PhiEliminationContext eliminatePhisInBlock(block); } - + // Next, convert the definition of other ordinary insts to assignments. convertInstDefToRegisterAssignment(); @@ -551,6 +551,7 @@ struct PhiEliminationContext auto user = use->getUser(); m_builder.setInsertBefore(user); auto newVal = m_builder.emitLoad(temp); + newVal->sourceLoc = param->sourceLoc; m_builder.replaceOperand(use, newVal); } @@ -939,6 +940,7 @@ struct PhiEliminationContext newOperands.getCount(), newOperands.getArrayView().getBuffer()); oldBranch->transferDecorationsTo(newBranch); + newBranch->sourceLoc = oldBranch->sourceLoc; // TODO: We could consider just modifying `branch` in-place by clearing // the relevant operands for the phi arguments and setting its operand From 490933bcb891198acaac59fe049e5974a755c519 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 9 Sep 2024 12:19:03 -0700 Subject: [PATCH 04/32] Printing checkpoint structure breakdown --- ad-report | 9926 +++++++++++++++++++--- reverse-loop.slang-ast | 1154 --- source/slang/slang-emit.cpp | 43 + source/slang/slang-ir-autodiff-unzip.cpp | 11 + source/slang/slang-ir-inst-defs.h | 3 + source/slang/slang-ir-insts.h | 8 + tests/modules/ad-report | 1 + 7 files changed, 8964 insertions(+), 2182 deletions(-) delete mode 100644 reverse-loop.slang-ast create mode 100644 tests/modules/ad-report diff --git a/ad-report b/ad-report index 1c9825ec86..37861bb975 100644 --- a/ad-report +++ b/ad-report @@ -1,592 +1,7149 @@ +### LOWER-TO-IR: +undefined +let %1 : Void = no_diff +let %2 : witness_table_t(%IDifferentiable) = lookupWitness(%3, %4) +let %3 : witness_table_t(%IFloat) = lookupWitness(%5, %6) +let %7 : CapabilitySet = capabilityDisjunction(%8, %9, %10, %11, %12, %13, %14, %15, %16, %17, %18, %19, %20, %21, %22, %23, %24, %25, %26, %27, %28, %29, %30, %31, %32, %33, %34, %35, %36, %37, %38, %39, %40, %41, %42, %43, %44, %45, %46, %47, %48, %49, %50, %51, %52, %53, %54, %55, %56, %57, %58, %59, %60, %61, %62, %63, %64, %65, %66, %67, %68, %69, %70, %71, %72, %73, %74, %75, %76, %77, %78, %79, %80, %81, %82, %83, %84, %85, %86, %87, %88, %89, %90, %91, %92, %93, %94, %95, %96, %97, %98, %99, %100, %101, %102, %103, %104, %105) +let %105 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 74 : Int) +let %104 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 73 : Int) +let %103 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 72 : Int) +let %102 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 71 : Int) +let %101 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 70 : Int) +let %100 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 69 : Int) +let %99 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 68 : Int) +let %98 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 67 : Int) +let %97 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 66 : Int) +let %96 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 65 : Int) +let %95 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 64 : Int) +let %94 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 63 : Int) +let %93 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 62 : Int) +let %92 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 61 : Int) +let %91 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 74 : Int) +let %90 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 73 : Int) +let %89 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 72 : Int) +let %88 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 71 : Int) +let %87 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 70 : Int) +let %86 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 69 : Int) +let %85 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 68 : Int) +let %84 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 67 : Int) +let %83 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 66 : Int) +let %82 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 65 : Int) +let %81 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 64 : Int) +let %80 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 63 : Int) +let %79 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 62 : Int) +let %78 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 61 : Int) +let %77 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 74 : Int) +let %76 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 73 : Int) +let %75 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 72 : Int) +let %74 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 71 : Int) +let %73 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 70 : Int) +let %72 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 69 : Int) +let %71 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 68 : Int) +let %70 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 67 : Int) +let %69 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 66 : Int) +let %68 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 65 : Int) +let %67 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 64 : Int) +let %66 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 63 : Int) +let %65 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 62 : Int) +let %64 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 61 : Int) +let %63 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 74 : Int) +let %62 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 73 : Int) +let %61 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 72 : Int) +let %60 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 71 : Int) +let %59 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 70 : Int) +let %58 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 69 : Int) +let %57 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 68 : Int) +let %56 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 67 : Int) +let %55 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 66 : Int) +let %54 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 65 : Int) +let %53 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 64 : Int) +let %52 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 63 : Int) +let %51 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 62 : Int) +let %50 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 61 : Int) +let %49 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 74 : Int) +let %48 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 73 : Int) +let %47 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 72 : Int) +let %46 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 71 : Int) +let %45 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 70 : Int) +let %44 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 69 : Int) +let %43 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 68 : Int) +let %42 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 67 : Int) +let %41 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 66 : Int) +let %40 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 65 : Int) +let %39 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 64 : Int) +let %38 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 63 : Int) +let %37 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 62 : Int) +let %36 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 61 : Int) +let %35 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 74 : Int) +let %34 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 73 : Int) +let %33 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 72 : Int) +let %32 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 71 : Int) +let %31 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 70 : Int) +let %30 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 69 : Int) +let %29 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 68 : Int) +let %28 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 67 : Int) +let %27 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 66 : Int) +let %26 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 65 : Int) +let %25 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 64 : Int) +let %24 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 63 : Int) +let %23 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 62 : Int) +let %22 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 61 : Int) +let %21 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 74 : Int) +let %20 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 73 : Int) +let %19 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 72 : Int) +let %18 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 71 : Int) +let %17 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 70 : Int) +let %16 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 69 : Int) +let %15 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 68 : Int) +let %14 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 67 : Int) +let %13 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 66 : Int) +let %12 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 65 : Int) +let %11 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 64 : Int) +let %10 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 63 : Int) +let %9 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 62 : Int) +let %8 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 61 : Int) +let %5 : witness_table_t(%x5Fx5FBuiltinFloatingPointType) = thisTypeWitness +let %106 : _ = interface_req_entry(%107, witness_table_t(%x5Fx5FBuiltinRealType)) +let %108 : _ = interface_req_entry(%6, witness_table_t(%IFloat)) +let %109 : _ = interface_req_entry(%110, Func(this_type(%x5Fx5FBuiltinFloatingPointType))) +let %111 : _ = interface_req_entry(%112, Func(DiffPairUserCode(this_type(%x5Fx5FBuiltinFloatingPointType), %2))) +let %113 : _ = interface_req_entry(%114, Func(Void, associated_type(%IDifferentiable))) +[treatAsDifferentiableDecoration] +[BuiltinDecoration] +[import("_ST4core26__BuiltinFloatingPointType")] +[nameHint("__BuiltinFloatingPointType")] +let %x5Fx5FBuiltinFloatingPointType : Type = interface(%106, %108, %109, %111, %113) +[import("_S4core26__BuiltinFloatingPointTypeI4core17__BuiltinRealType")] +let %107 : _ = key +let %115 : _ = interface_req_entry(%116, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[import("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%115) +[import("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %116 : _ = key +let %117 : _ = interface_req_entry(%118, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[import("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%117) +[import("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %118 : _ = key +let %119 : _ = interface_req_entry(%120, witness_table_t(%x5Fx5FBuiltinType)) +let %121 : _ = interface_req_entry(%122, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[import("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%119, %121) +[import("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %120 : _ = key +[BuiltinDecoration] +[import("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +[import("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %122 : _ = key +let %123 : _ = interface_req_entry(%124, witness_table_t(%IComparable)) +let %125 : _ = interface_req_entry(%126, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %127 : _ = interface_req_entry(%128, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %129 : _ = interface_req_entry(%130, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %131 : _ = interface_req_entry(%132, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %133 : _ = interface_req_entry(%134, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %135 : _ = interface_req_entry(%136, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +let %137 : _ = interface_req_entry(%138, Func(this_type(%IArithmetic), Int)) +let %139 : _ = interface_req_entry(%140, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[import("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%123, %125, %127, %129, %131, %133, %135, %137, %139) +[import("_S4core11IArithmeticI4core11IComparable")] +let %124 : _ = key +let %141 : _ = interface_req_entry(%142, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +let %143 : _ = interface_req_entry(%144, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +let %145 : _ = interface_req_entry(%146, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[import("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%141, %143, %145) +[import("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %142 : _ = key +[import("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %144 : _ = key +[import("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %146 : _ = key +[import("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %126 : _ = key +[import("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %128 : _ = key +[import("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %130 : _ = key +[import("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %132 : _ = key +[import("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %134 : _ = key +[import("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %136 : _ = key +[import("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %138 : _ = key +[import("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %140 : _ = key +[import("_S4core26__BuiltinFloatingPointTypeI4core6IFloat")] +let %6 : _ = key +let %147 : _ = interface_req_entry(%148, witness_table_t(%IArithmetic)) +let %149 : _ = interface_req_entry(%4, witness_table_t(%IDifferentiable)) +let %150 : _ = interface_req_entry(%151, Func(this_type(%IFloat), Float)) +let %152 : _ = interface_req_entry(%153, Func(Float, this_type(%IFloat))) +let %154 : _ = interface_req_entry(%155, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %156 : _ = interface_req_entry(%157, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %158 : _ = interface_req_entry(%159, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %160 : _ = interface_req_entry(%161, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %162 : _ = interface_req_entry(%163, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %164 : _ = interface_req_entry(%165, Func(this_type(%IFloat), this_type(%IFloat))) +let %166 : _ = interface_req_entry(%167, Func(this_type(%IFloat), this_type(%IFloat))) +let %168 : _ = interface_req_entry(%169, %170) +[import("_ST4core6IFloat")] +[nameHint("IFloat")] +let %IFloat : Type = interface(%147, %149, %150, %152, %154, %156, %158, %160, %162, %164, %166, %168) +[import("_S4core6IFloatI4core11IArithmetic")] +let %148 : _ = key +[import("_S4core6IFloatI4core15IDifferentiable")] +let %4 : _ = key +let %171 : _ = interface_req_entry(%172, associated_type(%IDifferentiable)) +let %173 : _ = interface_req_entry(%174, witness_table_t(%IDifferentiable)) +let %175 : _ = interface_req_entry(%176, Func(associated_type(%IDifferentiable))) +let %177 : _ = interface_req_entry(%178, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +let %179 : _ = interface_req_entry(%180, %181) +[import("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%171, %173, %175, %177, %179) +[import("_ST4core15IDifferentiable12Differential")] +let %172 : _ = key +[import("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %174 : _ = key +[StaticRequirementDecoration] +[import("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %176 : _ = key +[StaticRequirementDecoration] +[import("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %178 : _ = key +[StaticRequirementDecoration] +[import("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %180 : _ = key +generic %181 : Generic +{ +block %182( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %183 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +[import("_S4core6IFloatR8_24xinitp1pi_f")] +let %151 : _ = key +[import("_S4core6IFloat7toFloatp0pf")] +let %153 : _ = key +[import("_S4core6IFloat3addp1pi_4core6IFloat4This4core6IFloat4This")] +let %155 : _ = key +[import("_S4core6IFloat3subp1pi_4core6IFloat4This4core6IFloat4This")] +let %157 : _ = key +[import("_S4core6IFloat3mulp1pi_4core6IFloat4This4core6IFloat4This")] +let %159 : _ = key +[import("_S4core6IFloat3divp1pi_4core6IFloat4This4core6IFloat4This")] +let %161 : _ = key +[import("_S4core6IFloat3modp1pi_4core6IFloat4This4core6IFloat4This")] +let %163 : _ = key +[import("_S4core6IFloat3negp0p4core6IFloat4This")] +let %165 : _ = key +[import("_S4core6IFloatR8_24xinitp1pi_4core6IFloat4This")] +let %167 : _ = key +[import("_S4core6IFloat5scaleg2TC4core6IFloat1T4core26__BuiltinFloatingPointTypep1pi_4core6IFloat1T4core6IFloat4This")] +let %169 : _ = key +generic %170 : Generic +{ +block %184( + [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] + [nameHint("IFloat.T")] + param %IFloatx5FT : type_t, + param %185 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): + return_val(Func(this_type(%IFloat), this_type(%IFloat), %IFloatx5FT)) +} +[backwardDiffReference(%114)] +[fwdDerivative(%112)] +[StaticRequirementDecoration] +[import("_S4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] +let %110 : _ = key +[StaticRequirementDecoration] +[import("_SFwdReq_4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] +let %112 : _ = key +[StaticRequirementDecoration] +[import("_SBwdReq_4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] +let %114 : _ = key +[export("_SWf4core13__BuiltinType")] +witness_table %186 : witness_table_t(%x5Fx5FBuiltinType)(Float); + +[intrinsicOp(272 : Int)] +[method] +[import("_S4core5float6equalsp1pi_fb")] +[nameHint("float.equals")] +func %floatx5Fequals : Func(Bool, Float, Float); + +[intrinsicOp(275 : Int)] +[method] +[import("_S4core5float8lessThanp1pi_fb")] +[nameHint("float.lessThan")] +func %floatx5FlessThan : Func(Bool, Float, Float); + +[intrinsicOp(277 : Int)] +[method] +[import("_S4core5float16lessThanOrEqualsp1pi_fb")] +[nameHint("float.lessThanOrEquals")] +func %floatx5FlessThanOrEquals : Func(Bool, Float, Float); + +[export("_SWf4core11IComparable")] +witness_table %187 : witness_table_t(%IComparable)(Float) +{ + witness_table_entry(%142,%floatx5Fequals) + + witness_table_entry(%144,%floatx5FlessThan) + + witness_table_entry(%146,%floatx5FlessThanOrEquals) + +} + +[intrinsicOp(264 : Int)] +[method] +[import("_S4core5float3addp1pi_ff")] +[nameHint("float.add")] +func %floatx5Fadd : Func(Float, Float, Float); + +[intrinsicOp(265 : Int)] +[method] +[import("_S4core5float3subp1pi_ff")] +[nameHint("float.sub")] +func %floatx5Fsub : Func(Float, Float, Float); + +[intrinsicOp(266 : Int)] +[method] +[import("_S4core5float3mulp1pi_ff")] +[nameHint("float.mul")] +func %floatx5Fmul : Func(Float, Float, Float); + +[intrinsicOp(267 : Int)] +[method] +[import("_S4core5float3divp1pi_ff")] +[nameHint("float.div")] +func %floatx5Fdiv : Func(Float, Float, Float); + +[intrinsicOp(269 : Int)] +[method] +[import("_S4core5float3modp1pi_ff")] +[nameHint("float.mod")] +func %floatx5Fmod : Func(Float, Float, Float); + +[intrinsicOp(283 : Int)] +[method] +[import("_S4core5float3negp0pf")] +[nameHint("float.neg")] +func %floatx5Fneg : Func(Float, Float); + +[intrinsicOp(500 : Int)] +[method] +[import("_S4core5floatR8_24xinitp1pi_i")] +[nameHint("float.$init")] +func %floatx5Fx24init : Func(Float, Int); + +[intrinsicOp(0 : Int)] +[treatAsDifferentiableDecoration] +[method] +[import("_S4core5floatR8_24xinitp1pi_f")] +[nameHint("float.$init")] +func %floatx5Fx24init1 : Func(Float, Float); + +[export("_SWf4core11IArithmetic")] +witness_table %188 : witness_table_t(%IArithmetic)(Float) +{ + witness_table_entry(%124,%187) + + witness_table_entry(%126,%floatx5Fadd) + + witness_table_entry(%128,%floatx5Fsub) + + witness_table_entry(%130,%floatx5Fmul) + + witness_table_entry(%132,%floatx5Fdiv) + + witness_table_entry(%134,%floatx5Fmod) + + witness_table_entry(%136,%floatx5Fneg) + + witness_table_entry(%138,%floatx5Fx24init) + + witness_table_entry(%140,%floatx5Fx24init1) + +} + +[export("_SWf4core23__BuiltinArithmeticType")] +witness_table %189 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Float) +{ + witness_table_entry(%120,%186) + + witness_table_entry(%122,%188) + +} + +[export("_SWf4core29__BuiltinSignedArithmeticType")] +witness_table %190 : witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)(Float) +{ + witness_table_entry(%118,%189) + +} + +[export("_SWf4core17__BuiltinRealType")] +witness_table %191 : witness_table_t(%x5Fx5FBuiltinRealType)(Float) +{ + witness_table_entry(%116,%190) + +} + +[export("_SWf4core11IComparable")] +witness_table %192 : witness_table_t(%IComparable)(Float) +{ + witness_table_entry(%142,%floatx5Fequals) + + witness_table_entry(%144,%floatx5FlessThan) + + witness_table_entry(%146,%floatx5FlessThanOrEquals) + +} + +[export("_SWf4core11IArithmetic")] +witness_table %193 : witness_table_t(%IArithmetic)(Float) +{ + witness_table_entry(%124,%192) + + witness_table_entry(%126,%floatx5Fadd) + + witness_table_entry(%128,%floatx5Fsub) + + witness_table_entry(%130,%floatx5Fmul) + + witness_table_entry(%132,%floatx5Fdiv) + + witness_table_entry(%134,%floatx5Fmod) + + witness_table_entry(%136,%floatx5Fneg) + + witness_table_entry(%138,%floatx5Fx24init) + + witness_table_entry(%140,%floatx5Fx24init1) + +} + +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[import("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %194: + return_val(0 : Float) +} +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[import("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %195( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %196 : Float = add(%a, %b) + return_val(%196) +} +generic %197 : Generic +{ +block %198( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %199 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %1), Float)) +} +[import("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %200 : %197 +{ +block %201( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %202 : witness_table_t(%x5Fx5FBuiltinRealType)): + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %1), Float) + { +block %203( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %1), + [nameHint("b")] + param %b1 : Float): + let %204 : Float = floatCast(%a1) + let %205 : Float = mul(%204, %b1) + return_val(%205) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %206 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%172,Float) + + witness_table_entry(%174,%206) + + witness_table_entry(%176,%floatx5Fdzero) + + witness_table_entry(%178,%floatx5Fdadd) + + witness_table_entry(%180,%200) + +} + +[intrinsicOp(499 : Int)] +[method] +[import("_S4core5float7toFloatp0pf")] +[nameHint("float.toFloat")] +func %floatx5FtoFloat : Func(Float, Float); + +generic %207 : Generic +{ +block %208( + [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] + [nameHint("float.T")] + param %floatx5FT : type_t, + param %209 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): + return_val(Func(Float, Float, %floatx5FT)) +} +[import("_S4core5float5scaleg2TC4core5float1T4core26__BuiltinFloatingPointTypep1pi_4core5float1Tf")] +generic %210 : %207 +{ +block %211( + [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] + [nameHint("float.T")] + param %floatx5FT1 : type_t, + param %212 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): + [intrinsicOp(266 : Int)] + [nameHint("float.scale")] + func %floatx5Fscale : Func(Float, Float, %floatx5FT1); + + return_val(%floatx5Fscale) +} +[export("_SWf4core6IFloat")] +witness_table %213 : witness_table_t(%IFloat)(Float) +{ + witness_table_entry(%148,%193) + + witness_table_entry(%4,%206) + + witness_table_entry(%151,%floatx5Fx24init1) + + witness_table_entry(%153,%floatx5FtoFloat) + + witness_table_entry(%155,%floatx5Fadd) + + witness_table_entry(%157,%floatx5Fsub) + + witness_table_entry(%159,%floatx5Fmul) + + witness_table_entry(%161,%floatx5Fdiv) + + witness_table_entry(%163,%floatx5Fmod) + + witness_table_entry(%165,%floatx5Fneg) + + witness_table_entry(%167,%floatx5Fx24init1) + + witness_table_entry(%169,%210) + +} + +[export("_SWi4core13__BuiltinType")] +witness_table %214 : witness_table_t(%x5Fx5FBuiltinType)(Int); + +[intrinsicOp(272 : Int)] +[method] +[import("_S4core3int6equalsp1pi_ib")] +[nameHint("int.equals")] +func %intx5Fequals : Func(Bool, Int, Int); + +[intrinsicOp(275 : Int)] +[method] +[import("_S4core3int8lessThanp1pi_ib")] +[nameHint("int.lessThan")] +func %intx5FlessThan : Func(Bool, Int, Int); + +[intrinsicOp(277 : Int)] +[method] +[import("_S4core3int16lessThanOrEqualsp1pi_ib")] +[nameHint("int.lessThanOrEquals")] +func %intx5FlessThanOrEquals : Func(Bool, Int, Int); + +[export("_SWi4core11IComparable")] +witness_table %215 : witness_table_t(%IComparable)(Int) +{ + witness_table_entry(%142,%intx5Fequals) + + witness_table_entry(%144,%intx5FlessThan) + + witness_table_entry(%146,%intx5FlessThanOrEquals) + +} + +[intrinsicOp(264 : Int)] +[method] +[import("_S4core3int3addp1pi_ii")] +[nameHint("int.add")] +func %intx5Fadd : Func(Int, Int, Int); + +[intrinsicOp(265 : Int)] +[method] +[import("_S4core3int3subp1pi_ii")] +[nameHint("int.sub")] +func %intx5Fsub : Func(Int, Int, Int); + +[intrinsicOp(266 : Int)] +[method] +[import("_S4core3int3mulp1pi_ii")] +[nameHint("int.mul")] +func %intx5Fmul : Func(Int, Int, Int); + +[intrinsicOp(267 : Int)] +[method] +[import("_S4core3int3divp1pi_ii")] +[nameHint("int.div")] +func %intx5Fdiv : Func(Int, Int, Int); + +[intrinsicOp(269 : Int)] +[method] +[import("_S4core3int3modp1pi_ii")] +[nameHint("int.mod")] +func %intx5Fmod : Func(Int, Int, Int); + +[intrinsicOp(283 : Int)] +[method] +[import("_S4core3int3negp0pi")] +[nameHint("int.neg")] +func %intx5Fneg : Func(Int, Int); + +[intrinsicOp(0 : Int)] +[method] +[import("_S4core3intR8_24xinitp1pi_i")] +[nameHint("int.$init")] +func %intx5Fx24init : Func(Int, Int); + +[export("_SWi4core11IArithmetic")] +witness_table %216 : witness_table_t(%IArithmetic)(Int) +{ + witness_table_entry(%124,%215) + + witness_table_entry(%126,%intx5Fadd) + + witness_table_entry(%128,%intx5Fsub) + + witness_table_entry(%130,%intx5Fmul) + + witness_table_entry(%132,%intx5Fdiv) + + witness_table_entry(%134,%intx5Fmod) + + witness_table_entry(%136,%intx5Fneg) + + witness_table_entry(%138,%intx5Fx24init) + + witness_table_entry(%140,%intx5Fx24init) + +} + +[export("_SWi4core23__BuiltinArithmeticType")] +witness_table %217 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Int) +{ + witness_table_entry(%120,%214) + + witness_table_entry(%122,%216) + +} + +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %218( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%219, %220, %221, %y, 0 : Int) + +block %219( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %222 : Bool = cmpLT(%i, 3 : Int) + ifElse(%222, %223, %220, %223) + +block %223: + let %224 : Float = mul(%t, %t) + unconditionalBranch(%221) + +block %221: + let %225 : Int = add(%i, 1 : Int) + unconditionalBranch(%219, %224, %225) + +block %220: + return_val(%t) +} +[import("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[import("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %226 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %226) = global_param +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %227( + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %206)) = var + let %228 : DiffPairUserCode(Float, %206) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %228) + let %229 : Func(Void, InOut(DiffPairUserCode(Float, %206)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %229(%dpa, 1 : Float) + let %230 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %231 : DiffPairUserCode(Float, %206) = load(%dpa) + let %232 : Float = GetDifferentialUserCode(%231) + store(%230, %232) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %206)) = var + let %233 : DiffPairUserCode(Float, %206) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %233) + let %234 : Func(Void, InOut(DiffPairUserCode(Float, %206)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %234(%dpa1, 1 : Float) + let %235 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %236 : DiffPairUserCode(Float, %206) = load(%dpa1) + let %237 : Float = GetDifferentialUserCode(%236) + store(%235, %237) + return_val(void_constant) +} +### +### POST IR VALIDATION: +varLayout(%1) +let %1 : Void = structTypeLayout(%2) +let %2 : Void = fieldLayout(%outputBuffer, %3) +let %3 : Void = varLayout(%4, %5) +let %5 : Void = offset(9 : Int, 0 : Int) +let %4 : Void = structuredBufferTypeLayout(%6, %7) +let %7 : Void = size(9 : Int, 1 : Int) +let %6 : Void = typeLayout(%8) +let %8 : Void = size(8 : Int, 4 : Int) +let %9 : Void = no_diff +let %10 : Void = EntryPointLayout(%11, %12) +let %12 : Void = varLayout(%13) +let %11 : Void = varLayout(%14) +let %14 : Void = structTypeLayout(%15) +let %15 : Void = fieldLayout(%16, %17) +let %17 : Void = varLayout(%13, %18, %19) +let %19 : Void = stage(6 : Int) +let %18 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %13 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %16 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +let %27 : _ = interface_req_entry(%26, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %28 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %29 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %30 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %31 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %32 : _ = interface_req_entry(%31, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %33 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %34 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %39 : _ = key +let %40 : _ = interface_req_entry(%39, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%36, %38, %40) +let %41 : _ = interface_req_entry(%34, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %56 : _ = key +let %57 : _ = interface_req_entry(%56, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%41, %43, %45, %47, %49, %51, %53, %55, %57) +let %58 : _ = interface_req_entry(%33, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%32, %58) +let %59 : _ = interface_req_entry(%30, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%59) +let %60 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%60) +generic %61 : Generic +{ +block %62( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %63 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %64 : _ = interface_req_entry(%28, %61) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%21, %23, %25, %27, %64) +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %65: + return_val(0 : Float) +} +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %66( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %67 : Float = add(%a, %b) + return_val(%67) +} +generic %68 : Generic +{ +block %69( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %70 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %9), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %71 : %68 +{ +block %72( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %73 : witness_table_t(%x5Fx5FBuiltinRealType)): + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %9), Float) + { +block %74( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %9), + [nameHint("b")] + param %b1 : Float): + let %75 : Float = floatCast(%a1) + let %76 : Float = mul(%75, %b1) + return_val(%76) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %77 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%20,Float) + + witness_table_entry(%22,%77) + + witness_table_entry(%24,%floatx5Fdzero) + + witness_table_entry(%26,%floatx5Fdadd) + + witness_table_entry(%28,%71) + +} + +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %78( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%79, %80, %81, %y, 0 : Int) + +block %79( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %82 : Bool = cmpLT(%i, 3 : Int) + ifElse(%82, %83, %80, %83) + +block %83: + let %84 : Float = mul(%t, %t) + unconditionalBranch(%81) + +block %81: + let %85 : Int = add(%i, 1 : Int) + unconditionalBranch(%79, %84, %85) + +block %80: + return_val(%t) +} +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %86 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%3)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %86) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%10)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %87( + [layout(%17)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %77)) = var + let %88 : DiffPairUserCode(Float, %77) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %88) + let %89 : Func(Void, InOut(DiffPairUserCode(Float, %77)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %89(%dpa, 1 : Float) + let %90 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %91 : DiffPairUserCode(Float, %77) = load(%dpa) + let %92 : Float = GetDifferentialUserCode(%91) + store(%90, %92) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %77)) = var + let %93 : DiffPairUserCode(Float, %77) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %93) + let %94 : Func(Void, InOut(DiffPairUserCode(Float, %77)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %94(%dpa1, 1 : Float) + let %95 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %96 : DiffPairUserCode(Float, %77) = load(%dpa1) + let %97 : Float = GetDifferentialUserCode(%96) + store(%95, %97) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} + +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %98: + let %99 : %NullDifferential = makeStruct(0 : UInt) + return_val(%99) +} +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %100( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %101 : %NullDifferential = makeStruct(0 : UInt) + return_val(%101) +} +generic %102 : Generic +{ +block %103( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %104 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %9), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %105 : %102 +{ +block %106( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %107 : witness_table_t(%x5Fx5FBuiltinRealType)): + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %9), %NullDifferential) + { +block %108( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %9), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %109 : %NullDifferential = makeStruct(0 : UInt) + return_val(%109) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %110 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%20,%NullDifferential) + + witness_table_entry(%22,%110) + + witness_table_entry(%24,%NullDifferentialx5Fdzero) + + witness_table_entry(%26,%NullDifferentialx5Fdadd) + + witness_table_entry(%28,%105) + +} + +### +### BEFORE-SPECIALIZE: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) + + witness_table_entry(%20,%75) + + witness_table_entry(%22,%floatx5Fdzero) + + witness_table_entry(%24,%floatx5Fdadd) + + witness_table_entry(%26,%69) + +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) + +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) + +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) + +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) + +block %78: + return_val(%t) +} +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %85( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) + let %87 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %87(%dpa, 1 : Float) + let %88 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %89 : DiffPairUserCode(Float, %75) = load(%dpa) + let %90 : Float = GetDifferentialUserCode(%89) + store(%88, %90) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %91 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %91) + let %92 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %92(%dpa1, 1 : Float) + let %93 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %94 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %95 : Float = GetDifferentialUserCode(%94) + store(%93, %95) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %96: + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %98( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %99 : %NullDifferential = makeStruct(0 : UInt) + return_val(%99) +} +generic %100 : Generic +{ +block %101( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %102 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %103 : %100 +{ +block %104( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %105 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %106( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %107 : %NullDifferential = makeStruct(0 : UInt) + return_val(%107) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %108 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) + + witness_table_entry(%20,%108) + + witness_table_entry(%22,%NullDifferentialx5Fdzero) + + witness_table_entry(%24,%NullDifferentialx5Fdadd) + + witness_table_entry(%26,%103) + +} + +### +### AFTER-SPECIALIZE: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) + + witness_table_entry(%20,%75) + + witness_table_entry(%22,%floatx5Fdzero) + + witness_table_entry(%24,%floatx5Fdadd) + + witness_table_entry(%26,%69) + +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) + +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) + +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) + +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) + +block %78: + return_val(%t) +} +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %85( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) + let %87 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %87(%dpa, 1 : Float) + let %88 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %89 : DiffPairUserCode(Float, %75) = load(%dpa) + let %90 : Float = GetDifferentialUserCode(%89) + store(%88, %90) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %91 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %91) + let %92 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %92(%dpa1, 1 : Float) + let %93 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %94 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %95 : Float = GetDifferentialUserCode(%94) + store(%93, %95) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %96: + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %98( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %99 : %NullDifferential = makeStruct(0 : UInt) + return_val(%99) +} +generic %100 : Generic +{ +block %101( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %102 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %103 : %100 +{ +block %104( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %105 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %106( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %107 : %NullDifferential = makeStruct(0 : UInt) + return_val(%107) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %108 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) + + witness_table_entry(%20,%108) + + witness_table_entry(%22,%NullDifferentialx5Fdzero) + + witness_table_entry(%24,%NullDifferentialx5Fdadd) + + witness_table_entry(%26,%103) + +} + +GenericSpecializationDictionary +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +### +### BEFORE-AUTODIFF: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) + + witness_table_entry(%20,%75) + + witness_table_entry(%22,%floatx5Fdzero) + + witness_table_entry(%24,%floatx5Fdadd) + + witness_table_entry(%26,%69) + +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) + +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) + +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) + +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) + +block %78: + return_val(%t) +} +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %85( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) + let %87 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %87(%dpa, 1 : Float) + let %88 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %89 : DiffPairUserCode(Float, %75) = load(%dpa) + let %90 : Float = GetDifferentialUserCode(%89) + store(%88, %90) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %91 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %91) + let %92 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %92(%dpa1, 1 : Float) + let %93 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %94 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %95 : Float = GetDifferentialUserCode(%94) + store(%93, %95) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %96: + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %98( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %99 : %NullDifferential = makeStruct(0 : UInt) + return_val(%99) +} +generic %100 : Generic +{ +block %101( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %102 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %103 : %100 +{ +block %104( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %105 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %106( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %107 : %NullDifferential = makeStruct(0 : UInt) + return_val(%107) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %108 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) + + witness_table_entry(%20,%108) + + witness_table_entry(%22,%NullDifferentialx5Fdzero) + + witness_table_entry(%24,%NullDifferentialx5Fdadd) + + witness_table_entry(%26,%103) + +} + +GenericSpecializationDictionary +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +### BACKWARD DIFFERENTIATE BACKWARD DIFFERENTIATE BACKWARD DIFFERENTIATE PRIMAL BACKWARD DIFFERENTIATE PROPOGATE (result before eliminating phis)=============================== inst with location: 1514954 (1) -[nameHint("y")] -let %y : Float = param +[nameHint("y")] +let %y : Float = param + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, %y, 0 : Int) + +inst with location: 1514994 (1) +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[nameHint("i")] +let %i : Int = param + +inst with location: 1515008 (1) +loop(%1, %2, %1) + +inst with location: 1515026 (1) +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 1515008 (1) +ifElse(%1, %2, %3, %2) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515058 (1) +let %1 : Float = mul(%t, %t) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515008 (1) +unconditionalBranch(%1) + +inst with location: 1515032 (1) +let %1 : Int = add(%i, 1 : Int) + +inst with location: 1515008 (1) +unconditionalBranch(%1, %2, %3) + +inst with location: 1515077 (1) +return_val(%t) + +(fwdDiffFunc from generateNewForwardDerivative)=============================== +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[forwardDifferentiable] +[nameHint("s_fwd_test_simple_loop")] +func %sx5Ffwdx5Ftestx5Fsimplex5Floop : Func(DiffPair(Float, %1), DiffPair(Float, %1)) +{ +block %2( + [nameHint("dpy")] + param %dpy : DiffPair(Float, %1)): + [diffInstDecoration(Float)] + let %3 : Float = GetDifferential(%dpy) + [primalInstDecoration] + let %4 : Float = GetPrimal(%dpy) + [mixedDiffInstDecoration()] + [loopMaxIters(4 : Int)] + loop(%5, %6, %5, true, %4, %3, 0 : Int) + +block %5( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t : Float, + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft : Float, + [primalInstDecoration] + [nameHint("i")] + param %i : Int): + [mixedDiffInstDecoration()] + ifElse(%x5Fbflag, %7, %8, %7) + +block %8: + [mixedDiffInstDecoration()] + unconditionalBranch(%6) + +block %6: + [mixedDiffInstDecoration(DiffPair(Float, %1))] + let %9 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + [mixedDiffInstDecoration(DiffPair(Float, %1))] + return_val(%9) + +block %7: + [mixedDiffInstDecoration()] + unconditionalBranch(%10) + +block %10: + [primalInstDecoration] + let %11 : Bool = cmpLT(%i, 3 : Int) + [mixedDiffInstDecoration()] + ifElse(%11, %12, %13, %14) + +block %13: + [diffInstDecoration(Float)] + let %15 : Float = call %floatx5Fdzero() + [mixedDiffInstDecoration()] + unconditionalBranch(%14, 0 : Int, 0 : Float, %15) + +block %12: + [primalInstDecoration] + let %16 : Float = mul(%t, %t) + [diffInstDecoration(Float)] + let %17 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %18 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %19 : Float = add(%17, %18) + [mixedDiffInstDecoration()] + unconditionalBranch(%14, 1 : Int, %16, %19) + +block %14( + [primalInstDecoration] + param %20 : Int, + [primalInstDecoration] + param %21 : Float, + [diffInstDecoration(Float)] + param %22 : Float): + [mixedDiffInstDecoration()] + unconditionalBranch(%23) + +block %23: + [primalInstDecoration] + let %24 : Bool = cmpNE(%20, 1 : Int) + [mixedDiffInstDecoration()] + ifElse(%24, %25, %26, %27) + +block %26: + [mixedDiffInstDecoration()] + unconditionalBranch(%27, %x5Fbflag) + +block %25: + [mixedDiffInstDecoration()] + unconditionalBranch(%27, false) + +block %27( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + [mixedDiffInstDecoration()] + unconditionalBranch(%28) + +block %28: + [mixedDiffInstDecoration()] + ifElse(%x5Fbflag1, %29, %30, %31) + +block %30: + [mixedDiffInstDecoration()] + unconditionalBranch(%31, %t, %sx5Fdiffx5Ft, %i) + +block %29: + [primalInstDecoration] + let %32 : Int = add(%i, 1 : Int) + [mixedDiffInstDecoration()] + unconditionalBranch(%31, %21, %22, %32) + +block %31( + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int): + [mixedDiffInstDecoration()] + unconditionalBranch(%5, %x5Fbflag1, %t1, %sx5Fdiffx5Ft1, %i1) +} + +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : DiffPair(Float, %1) = param + +inst with location: 1514954 (1) +[diffInstDecoration(Float)] +let %1 : Float = GetDifferential(%dpy) + +inst with location: 1514954 (1) +[primalInstDecoration] +let %1 : Float = GetPrimal(%dpy) + +inst with location: 1515008 (1) +[mixedDiffInstDecoration()] +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %3, %4, 0 : Int) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 0 (0) +[mixedDiffInstDecoration(DiffPair(Float, %1))] +let %2 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + +inst with location: 1515077 (1) +[mixedDiffInstDecoration(DiffPair(Float, %1))] +return_val(%2) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 1515026 (1) +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, 0 : Int, 0 : Float, %2) + +inst with location: 1515058 (1) +[primalInstDecoration] +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 1515058 (1) +[diffInstDecoration(Float)] +let %1 : Float = add(%2, %3) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, 1 : Int, %2, %3) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Int = param + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Float = param + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) + +inst with location: 1515032 (1) +[primalInstDecoration] +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %2, %3, %4) + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +[mixedDiffInstDecoration()] +unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) + +(diffPropagateFunc after unzipping)=============================== +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)); + + +(unzipDiffInsts)=============================== +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : DiffPair(Float, %1) = param + +inst with location: 0 (0) +let %1 : Float = PrimalParamRef(%dpy) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = DiffParamRef(%dpy) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %3, 0 : Int) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[BackwardDerivativePrimalReturnDecoration(%t)] +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515026 (1) +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, 0 : Int, 0 : Float) + +inst with location: 1515058 (1) +[primalInstDecoration] +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +unconditionalBranch(%1, 1 : Int, %2) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Int = param + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %t, %i) + +inst with location: 1515032 (1) +[primalInstDecoration] +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, %3) + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag, %t, %i) + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, %3) + +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +return_val(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 1515058 (1) +[diffInstDecoration(Float)] +let %1 : Float = add(%2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) + +(diffPropagateFunc moving blocks)=============================== +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)) +{ +block %2( + [nameHint("dpy")] + param %dpy : DiffPair(Float, %1)): + let %3 : Float = PrimalParamRef(%dpy) + [diffInstDecoration(Float)] + let %4 : Float = DiffParamRef(%dpy) + unconditionalBranch(%5) + +block %5: + [loopMaxIters(4 : Int)] + loop(%6, %7, %6, true, %3, 0 : Int) + +block %6( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t : Float, + [primalInstDecoration] + [nameHint("i")] + param %i : Int): + ifElse(%x5Fbflag, %8, %9, %8) + +block %9: + unconditionalBranch(%7) + +block %7: + [BackwardDerivativePrimalReturnDecoration(%t)] + unconditionalBranch(%10) + +block %8: + unconditionalBranch(%11) + +block %11: + [primalInstDecoration] + let %12 : Bool = cmpLT(%i, 3 : Int) + ifElse(%12, %13, %14, %15) + +block %14: + unconditionalBranch(%15, 0 : Int, 0 : Float) + +block %13: + [primalInstDecoration] + let %16 : Float = mul(%t, %t) + unconditionalBranch(%15, 1 : Int, %16) + +block %15( + [primalInstDecoration] + param %17 : Int, + [primalInstDecoration] + param %18 : Float): + unconditionalBranch(%19) + +block %19: + [primalInstDecoration] + let %20 : Bool = cmpNE(%17, 1 : Int) + ifElse(%20, %21, %22, %23) + +block %22: + unconditionalBranch(%23, %x5Fbflag) + +block %21: + unconditionalBranch(%23, false) + +block %23( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%24) + +block %24: + ifElse(%x5Fbflag1, %25, %26, %27) + +block %26: + unconditionalBranch(%27, %t, %i) + +block %25: + [primalInstDecoration] + let %28 : Int = add(%i, 1 : Int) + unconditionalBranch(%27, %18, %28) + +block %27( + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int): + unconditionalBranch(%6, %x5Fbflag1, %t1, %i1) + +block %10: + [loopMaxIters(4 : Int)] + loop(%29, %30, %29, %4) + +block %29( + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft : Float): + ifElse(%x5Fbflag, %31, %32, %31) + +block %32: + unconditionalBranch(%30) + +block %30: + [diffInstDecoration(Float)] + let %33 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + [diffInstDecoration(Float)] + return_val(%33) + +block %31: + unconditionalBranch(%34) + +block %34: + ifElse(%12, %35, %36, %37) + +block %36: + [diffInstDecoration(Float)] + let %38 : Float = call %floatx5Fdzero() + unconditionalBranch(%37, %38) + +block %35: + [diffInstDecoration(Float)] + let %39 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %40 : Float = mul(%sx5Fdiffx5Ft, %t) + [diffInstDecoration(Float)] + let %41 : Float = add(%39, %40) + unconditionalBranch(%37, %41) + +block %37( + [diffInstDecoration(Float)] + param %42 : Float): + unconditionalBranch(%43) + +block %43: + ifElse(%20, %44, %45, %46) + +block %45: + unconditionalBranch(%46) + +block %44: + unconditionalBranch(%46) + +block %46: + unconditionalBranch(%47) + +block %47: + ifElse(%x5Fbflag1, %48, %49, %50) + +block %49: + unconditionalBranch(%50, %sx5Fdiffx5Ft) + +block %48: + unconditionalBranch(%50, %42) + +block %50( + [diffInstDecoration(Float)] + [nameHint("s_diff_t")] + param %sx5Fdiffx5Ft1 : Float): + unconditionalBranch(%29, %sx5Fdiffx5Ft1) +} + +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : DiffPair(Float, %1) = param + +inst with location: 0 (0) +let %1 : Float = PrimalParamRef(%dpy) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = DiffParamRef(%dpy) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, true, %3, 0 : Int) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[BackwardDerivativePrimalReturnDecoration(%t)] +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515026 (1) +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, 0 : Int, 0 : Float) + +inst with location: 1515058 (1) +[primalInstDecoration] +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +unconditionalBranch(%1, 1 : Int, %2) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Int = param + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %t, %i) + +inst with location: 1515032 (1) +[primalInstDecoration] +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, %3) + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag, %t, %i) + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +loop(%1, %2, %1, %3) + +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +return_val(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + +inst with location: 1515058 (1) +[diffInstDecoration(Float)] +let %1 : Float = add(%2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +[diffInstDecoration(Float)] +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 1514994 (1) +[diffInstDecoration(Float)] +[nameHint("s_diff_t")] +let %sx5Fdiffx5Ft : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1, %sx5Fdiffx5Ft) + +(applyCheckpointPolicy) =============================== +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : Float = param + +inst with location: 0 (0) +[nameHint("dpy")] +let %dpy : InOut(DiffPair(Float, %1)) = param + +inst with location: 0 (0) +[nameHint("_s_dOut")] +let %x5Fsx5FdOut : Float = param + +inst with location: 0 (0) +[nameHint("_s_diff_ctx")] +let %x5Fsx5Fdiffx5Fctx : BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop) = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : DiffPair(Float, %2) = load(%dpy) + +inst with location: 0 (0) +[keepAlive] +let %1 : Float = GetPrimal(%2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515008 (1) +[loopMaxIters(4 : Int)] +let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[BackwardDerivativePrimalReturnDecoration(%t)] +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +let %1 : Ptr(Float) = var + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +let %1 : Ptr(Float) = var + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %2) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[diffInstDecoration(Void, %1)] +[loopMaxIters(4 : Int)] +loop(%2, %3, %4) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %1) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : DiffPair(Float, %2) = load(%dpy) + +inst with location: 0 (0) +let %1 : Float = GetPrimal(%2) + +inst with location: 0 (0) +let %1 : DiffPair(Float, %2) = MakeDiffPair(%3, %4) + +inst with location: 0 (0) +store(%dpy, %1) + +inst with location: 0 (0) +return_val(void_constant) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdzero() + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1, %2) + +inst with location: 0 (0) +let %1 : Float = param + +inst with location: 0 (0) +let %1 : Float = mul(%t, %2) + +inst with location: 0 (0) +let %1 : Float = mul(%t, %2) + +inst with location: 0 (0) +let %1 : Float = load(%2) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +let %1 : Float = call %floatx5Fdadd(%2, %3) + +inst with location: 0 (0) +store(%1, %2) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 1515026 (1) +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, 0 : Int, 0 : Float) + +inst with location: 1515058 (1) +[primalInstDecoration] +let %1 : Float = mul(%t, %t) + +inst with location: 0 (0) +unconditionalBranch(%1, 1 : Int, %2) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Int = param + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Float = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +inst with location: 0 (0) +ifElse(%1, %2, %3, %4) + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag) + +inst with location: 0 (0) +unconditionalBranch(%1, false) + +inst with location: 0 (0) +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +inst with location: 0 (0) +unconditionalBranch(%1) + +inst with location: 0 (0) +ifElse(%x5Fbflag, %1, %2, %3) + +inst with location: 0 (0) +unconditionalBranch(%1, %t, %i) + +inst with location: 1515032 (1) +[primalInstDecoration] +let %1 : Int = add(%i, 1 : Int) + +inst with location: 0 (0) +unconditionalBranch(%1, %2, %3) + +inst with location: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1515017 (1) +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +inst with location: 0 (0) +unconditionalBranch(%1, %x5Fbflag, %t, %i) + +Adding counter for primalLoop: +[loopMaxIters(4 : Int)] +let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) + + > sourceLoc: 1515008 (1) +>> Counter for primalLoop: +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + + > sourceLoc: 1515008 (1) +### Slang::AutodiffCheckpointPolicyBase::processFunc +processing workList +use with usedVal: +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3CC5E0 to storeSet +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1514994 (1) +use with usedVal: +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3CC5E0 to storeSet +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +inst with location: 1514994 (1) +use with usedVal: +[primalInstDecoration] +let %1 : Bool = cmpLT(%i, 3 : Int) + +use with usedVal: +[primalInstDecoration] +[nameHint("i")] +let %i : Int = param + +use with usedVal: +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +use with usedVal: +[primalInstDecoration] +let %1 : Int = param + +use with usedVal: +0 + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3BDB60 to storeSet +0 +inst with location: 0 (0) +use with usedVal: +1 + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3BD730 to storeSet +1 +inst with location: 0 (0) +use with usedVal: +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +use with usedVal: +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +use with usedVal: + + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3C97B0 to storeSet + +inst with location: 0 (0) +use with usedVal: +[nameHint("dpy")] +let %dpy : InOut(DiffPair(Float, %1)) = param + +use with usedVal: +[nameHint("dpy")] +let %dpy : InOut(DiffPair(Float, %1)) = param + +use with usedVal: +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + + +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3E5848 to storeSet +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + +inst with location: 1515008 (1) +use with usedVal: +[nameHint("_s_dOut")] +let %x5Fsx5FdOut : Float = param + +****** (before legalization) # of elements in the store set for hoistInfo: 2 +source loc recorded: 1514994 (1) +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +source loc recorded: 1515008 (1) +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + +****** ensureInstAvailable +ensureInstAvailable, worklist element: +[primalInstDecoration] +[nameHint("_pc")] +[loopCounterDecoration] +let %x5Fpc : Int = param + +>> LOOP COUNTER! +% localVar: +let %1 : Ptr(Int) = var + +ensureInstAvailable, worklist element: +[primalInstDecoration] +[nameHint("t")] +let %t : Float = param + +% localVar: +let %1 : Ptr(Array(Float, 5 : Int)) = var + +ensureInstAvailable, worklist element: +[primalInstDecoration] +[nameHint("_bflag")] +let %x5Fbflag : Bool = param + +>> NO OUT OF SCOPE USES +ensureInstAvailable, worklist element: +[primalInstDecoration] +let %1 : Bool = cmpNE(%2, 1 : Int) + +>> NO OUT OF SCOPE USES +ensureInstAvailable, worklist element: +[primalInstDecoration] +let %1 : Int = param + +>> NO OUT OF SCOPE USES +ensureInstAvailable, worklist element: +[primalInstDecoration] +let %1 : Bool = cmpLT(%2, 3 : Int) + +>> NO OUT OF SCOPE USES +****** (after legalization) # of elements in the store set for hoistInfo: 2 +source loc recorded: 1515008 (1) +let %1 : Ptr(Int) = var + +tests/autodiff/reverse-loop.slang(16): note: also see pipeline definition + for (int i = 0; i < 3; i++) + ^~~ +source loc recorded: 1514994 (1) +let %1 : Ptr(Array(Float, 5 : Int)) = var + +tests/autodiff/reverse-loop.slang(14): note: also see pipeline definition + float t = y; + ^ +in unzipping function: +createIntermediate type: +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type; + + +adding field to outIntermediatery +inst: 1514994 (1) +let %1 : Ptr(Array(Float, 5 : Int)) = var + +[IntermediateContextFieldDifferentialTypeDecoration(%1)] +field(%2, Array(Float, 5 : Int)) + +adding field to outIntermediatery +inst: 1515008 (1) +let %1 : Ptr(Int) = var + +field(%1, Int) + +### AFTER-AUTODIFF: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) + + witness_table_entry(%20,%75) + + witness_table_entry(%22,%floatx5Fdzero) + + witness_table_entry(%24,%floatx5Fdadd) + + witness_table_entry(%26,%69) + +} + +[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] +[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] +[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] +[primalInstDecoration] +[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) + +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) + +block %78: + return_val(%t) + +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) + +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) +} +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %85( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) + let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %88 : DiffPairUserCode(Float, %75) = load(%dpa) + let %89 : Float = GetDifferentialUserCode(%88) + store(%87, %89) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %90) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) + let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %93 : Float = GetDifferentialUserCode(%92) + store(%91, %93) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %94: + let %95 : %NullDifferential = makeStruct(0 : UInt) + return_val(%95) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %96( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} +generic %98 : Generic +{ +block %99( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %101 : %98 +{ +block %102( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %104( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %105 : %NullDifferential = makeStruct(0 : UInt) + return_val(%105) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) + + witness_table_entry(%20,%106) + + witness_table_entry(%22,%NullDifferentialx5Fdzero) + + witness_table_entry(%24,%NullDifferentialx5Fdadd) + + witness_table_entry(%26,%101) + +} + +GenericSpecializationDictionary +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_test_simple_loop")] +func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) +{ +block %107( + param %108 : InOut(DiffPairUserCode(Float, %75)), + param %109 : Float): + let %110 : DiffPairUserCode(Float, %75) = load(%108) + let %111 : Float = GetPrimalUserCode(%110) + let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) + let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) + return_val(void_constant) +} +[nameHint("s_primal_ctx_test_simple_loop")] +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) +{ +block %115( + [nameHint("dpy")] + param %dpy : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): + unconditionalBranch(%116) + +block %116: + let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct + store(%x5Fsx5Fdiffx5Fctx, %117) + let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) + let %120 : Ptr(Array(Float, 5 : Int)) = var + let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%120, %121) + let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%118, %122) + let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + let %125 : Ptr(Int) = var + store(%125, 0 : Int) + store(%123, 0 : Int) + unconditionalBranch(%126) + +block %126: + [loopMaxIters(4 : Int)] + loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) + +block %127( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc : Int): + let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) + store(%129, %t1) + store(%123, %x5Fpc) + ifElse(%x5Fbflag, %130, %131, %130) + +block %131: + unconditionalBranch(%128) + +block %128: + return_val(%t1) + +block %130: + unconditionalBranch(%132) + +block %132: + [primalInstDecoration] + let %133 : Bool = cmpLT(%i1, 3 : Int) + ifElse(%133, %134, %135, %136) + +block %135: + unconditionalBranch(%136, 0 : Int, 0 : Float) + +block %134: + [primalInstDecoration] + let %137 : Float = mul(%t1, %t1) + unconditionalBranch(%136, 1 : Int, %137) + +block %136( + [primalInstDecoration] + param %138 : Int, + [primalInstDecoration] + param %139 : Float): + unconditionalBranch(%140) + +block %140: + [primalInstDecoration] + let %141 : Bool = cmpNE(%138, 1 : Int) + ifElse(%141, %142, %143, %144) + +block %143: + unconditionalBranch(%144, %x5Fbflag) + +block %142: + unconditionalBranch(%144, false) + +block %144( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%145) + +block %145: + ifElse(%x5Fbflag1, %146, %147, %148) + +block %147: + unconditionalBranch(%148, %t1, %i1) + +block %146: + [primalInstDecoration] + let %149 : Int = add(%i1, 1 : Int) + unconditionalBranch(%148, %139, %149) + +block %148( + [primalInstDecoration] + [nameHint("t")] + param %t2 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i2 : Int): + [primalInstDecoration] + let %150 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) +} +[fwdDerivative(%151)] +[primalInstDecoration] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop1 : Func(Float, Float) +{ +block %152( + [nameHint("y")] + param %y1 : Float): + [loopMaxIters(4 : Int)] + loop(%153, %154, %153, true, %y1, 0 : Int) + +block %153( + [nameHint("_bflag")] + param %x5Fbflag2 : Bool, + [nameHint("t")] + param %t3 : Float, + [nameHint("i")] + param %i3 : Int): + ifElse(%x5Fbflag2, %155, %156, %155) + +block %156: + unconditionalBranch(%154) + +block %154: + return_val(%t3) + +block %155: + unconditionalBranch(%157) + +block %157: + let %158 : Bool = cmpLT(%i3, 3 : Int) + ifElse(%158, %159, %160, %161) + +block %160: + unconditionalBranch(%161, 0 : Int, 0 : Float) + +block %159: + let %162 : Float = mul(%t3, %t3) + unconditionalBranch(%161, 1 : Int, %162) + +block %161( + param %163 : Int, + param %164 : Float): + unconditionalBranch(%165) + +block %165: + let %166 : Bool = cmpNE(%163, 1 : Int) + ifElse(%166, %167, %168, %169) + +block %168: + unconditionalBranch(%169, %x5Fbflag2) -inst with location: 1515008 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, %y, 0 : Int) +block %167: + unconditionalBranch(%169, false) -inst with location: 1514994 (1) -[nameHint("t")] -let %t : Float = param +block %169( + [nameHint("_bflag")] + param %x5Fbflag3 : Bool): + unconditionalBranch(%170) -inst with location: 1515017 (1) -[nameHint("i")] -let %i : Int = param +block %170: + ifElse(%x5Fbflag3, %171, %172, %173) + +block %172: + unconditionalBranch(%173, %t3, %i3) + +block %171: + let %174 : Int = add(%i3, 1 : Int) + unconditionalBranch(%173, %164, %174) + +block %173( + [nameHint("t")] + param %t4 : Float, + [nameHint("i")] + param %i4 : Int): + unconditionalBranch(%153, %x5Fbflag3, %t4, %i4) +} +[derivativeMemberDecoration(%175)] +let %119 : _ = key +let %124 : _ = key +struct %176 : Type +{ + field(%175, Array(Float, 5 : Int)) +} + +func %177 : Func(%176) +{ +block %178: + let %179 : Array(Float, 5 : Int) = call %180() + let %181 : %176 = makeStruct(%179) + return_val(%181) +} +func %182 : Func(%176) +{ +block %183( + param %184 : %176, + param %185 : %176): + let %186 : Array(Float, 5 : Int) = get_field(%184, %175) + let %187 : Array(Float, 5 : Int) = get_field(%185, %175) + let %188 : Array(Float, 5 : Int) = call %189(%186, %187) + let %190 : %176 = makeStruct(%188) + return_val(%190) +} +witness_table %191 : witness_table_t(%IDifferentiable)(%176) +{ + witness_table_entry(%18,%176) + + witness_table_entry(%20,%191) + + witness_table_entry(%22,%177) + + witness_table_entry(%24,%182) + +} + +witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ + witness_table_entry(%18,%176) + + witness_table_entry(%20,%191) + + witness_table_entry(%22,%177) + + witness_table_entry(%24,%182) + +} + +[derivativeMemberDecoration(%175)] +let %175 : _ = key +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + [IntermediateContextFieldDifferentialTypeDecoration(%193)] + field(%119, Array(Float, 5 : Int)) + field(%124, Int) +} + +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ +block %194( + [nameHint("dpy")] + param %dpy1 : InOut(DiffPairUserCode(Float, %75)), + [nameHint("_s_dOut")] + param %x5Fsx5FdOut : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): + unconditionalBranch(%195) + +block %195: + let %196 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %197 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %198 : Ptr(Array(Float, 5 : Int)) = var + store(%198, %197) + store(%198, %196) + let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %200 : Ptr(Int) = var + store(%200, %199) + store(%200, 0 : Int) + let %201 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %202 : Float = GetPrimalUserCode(%201) + unconditionalBranch(%203) + +block %203: + [loopMaxIters(4 : Int)] + loop(%204, %205, %204, true, %202, 0 : Int, 0 : Int) + +block %204( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag4 : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t5 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i5 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc1 : Int): + let %206 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %207 : Ptr(Array(Float, 5 : Int)) = var + store(%207, %206) + let %208 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%207, %x5Fpc1) + store(%208, %t5) + let %209 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %210 : Ptr(Int) = var + store(%210, %209) + store(%210, %x5Fpc1) + ifElse(%x5Fbflag4, %211, %212, %211) + +block %212: + unconditionalBranch(%205) + +block %205: + unconditionalBranch(%213) + +block %213: + unconditionalBranch(%214) + +block %214: + unconditionalBranch(%215) + +block %215: + unconditionalBranch(%216) + +block %216: + unconditionalBranch(%217) + +block %217: + let %218 : Float = call %floatx5Fdzero() + let %219 : Ptr(Float) = var + store(%219, %218) + let %220 : Float = call %floatx5Fdzero() + let %221 : Ptr(Float) = var + store(%221, %220) + let %222 : Float = load(%219) + let %223 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %222) + store(%219, %223) + unconditionalBranch(%224) + +block %224: + let %225 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %226 : Int = sub(%225, 1 : Int) + [loopMaxIters(4 : Int)] + loop(%227, %228, %229, %226) + +block %227( + [primalInstDecoration] + [nameHint("_dc")] + param %x5Fdc : Int): + let %230 : Int = add(%x5Fdc, 0 : Int) + let %231 : Float = load(%219) + let %232 : Float = call %floatx5Fdzero() + store(%219, %232) + let %233 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%233, %234, %235, %234) + +block %235: + unconditionalBranch(%228, %231) + +block %228( + param %236 : Float): + let %237 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %238 : Float = GetPrimalUserCode(%237) + let %239 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%238, %236) + store(%dpy1, %239) + return_val(void_constant) + +block %234: + unconditionalBranch(%240) + +block %240: + [primalInstDecoration] + let %241 : Bool = cmpLT(%230, 3 : Int) + ifElse(%241, %242, %243, %244) + +block %243: + unconditionalBranch(%244, 0 : Int) + +block %242: + unconditionalBranch(%244, 1 : Int) + +block %244( + [primalInstDecoration] + param %245 : Int): + unconditionalBranch(%246) + +block %246: + [primalInstDecoration] + let %247 : Bool = cmpNE(%245, 1 : Int) + ifElse(%247, %248, %249, %250) + +block %249: + unconditionalBranch(%250, true) + +block %248: + unconditionalBranch(%250, false) + +block %250( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag5 : Bool): + unconditionalBranch(%251) + +block %251: + ifElse(%x5Fbflag5, %252, %253, %254) + +block %253: + unconditionalBranch(%254) + +block %252: + unconditionalBranch(%254) + +block %254: + unconditionalBranch(%255) + +block %255: + unconditionalBranch(%256, %231) + +block %256( + param %257 : Float): + ifElse(%x5Fbflag5, %258, %259, %260) + +block %259: + unconditionalBranch(%261, %257) + +block %261( + param %262 : Float): + let %263 : Float = load(%219) + let %264 : Float = call %floatx5Fdadd(%262, %263) + store(%219, %264) + unconditionalBranch(%260) + +block %258: + unconditionalBranch(%265, %257) + +block %265( + param %266 : Float): + let %267 : Float = load(%221) + let %268 : Float = call %floatx5Fdadd(%266, %267) + store(%221, %268) + unconditionalBranch(%260) + +block %260: + unconditionalBranch(%269) + +block %269: + ifElse(%247, %270, %271, %272) + +block %271: + unconditionalBranch(%272) + +block %270: + unconditionalBranch(%272) + +block %272: + unconditionalBranch(%273) + +block %273: + let %274 : Float = load(%221) + let %275 : Float = call %floatx5Fdzero() + store(%221, %275) + ifElse(%241, %276, %277, %278) + +block %277: + unconditionalBranch(%279) + +block %279: + unconditionalBranch(%278) + +block %276: + unconditionalBranch(%280, %274) + +block %280( + param %281 : Float): + let %282 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %283 : Ptr(Array(Float, 5 : Int)) = var + store(%283, %282) + let %284 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%283, %x5Fdc) + let %285 : Float = load(%284) + let %286 : Float = mul(%285, %281) + let %287 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %288 : Ptr(Array(Float, 5 : Int)) = var + store(%288, %287) + let %289 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%288, %x5Fdc) + let %290 : Float = load(%289) + let %291 : Float = mul(%290, %281) + let %292 : Float = load(%219) + let %293 : Float = call %floatx5Fdadd(%286, %291) + let %294 : Float = call %floatx5Fdadd(%293, %292) + store(%219, %294) + unconditionalBranch(%278) + +block %278: + unconditionalBranch(%229) + +block %229: + [primalInstDecoration] + let %295 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%227, %295) + +block %211: + unconditionalBranch(%296) + +block %296: + [primalInstDecoration] + let %297 : Bool = cmpLT(%i5, 3 : Int) + ifElse(%297, %298, %299, %300) + +block %299: + unconditionalBranch(%300, 0 : Int, 0 : Float) + +block %298: + [primalInstDecoration] + let %301 : Float = mul(%t5, %t5) + unconditionalBranch(%300, 1 : Int, %301) + +block %300( + [primalInstDecoration] + param %302 : Int, + [primalInstDecoration] + param %303 : Float): + unconditionalBranch(%304) + +block %304: + [primalInstDecoration] + let %305 : Bool = cmpNE(%302, 1 : Int) + ifElse(%305, %306, %307, %308) + +block %307: + unconditionalBranch(%308, %x5Fbflag4) + +block %306: + unconditionalBranch(%308, false) + +block %308( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag6 : Bool): + unconditionalBranch(%309) + +block %309: + ifElse(%x5Fbflag6, %310, %311, %312) + +block %311: + unconditionalBranch(%312, %t5, %i5) + +block %310: + [primalInstDecoration] + let %313 : Int = add(%i5, 1 : Int) + unconditionalBranch(%312, %303, %313) + +block %312( + [primalInstDecoration] + [nameHint("t")] + param %t6 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i6 : Int): + [primalInstDecoration] + let %314 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%204, %x5Fbflag6, %t6, %i6, %314) +} +[backwardDifferentiable] +func %189 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) +{ +block %315( + param %316 : Array(Float, 5 : Int), + param %317 : Array(Float, 5 : Int)): + let %318 : Ptr(Array(Float, 5 : Int)) = var + loop(%319, %320, %319, 0 : Int) + +block %319( + param %321 : Int): + let %322 : Bool = cmpLT(%321, 5 : Int) + ifElse(%322, %323, %324, %324) + +block %323: + let %325 : Float = getElement(%316, %321) + let %326 : Float = getElement(%317, %321) + let %327 : Float = call %floatx5Fdadd(%325, %326) + let %328 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%318, %321) + store(%328, %327) + unconditionalBranch(%329) + +block %324: + unconditionalBranch(%320) + +block %320: + let %330 : Array(Float, 5 : Int) = load(%318) + return_val(%330) + +block %329: + let %331 : Int = add(%321, 1 : Int) + unconditionalBranch(%319, %331) +} +func %180 : Func(Array(Float, 5 : Int)) +{ +block %332: + let %333 : Float = call %floatx5Fdzero() + let %334 : Array(Float, 5 : Int) = makeArrayFromElement(%333) + return_val(%334) +} +witness_table %193 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) +{ + witness_table_entry(%18,Array(Float, 5 : Int)) + + witness_table_entry(%20,%193) + + witness_table_entry(%24,%189) + + witness_table_entry(%22,%180) + +} + +### +### BEFORE-SPECIALIZE: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) + + witness_table_entry(%20,%75) + + witness_table_entry(%22,%floatx5Fdzero) + + witness_table_entry(%24,%floatx5Fdadd) + + witness_table_entry(%26,%69) + +} + +[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] +[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] +[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] +[primalInstDecoration] +[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) + +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) + +block %78: + return_val(%t) + +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) + +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) +} +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %85( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) + let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %88 : DiffPairUserCode(Float, %75) = load(%dpa) + let %89 : Float = GetDifferentialUserCode(%88) + store(%87, %89) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %90) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) + let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %93 : Float = GetDifferentialUserCode(%92) + store(%91, %93) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} + +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %94: + let %95 : %NullDifferential = makeStruct(0 : UInt) + return_val(%95) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %96( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} +generic %98 : Generic +{ +block %99( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %101 : %98 +{ +block %102( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %104( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %105 : %NullDifferential = makeStruct(0 : UInt) + return_val(%105) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) + + witness_table_entry(%20,%106) + + witness_table_entry(%22,%NullDifferentialx5Fdzero) + + witness_table_entry(%24,%NullDifferentialx5Fdadd) + + witness_table_entry(%26,%101) + +} + +GenericSpecializationDictionary +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_test_simple_loop")] +func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) +{ +block %107( + param %108 : InOut(DiffPairUserCode(Float, %75)), + param %109 : Float): + let %110 : DiffPairUserCode(Float, %75) = load(%108) + let %111 : Float = GetPrimalUserCode(%110) + let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) + let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) + return_val(void_constant) +} +[nameHint("s_primal_ctx_test_simple_loop")] +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) +{ +block %115( + [nameHint("dpy")] + param %dpy : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): + unconditionalBranch(%116) + +block %116: + let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct + store(%x5Fsx5Fdiffx5Fctx, %117) + let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) + let %120 : Ptr(Array(Float, 5 : Int)) = var + let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%120, %121) + let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%118, %122) + let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + let %125 : Ptr(Int) = var + store(%125, 0 : Int) + store(%123, 0 : Int) + unconditionalBranch(%126) + +block %126: + [loopMaxIters(4 : Int)] + loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) + +block %127( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc : Int): + let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) + store(%129, %t1) + store(%123, %x5Fpc) + ifElse(%x5Fbflag, %130, %131, %130) + +block %131: + unconditionalBranch(%128) + +block %128: + return_val(%t1) + +block %130: + unconditionalBranch(%132) + +block %132: + [primalInstDecoration] + let %133 : Bool = cmpLT(%i1, 3 : Int) + ifElse(%133, %134, %135, %136) + +block %135: + unconditionalBranch(%136, 0 : Int, 0 : Float) + +block %134: + [primalInstDecoration] + let %137 : Float = mul(%t1, %t1) + unconditionalBranch(%136, 1 : Int, %137) + +block %136( + [primalInstDecoration] + param %138 : Int, + [primalInstDecoration] + param %139 : Float): + unconditionalBranch(%140) + +block %140: + [primalInstDecoration] + let %141 : Bool = cmpNE(%138, 1 : Int) + ifElse(%141, %142, %143, %144) + +block %143: + unconditionalBranch(%144, %x5Fbflag) + +block %142: + unconditionalBranch(%144, false) + +block %144( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%145) + +block %145: + ifElse(%x5Fbflag1, %146, %147, %148) + +block %147: + unconditionalBranch(%148, %t1, %i1) + +block %146: + [primalInstDecoration] + let %149 : Int = add(%i1, 1 : Int) + unconditionalBranch(%148, %139, %149) + +block %148( + [primalInstDecoration] + [nameHint("t")] + param %t2 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i2 : Int): + [primalInstDecoration] + let %150 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) +} +[fwdDerivative(%151)] +[primalInstDecoration] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop1 : Func(Float, Float) +{ +block %152( + [nameHint("y")] + param %y1 : Float): + [loopMaxIters(4 : Int)] + loop(%153, %154, %153, true, %y1, 0 : Int) + +block %153( + [nameHint("_bflag")] + param %x5Fbflag2 : Bool, + [nameHint("t")] + param %t3 : Float, + [nameHint("i")] + param %i3 : Int): + ifElse(%x5Fbflag2, %155, %156, %155) + +block %156: + unconditionalBranch(%154) + +block %154: + return_val(%t3) + +block %155: + unconditionalBranch(%157) + +block %157: + let %158 : Bool = cmpLT(%i3, 3 : Int) + ifElse(%158, %159, %160, %161) + +block %160: + unconditionalBranch(%161, 0 : Int, 0 : Float) + +block %159: + let %162 : Float = mul(%t3, %t3) + unconditionalBranch(%161, 1 : Int, %162) + +block %161( + param %163 : Int, + param %164 : Float): + unconditionalBranch(%165) + +block %165: + let %166 : Bool = cmpNE(%163, 1 : Int) + ifElse(%166, %167, %168, %169) + +block %168: + unconditionalBranch(%169, %x5Fbflag2) + +block %167: + unconditionalBranch(%169, false) + +block %169( + [nameHint("_bflag")] + param %x5Fbflag3 : Bool): + unconditionalBranch(%170) + +block %170: + ifElse(%x5Fbflag3, %171, %172, %173) + +block %172: + unconditionalBranch(%173, %t3, %i3) + +block %171: + let %174 : Int = add(%i3, 1 : Int) + unconditionalBranch(%173, %164, %174) + +block %173( + [nameHint("t")] + param %t4 : Float, + [nameHint("i")] + param %i4 : Int): + unconditionalBranch(%153, %x5Fbflag3, %t4, %i4) +} +[derivativeMemberDecoration(%175)] +let %119 : _ = key +let %124 : _ = key +struct %176 : Type +{ + field(%175, Array(Float, 5 : Int)) +} -inst with location: 1515008 (1) -loop(%1, %2, %1) +func %177 : Func(%176) +{ +block %178: + let %179 : Array(Float, 5 : Int) = call %180() + let %181 : %176 = makeStruct(%179) + return_val(%181) +} +func %182 : Func(%176) +{ +block %183( + param %184 : %176, + param %185 : %176): + let %186 : Array(Float, 5 : Int) = get_field(%184, %175) + let %187 : Array(Float, 5 : Int) = get_field(%185, %175) + let %188 : Array(Float, 5 : Int) = call %189(%186, %187) + let %190 : %176 = makeStruct(%188) + return_val(%190) +} +witness_table %191 : witness_table_t(%IDifferentiable)(%176) +{ + witness_table_entry(%18,%176) -inst with location: 1515026 (1) -let %1 : Bool = cmpLT(%i, 3 : Int) + witness_table_entry(%20,%191) -inst with location: 1515008 (1) -ifElse(%1, %2, %3, %2) + witness_table_entry(%22,%177) -inst with location: 1515008 (1) -unconditionalBranch(%1) + witness_table_entry(%24,%182) -inst with location: 1515058 (1) -let %1 : Float = mul(%t, %t) +} -inst with location: 1515008 (1) -unconditionalBranch(%1) +witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ + witness_table_entry(%18,%176) -inst with location: 1515008 (1) -unconditionalBranch(%1) + witness_table_entry(%20,%191) -inst with location: 1515032 (1) -let %1 : Int = add(%i, 1 : Int) + witness_table_entry(%22,%177) -inst with location: 1515008 (1) -unconditionalBranch(%1, %2, %3) + witness_table_entry(%24,%182) -inst with location: 1515077 (1) -return_val(%t) +} + +[derivativeMemberDecoration(%175)] +let %175 : _ = key +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + [IntermediateContextFieldDifferentialTypeDecoration(%193)] + field(%119, Array(Float, 5 : Int)) + field(%124, Int) +} -(fwdDiffFunc from generateNewForwardDerivative)=============================== [FloatingPointModeOverride(1 : Int)] [DifferentiableTypeDictionaryDecoration] [backwardDifferentiable] -[forwardDifferentiable] -[nameHint("s_fwd_test_simple_loop")] -func %sx5Ffwdx5Ftestx5Fsimplex5Floop : Func(DiffPair(Float, %1), DiffPair(Float, %1)) +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { -block %2( +block %194( [nameHint("dpy")] - param %dpy : DiffPair(Float, %1)): - [diffInstDecoration(Float)] - let %3 : Float = GetDifferential(%dpy) - [primalInstDecoration] - let %4 : Float = GetPrimal(%dpy) - [mixedDiffInstDecoration()] + param %dpy1 : InOut(DiffPairUserCode(Float, %75)), + [nameHint("_s_dOut")] + param %x5Fsx5FdOut : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): + unconditionalBranch(%195) + +block %195: + let %196 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %197 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %198 : Ptr(Array(Float, 5 : Int)) = var + store(%198, %197) + store(%198, %196) + let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %200 : Ptr(Int) = var + store(%200, %199) + store(%200, 0 : Int) + let %201 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %202 : Float = GetPrimalUserCode(%201) + unconditionalBranch(%203) + +block %203: [loopMaxIters(4 : Int)] - loop(%5, %6, %5, true, %4, %3, 0 : Int) + loop(%204, %205, %204, true, %202, 0 : Int, 0 : Int) -block %5( +block %204( [primalInstDecoration] [nameHint("_bflag")] - param %x5Fbflag : Bool, + param %x5Fbflag4 : Bool, [primalInstDecoration] [nameHint("t")] - param %t : Float, - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft : Float, + param %t5 : Float, [primalInstDecoration] [nameHint("i")] - param %i : Int): - [mixedDiffInstDecoration()] - ifElse(%x5Fbflag, %7, %8, %7) + param %i5 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc1 : Int): + let %206 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %207 : Ptr(Array(Float, 5 : Int)) = var + store(%207, %206) + let %208 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%207, %x5Fpc1) + store(%208, %t5) + let %209 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %210 : Ptr(Int) = var + store(%210, %209) + store(%210, %x5Fpc1) + ifElse(%x5Fbflag4, %211, %212, %211) + +block %212: + unconditionalBranch(%205) + +block %205: + unconditionalBranch(%213) + +block %213: + unconditionalBranch(%214) + +block %214: + unconditionalBranch(%215) + +block %215: + unconditionalBranch(%216) + +block %216: + unconditionalBranch(%217) + +block %217: + let %218 : Float = call %floatx5Fdzero() + let %219 : Ptr(Float) = var + store(%219, %218) + let %220 : Float = call %floatx5Fdzero() + let %221 : Ptr(Float) = var + store(%221, %220) + let %222 : Float = load(%219) + let %223 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %222) + store(%219, %223) + unconditionalBranch(%224) + +block %224: + let %225 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %226 : Int = sub(%225, 1 : Int) + [loopMaxIters(4 : Int)] + loop(%227, %228, %229, %226) -block %8: - [mixedDiffInstDecoration()] - unconditionalBranch(%6) +block %227( + [primalInstDecoration] + [nameHint("_dc")] + param %x5Fdc : Int): + let %230 : Int = add(%x5Fdc, 0 : Int) + let %231 : Float = load(%219) + let %232 : Float = call %floatx5Fdzero() + store(%219, %232) + let %233 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%233, %234, %235, %234) + +block %235: + unconditionalBranch(%228, %231) + +block %228( + param %236 : Float): + let %237 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %238 : Float = GetPrimalUserCode(%237) + let %239 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%238, %236) + store(%dpy1, %239) + return_val(void_constant) + +block %234: + unconditionalBranch(%240) + +block %240: + [primalInstDecoration] + let %241 : Bool = cmpLT(%230, 3 : Int) + ifElse(%241, %242, %243, %244) -block %6: - [mixedDiffInstDecoration(DiffPair(Float, %1))] - let %9 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - [mixedDiffInstDecoration(DiffPair(Float, %1))] - return_val(%9) +block %243: + unconditionalBranch(%244, 0 : Int) -block %7: - [mixedDiffInstDecoration()] - unconditionalBranch(%10) +block %242: + unconditionalBranch(%244, 1 : Int) -block %10: +block %244( + [primalInstDecoration] + param %245 : Int): + unconditionalBranch(%246) + +block %246: [primalInstDecoration] - let %11 : Bool = cmpLT(%i, 3 : Int) - [mixedDiffInstDecoration()] - ifElse(%11, %12, %13, %14) + let %247 : Bool = cmpNE(%245, 1 : Int) + ifElse(%247, %248, %249, %250) -block %13: - [diffInstDecoration(Float)] - let %15 : Float = call %floatx5Fdzero() - [mixedDiffInstDecoration()] - unconditionalBranch(%14, 0 : Int, 0 : Float, %15) +block %249: + unconditionalBranch(%250, true) -block %12: +block %248: + unconditionalBranch(%250, false) + +block %250( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag5 : Bool): + unconditionalBranch(%251) + +block %251: + ifElse(%x5Fbflag5, %252, %253, %254) + +block %253: + unconditionalBranch(%254) + +block %252: + unconditionalBranch(%254) + +block %254: + unconditionalBranch(%255) + +block %255: + unconditionalBranch(%256, %231) + +block %256( + param %257 : Float): + ifElse(%x5Fbflag5, %258, %259, %260) + +block %259: + unconditionalBranch(%261, %257) + +block %261( + param %262 : Float): + let %263 : Float = load(%219) + let %264 : Float = call %floatx5Fdadd(%262, %263) + store(%219, %264) + unconditionalBranch(%260) + +block %258: + unconditionalBranch(%265, %257) + +block %265( + param %266 : Float): + let %267 : Float = load(%221) + let %268 : Float = call %floatx5Fdadd(%266, %267) + store(%221, %268) + unconditionalBranch(%260) + +block %260: + unconditionalBranch(%269) + +block %269: + ifElse(%247, %270, %271, %272) + +block %271: + unconditionalBranch(%272) + +block %270: + unconditionalBranch(%272) + +block %272: + unconditionalBranch(%273) + +block %273: + let %274 : Float = load(%221) + let %275 : Float = call %floatx5Fdzero() + store(%221, %275) + ifElse(%241, %276, %277, %278) + +block %277: + unconditionalBranch(%279) + +block %279: + unconditionalBranch(%278) + +block %276: + unconditionalBranch(%280, %274) + +block %280( + param %281 : Float): + let %282 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %283 : Ptr(Array(Float, 5 : Int)) = var + store(%283, %282) + let %284 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%283, %x5Fdc) + let %285 : Float = load(%284) + let %286 : Float = mul(%285, %281) + let %287 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %288 : Ptr(Array(Float, 5 : Int)) = var + store(%288, %287) + let %289 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%288, %x5Fdc) + let %290 : Float = load(%289) + let %291 : Float = mul(%290, %281) + let %292 : Float = load(%219) + let %293 : Float = call %floatx5Fdadd(%286, %291) + let %294 : Float = call %floatx5Fdadd(%293, %292) + store(%219, %294) + unconditionalBranch(%278) + +block %278: + unconditionalBranch(%229) + +block %229: [primalInstDecoration] - let %16 : Float = mul(%t, %t) - [diffInstDecoration(Float)] - let %17 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %18 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %19 : Float = add(%17, %18) - [mixedDiffInstDecoration()] - unconditionalBranch(%14, 1 : Int, %16, %19) + let %295 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%227, %295) -block %14( +block %211: + unconditionalBranch(%296) + +block %296: + [primalInstDecoration] + let %297 : Bool = cmpLT(%i5, 3 : Int) + ifElse(%297, %298, %299, %300) + +block %299: + unconditionalBranch(%300, 0 : Int, 0 : Float) + +block %298: + [primalInstDecoration] + let %301 : Float = mul(%t5, %t5) + unconditionalBranch(%300, 1 : Int, %301) + +block %300( [primalInstDecoration] - param %20 : Int, + param %302 : Int, [primalInstDecoration] - param %21 : Float, - [diffInstDecoration(Float)] - param %22 : Float): - [mixedDiffInstDecoration()] - unconditionalBranch(%23) + param %303 : Float): + unconditionalBranch(%304) -block %23: +block %304: [primalInstDecoration] - let %24 : Bool = cmpNE(%20, 1 : Int) - [mixedDiffInstDecoration()] - ifElse(%24, %25, %26, %27) + let %305 : Bool = cmpNE(%302, 1 : Int) + ifElse(%305, %306, %307, %308) -block %26: - [mixedDiffInstDecoration()] - unconditionalBranch(%27, %x5Fbflag) +block %307: + unconditionalBranch(%308, %x5Fbflag4) -block %25: - [mixedDiffInstDecoration()] - unconditionalBranch(%27, false) +block %306: + unconditionalBranch(%308, false) -block %27( +block %308( [primalInstDecoration] [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - [mixedDiffInstDecoration()] - unconditionalBranch(%28) + param %x5Fbflag6 : Bool): + unconditionalBranch(%309) -block %28: - [mixedDiffInstDecoration()] - ifElse(%x5Fbflag1, %29, %30, %31) +block %309: + ifElse(%x5Fbflag6, %310, %311, %312) -block %30: - [mixedDiffInstDecoration()] - unconditionalBranch(%31, %t, %sx5Fdiffx5Ft, %i) +block %311: + unconditionalBranch(%312, %t5, %i5) -block %29: +block %310: [primalInstDecoration] - let %32 : Int = add(%i, 1 : Int) - [mixedDiffInstDecoration()] - unconditionalBranch(%31, %21, %22, %32) + let %313 : Int = add(%i5, 1 : Int) + unconditionalBranch(%312, %303, %313) -block %31( +block %312( [primalInstDecoration] [nameHint("t")] - param %t1 : Float, - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft1 : Float, + param %t6 : Float, [primalInstDecoration] [nameHint("i")] - param %i1 : Int): - [mixedDiffInstDecoration()] - unconditionalBranch(%5, %x5Fbflag1, %t1, %sx5Fdiffx5Ft1, %i1) + param %i6 : Int): + [primalInstDecoration] + let %314 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%204, %x5Fbflag6, %t6, %i6, %314) +} +[backwardDifferentiable] +func %189 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) +{ +block %315( + param %316 : Array(Float, 5 : Int), + param %317 : Array(Float, 5 : Int)): + let %318 : Ptr(Array(Float, 5 : Int)) = var + loop(%319, %320, %319, 0 : Int) + +block %319( + param %321 : Int): + let %322 : Bool = cmpLT(%321, 5 : Int) + ifElse(%322, %323, %324, %324) + +block %323: + let %325 : Float = getElement(%316, %321) + let %326 : Float = getElement(%317, %321) + let %327 : Float = call %floatx5Fdadd(%325, %326) + let %328 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%318, %321) + store(%328, %327) + unconditionalBranch(%329) + +block %324: + unconditionalBranch(%320) + +block %320: + let %330 : Array(Float, 5 : Int) = load(%318) + return_val(%330) + +block %329: + let %331 : Int = add(%321, 1 : Int) + unconditionalBranch(%319, %331) +} +func %180 : Func(Array(Float, 5 : Int)) +{ +block %332: + let %333 : Float = call %floatx5Fdzero() + let %334 : Array(Float, 5 : Int) = makeArrayFromElement(%333) + return_val(%334) } +witness_table %193 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) +{ + witness_table_entry(%18,Array(Float, 5 : Int)) -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : DiffPair(Float, %1) = param + witness_table_entry(%20,%193) -inst with location: 1514954 (1) -[diffInstDecoration(Float)] -let %1 : Float = GetDifferential(%dpy) + witness_table_entry(%24,%189) -inst with location: 1514954 (1) -[primalInstDecoration] -let %1 : Float = GetPrimal(%dpy) + witness_table_entry(%22,%180) -inst with location: 1515008 (1) -[mixedDiffInstDecoration()] -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, %4, 0 : Int) +} -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +### +### AFTER-SPECIALIZE: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param + witness_table_entry(%20,%75) -inst with location: 1514994 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param + witness_table_entry(%22,%floatx5Fdzero) -inst with location: 1515017 (1) + witness_table_entry(%24,%floatx5Fdadd) + + witness_table_entry(%26,%69) + +} + +[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] +[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] +[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] [primalInstDecoration] -[nameHint("i")] -let %i : Int = param +[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%x5Fbflag, %1, %2, %1) +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) +block %78: + return_val(%t) -inst with location: 0 (0) -[mixedDiffInstDecoration(DiffPair(Float, %1))] -let %2 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) -inst with location: 1515077 (1) -[mixedDiffInstDecoration(DiffPair(Float, %1))] -return_val(%2) +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) +} +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %85( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) + let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %88 : DiffPairUserCode(Float, %75) = load(%dpa) + let %89 : Float = GetDifferentialUserCode(%88) + store(%87, %89) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %90) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) + let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %93 : Float = GetDifferentialUserCode(%92) + store(%91, %93) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %94: + let %95 : %NullDifferential = makeStruct(0 : UInt) + return_val(%95) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %96( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} +generic %98 : Generic +{ +block %99( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %101 : %98 +{ +block %102( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %104( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %105 : %NullDifferential = makeStruct(0 : UInt) + return_val(%105) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) -inst with location: 1515026 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) + witness_table_entry(%20,%106) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%1, %2, %3, %4) + witness_table_entry(%22,%NullDifferentialx5Fdzero) + + witness_table_entry(%24,%NullDifferentialx5Fdadd) + + witness_table_entry(%26,%101) + +} + +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_test_simple_loop")] +func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) +{ +block %107( + param %108 : InOut(DiffPairUserCode(Float, %75)), + param %109 : Float): + let %110 : DiffPairUserCode(Float, %75) = load(%108) + let %111 : Float = GetPrimalUserCode(%110) + let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) + let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) + return_val(void_constant) +} +[nameHint("s_primal_ctx_test_simple_loop")] +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) +{ +block %115( + [nameHint("dpy")] + param %dpy : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): + unconditionalBranch(%116) + +block %116: + let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct + store(%x5Fsx5Fdiffx5Fctx, %117) + let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) + let %120 : Ptr(Array(Float, 5 : Int)) = var + let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%120, %121) + let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%118, %122) + let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + let %125 : Ptr(Int) = var + store(%125, 0 : Int) + store(%123, 0 : Int) + unconditionalBranch(%126) + +block %126: + [loopMaxIters(4 : Int)] + loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = call %floatx5Fdzero() +block %127( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc : Int): + let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) + store(%129, %t1) + store(%123, %x5Fpc) + ifElse(%x5Fbflag, %130, %131, %130) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, 0 : Int, 0 : Float, %2) +block %131: + unconditionalBranch(%128) -inst with location: 1515058 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) +block %128: + return_val(%t1) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) +block %130: + unconditionalBranch(%132) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) +block %132: + [primalInstDecoration] + let %133 : Bool = cmpLT(%i1, 3 : Int) + ifElse(%133, %134, %135, %136) -inst with location: 1515058 (1) -[diffInstDecoration(Float)] -let %1 : Float = add(%2, %3) +block %135: + unconditionalBranch(%136, 0 : Int, 0 : Float) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, 1 : Int, %2, %3) +block %134: + [primalInstDecoration] + let %137 : Float = mul(%t1, %t1) + unconditionalBranch(%136, 1 : Int, %137) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param +block %136( + [primalInstDecoration] + param %138 : Int, + [primalInstDecoration] + param %139 : Float): + unconditionalBranch(%140) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param +block %140: + [primalInstDecoration] + let %141 : Bool = cmpNE(%138, 1 : Int) + ifElse(%141, %142, %143, %144) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = param +block %143: + unconditionalBranch(%144, %x5Fbflag) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) +block %142: + unconditionalBranch(%144, false) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) +block %144( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%145) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%1, %2, %3, %4) +block %145: + ifElse(%x5Fbflag1, %146, %147, %148) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag) +block %147: + unconditionalBranch(%148, %t1, %i1) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, false) +block %146: + [primalInstDecoration] + let %149 : Int = add(%i1, 1 : Int) + unconditionalBranch(%148, %139, %149) -inst with location: 0 (0) +block %148( + [primalInstDecoration] + [nameHint("t")] + param %t2 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i2 : Int): + [primalInstDecoration] + let %150 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) +} +[fwdDerivative(%151)] [primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%x5Fbflag, %1, %2, %3) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop1 : Func(Float, Float) +{ +block %152( + [nameHint("y")] + param %y1 : Float): + [loopMaxIters(4 : Int)] + loop(%153, %154, %153, true, %y1, 0 : Int) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) +block %153( + [nameHint("_bflag")] + param %x5Fbflag2 : Bool, + [nameHint("t")] + param %t3 : Float, + [nameHint("i")] + param %i3 : Int): + ifElse(%x5Fbflag2, %155, %156, %155) -inst with location: 1515032 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) +block %156: + unconditionalBranch(%154) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %2, %3, %4) +block %154: + return_val(%t3) -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %155: + unconditionalBranch(%157) -inst with location: 1514994 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param +block %157: + let %158 : Bool = cmpLT(%i3, 3 : Int) + ifElse(%158, %159, %160, %161) -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +block %160: + unconditionalBranch(%161, 0 : Int, 0 : Float) -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) +block %159: + let %162 : Float = mul(%t3, %t3) + unconditionalBranch(%161, 1 : Int, %162) -(diffPropagateFunc after unzipping)=============================== -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)); +block %161( + param %163 : Int, + param %164 : Float): + unconditionalBranch(%165) +block %165: + let %166 : Bool = cmpNE(%163, 1 : Int) + ifElse(%166, %167, %168, %169) -(unzipDiffInsts)=============================== -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : DiffPair(Float, %1) = param +block %168: + unconditionalBranch(%169, %x5Fbflag2) -inst with location: 0 (0) -let %1 : Float = PrimalParamRef(%dpy) +block %167: + unconditionalBranch(%169, false) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = DiffParamRef(%dpy) +block %169( + [nameHint("_bflag")] + param %x5Fbflag3 : Bool): + unconditionalBranch(%170) -inst with location: 0 (0) -unconditionalBranch(%1) +block %170: + ifElse(%x5Fbflag3, %171, %172, %173) -inst with location: 1515008 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, 0 : Int) +block %172: + unconditionalBranch(%173, %t3, %i3) -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +block %171: + let %174 : Int = add(%i3, 1 : Int) + unconditionalBranch(%173, %164, %174) -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %173( + [nameHint("t")] + param %t4 : Float, + [nameHint("i")] + param %i4 : Int): + unconditionalBranch(%153, %x5Fbflag3, %t4, %i4) +} +[derivativeMemberDecoration(%175)] +let %119 : _ = key +let %124 : _ = key +struct %176 : Type +{ + field(%175, Array(Float, 5 : Int)) +} -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +func %177 : Func(%176) +{ +block %178: + let %179 : Array(Float, 5 : Int) = call %180() + let %181 : %176 = makeStruct(%179) + return_val(%181) +} +func %182 : Func(%176) +{ +block %183( + param %184 : %176, + param %185 : %176): + let %186 : Array(Float, 5 : Int) = get_field(%184, %175) + let %187 : Array(Float, 5 : Int) = get_field(%185, %175) + let %188 : Array(Float, 5 : Int) = call %189(%186, %187) + let %190 : %176 = makeStruct(%188) + return_val(%190) +} +witness_table %191 : witness_table_t(%IDifferentiable)(%176) +{ + witness_table_entry(%18,%176) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) + witness_table_entry(%20,%191) -inst with location: 0 (0) -unconditionalBranch(%1) + witness_table_entry(%22,%177) -inst with location: 0 (0) -[BackwardDerivativePrimalReturnDecoration(%t)] -unconditionalBranch(%1) + witness_table_entry(%24,%182) -inst with location: 0 (0) -unconditionalBranch(%1) +} -inst with location: 1515026 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) +witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ + witness_table_entry(%18,%176) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) + witness_table_entry(%20,%191) -inst with location: 0 (0) -unconditionalBranch(%1, 0 : Int, 0 : Float) + witness_table_entry(%22,%177) -inst with location: 1515058 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) + witness_table_entry(%24,%182) -inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int, %2) +} -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param +[derivativeMemberDecoration(%175)] +let %175 : _ = key +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + [IntermediateContextFieldDifferentialTypeDecoration(%193)] + field(%119, Array(Float, 5 : Int)) + field(%124, Int) +} -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ +block %194( + [nameHint("dpy")] + param %dpy1 : InOut(DiffPairUserCode(Float, %75)), + [nameHint("_s_dOut")] + param %x5Fsx5FdOut : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): + unconditionalBranch(%195) + +block %195: + let %196 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %197 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %198 : Ptr(Array(Float, 5 : Int)) = var + store(%198, %197) + store(%198, %196) + let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %200 : Ptr(Int) = var + store(%200, %199) + store(%200, 0 : Int) + let %201 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %202 : Float = GetPrimalUserCode(%201) + unconditionalBranch(%203) + +block %203: + [loopMaxIters(4 : Int)] + loop(%204, %205, %204, true, %202, 0 : Int, 0 : Int) -inst with location: 0 (0) -unconditionalBranch(%1) +block %204( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag4 : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t5 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i5 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc1 : Int): + let %206 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %207 : Ptr(Array(Float, 5 : Int)) = var + store(%207, %206) + let %208 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%207, %x5Fpc1) + store(%208, %t5) + let %209 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %210 : Ptr(Int) = var + store(%210, %209) + store(%210, %x5Fpc1) + ifElse(%x5Fbflag4, %211, %212, %211) + +block %212: + unconditionalBranch(%205) + +block %205: + unconditionalBranch(%213) + +block %213: + unconditionalBranch(%214) + +block %214: + unconditionalBranch(%215) + +block %215: + unconditionalBranch(%216) + +block %216: + unconditionalBranch(%217) + +block %217: + let %218 : Float = call %floatx5Fdzero() + let %219 : Ptr(Float) = var + store(%219, %218) + let %220 : Float = call %floatx5Fdzero() + let %221 : Ptr(Float) = var + store(%221, %220) + let %222 : Float = load(%219) + let %223 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %222) + store(%219, %223) + unconditionalBranch(%224) + +block %224: + let %225 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %226 : Int = sub(%225, 1 : Int) + [loopMaxIters(4 : Int)] + loop(%227, %228, %229, %226) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) +block %227( + [primalInstDecoration] + [nameHint("_dc")] + param %x5Fdc : Int): + let %230 : Int = add(%x5Fdc, 0 : Int) + let %231 : Float = load(%219) + let %232 : Float = call %floatx5Fdzero() + store(%219, %232) + let %233 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%233, %234, %235, %234) + +block %235: + unconditionalBranch(%228, %231) + +block %228( + param %236 : Float): + let %237 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %238 : Float = GetPrimalUserCode(%237) + let %239 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%238, %236) + store(%dpy1, %239) + return_val(void_constant) + +block %234: + unconditionalBranch(%240) + +block %240: + [primalInstDecoration] + let %241 : Bool = cmpLT(%230, 3 : Int) + ifElse(%241, %242, %243, %244) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %243: + unconditionalBranch(%244, 0 : Int) -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag) +block %242: + unconditionalBranch(%244, 1 : Int) -inst with location: 0 (0) -unconditionalBranch(%1, false) +block %244( + [primalInstDecoration] + param %245 : Int): + unconditionalBranch(%246) -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +block %246: + [primalInstDecoration] + let %247 : Bool = cmpNE(%245, 1 : Int) + ifElse(%247, %248, %249, %250) -inst with location: 0 (0) -unconditionalBranch(%1) +block %249: + unconditionalBranch(%250, true) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) +block %248: + unconditionalBranch(%250, false) -inst with location: 0 (0) -unconditionalBranch(%1, %t, %i) +block %250( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag5 : Bool): + unconditionalBranch(%251) + +block %251: + ifElse(%x5Fbflag5, %252, %253, %254) + +block %253: + unconditionalBranch(%254) + +block %252: + unconditionalBranch(%254) + +block %254: + unconditionalBranch(%255) + +block %255: + unconditionalBranch(%256, %231) + +block %256( + param %257 : Float): + ifElse(%x5Fbflag5, %258, %259, %260) + +block %259: + unconditionalBranch(%261, %257) + +block %261( + param %262 : Float): + let %263 : Float = load(%219) + let %264 : Float = call %floatx5Fdadd(%262, %263) + store(%219, %264) + unconditionalBranch(%260) + +block %258: + unconditionalBranch(%265, %257) + +block %265( + param %266 : Float): + let %267 : Float = load(%221) + let %268 : Float = call %floatx5Fdadd(%266, %267) + store(%221, %268) + unconditionalBranch(%260) + +block %260: + unconditionalBranch(%269) + +block %269: + ifElse(%247, %270, %271, %272) + +block %271: + unconditionalBranch(%272) + +block %270: + unconditionalBranch(%272) + +block %272: + unconditionalBranch(%273) + +block %273: + let %274 : Float = load(%221) + let %275 : Float = call %floatx5Fdzero() + store(%221, %275) + ifElse(%241, %276, %277, %278) + +block %277: + unconditionalBranch(%279) + +block %279: + unconditionalBranch(%278) + +block %276: + unconditionalBranch(%280, %274) + +block %280( + param %281 : Float): + let %282 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %283 : Ptr(Array(Float, 5 : Int)) = var + store(%283, %282) + let %284 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%283, %x5Fdc) + let %285 : Float = load(%284) + let %286 : Float = mul(%285, %281) + let %287 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %288 : Ptr(Array(Float, 5 : Int)) = var + store(%288, %287) + let %289 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%288, %x5Fdc) + let %290 : Float = load(%289) + let %291 : Float = mul(%290, %281) + let %292 : Float = load(%219) + let %293 : Float = call %floatx5Fdadd(%286, %291) + let %294 : Float = call %floatx5Fdadd(%293, %292) + store(%219, %294) + unconditionalBranch(%278) + +block %278: + unconditionalBranch(%229) + +block %229: + [primalInstDecoration] + let %295 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%227, %295) -inst with location: 1515032 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) +block %211: + unconditionalBranch(%296) -inst with location: 0 (0) -unconditionalBranch(%1, %2, %3) +block %296: + [primalInstDecoration] + let %297 : Bool = cmpLT(%i5, 3 : Int) + ifElse(%297, %298, %299, %300) -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %299: + unconditionalBranch(%300, 0 : Int, 0 : Float) -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +block %298: + [primalInstDecoration] + let %301 : Float = mul(%t5, %t5) + unconditionalBranch(%300, 1 : Int, %301) -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag, %t, %i) +block %300( + [primalInstDecoration] + param %302 : Int, + [primalInstDecoration] + param %303 : Float): + unconditionalBranch(%304) -inst with location: 1515008 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, %3) +block %304: + [primalInstDecoration] + let %305 : Bool = cmpNE(%302, 1 : Int) + ifElse(%305, %306, %307, %308) -inst with location: 1514994 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param +block %307: + unconditionalBranch(%308, %x5Fbflag4) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) +block %306: + unconditionalBranch(%308, false) -inst with location: 0 (0) -unconditionalBranch(%1) +block %308( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag6 : Bool): + unconditionalBranch(%309) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) +block %309: + ifElse(%x5Fbflag6, %310, %311, %312) -inst with location: 0 (0) -[diffInstDecoration(Float)] -return_val(%1) +block %311: + unconditionalBranch(%312, %t5, %i5) -inst with location: 0 (0) -unconditionalBranch(%1) +block %310: + [primalInstDecoration] + let %313 : Int = add(%i5, 1 : Int) + unconditionalBranch(%312, %303, %313) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %312( + [primalInstDecoration] + [nameHint("t")] + param %t6 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i6 : Int): + [primalInstDecoration] + let %314 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%204, %x5Fbflag6, %t6, %i6, %314) +} +[backwardDifferentiable] +func %189 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) +{ +block %315( + param %316 : Array(Float, 5 : Int), + param %317 : Array(Float, 5 : Int)): + let %318 : Ptr(Array(Float, 5 : Int)) = var + loop(%319, %320, %319, 0 : Int) + +block %319( + param %321 : Int): + let %322 : Bool = cmpLT(%321, 5 : Int) + ifElse(%322, %323, %324, %324) + +block %323: + let %325 : Float = getElement(%316, %321) + let %326 : Float = getElement(%317, %321) + let %327 : Float = call %floatx5Fdadd(%325, %326) + let %328 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%318, %321) + store(%328, %327) + unconditionalBranch(%329) + +block %324: + unconditionalBranch(%320) + +block %320: + let %330 : Array(Float, 5 : Int) = load(%318) + return_val(%330) + +block %329: + let %331 : Int = add(%321, 1 : Int) + unconditionalBranch(%319, %331) +} +func %180 : Func(Array(Float, 5 : Int)) +{ +block %332: + let %333 : Float = call %floatx5Fdzero() + let %334 : Array(Float, 5 : Int) = makeArrayFromElement(%333) + return_val(%334) +} +witness_table %193 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) +{ + witness_table_entry(%18,Array(Float, 5 : Int)) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = call %floatx5Fdzero() + witness_table_entry(%20,%193) -inst with location: 0 (0) -unconditionalBranch(%1, %2) + witness_table_entry(%24,%189) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) + witness_table_entry(%22,%180) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) +} -inst with location: 1515058 (1) -[diffInstDecoration(Float)] -let %1 : Float = add(%2, %3) +GenericSpecializationDictionary +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +### +### BEFORE-AUTODIFF: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) -inst with location: 0 (0) -unconditionalBranch(%1, %2) + witness_table_entry(%20,%75) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = param + witness_table_entry(%22,%floatx5Fdzero) -inst with location: 0 (0) -unconditionalBranch(%1) + witness_table_entry(%24,%floatx5Fdadd) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) + witness_table_entry(%26,%69) -inst with location: 0 (0) -unconditionalBranch(%1) +} -inst with location: 0 (0) -unconditionalBranch(%1) +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %76 : witness_table_t(%IBufferDataLayout)(DefaultLayout); -inst with location: 0 (0) -unconditionalBranch(%1) +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %76) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %77( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %78 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %78) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) + let %79 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %80 : DiffPairUserCode(Float, %75) = load(%dpa) + let %81 : Float = GetDifferentialUserCode(%80) + store(%79, %81) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %82 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %82) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) + let %83 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %84 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %85 : Float = GetDifferentialUserCode(%84) + store(%83, %85) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %86: + let %87 : %NullDifferential = makeStruct(0 : UInt) + return_val(%87) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %88( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %89 : %NullDifferential = makeStruct(0 : UInt) + return_val(%89) +} +generic %90 : Generic +{ +block %91( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %92 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %93 : %90 +{ +block %94( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %95 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %96( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %98 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) + witness_table_entry(%20,%98) -inst with location: 0 (0) -unconditionalBranch(%1, %2) + witness_table_entry(%22,%NullDifferentialx5Fdzero) -inst with location: 1514994 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param + witness_table_entry(%24,%NullDifferentialx5Fdadd) -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) + witness_table_entry(%26,%93) -(diffPropagateFunc moving blocks)=============================== +} + +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary [FloatingPointModeOverride(1 : Int)] [DifferentiableTypeDictionaryDecoration] [backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)) +[nameHint("s_bwd_test_simple_loop")] +func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) { -block %2( +block %99( + param %100 : InOut(DiffPairUserCode(Float, %75)), + param %101 : Float): + let %102 : DiffPairUserCode(Float, %75) = load(%100) + let %103 : Float = GetPrimalUserCode(%102) + let %104 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %105 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%103, %104) + let %106 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%104) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%100, %101, %106) + return_val(void_constant) +} +[nameHint("s_primal_ctx_test_simple_loop")] +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) +{ +block %107( [nameHint("dpy")] - param %dpy : DiffPair(Float, %1)): - let %3 : Float = PrimalParamRef(%dpy) - [diffInstDecoration(Float)] - let %4 : Float = DiffParamRef(%dpy) - unconditionalBranch(%5) - -block %5: + param %dpy : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): + unconditionalBranch(%108) + +block %108: + let %109 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct + store(%x5Fsx5Fdiffx5Fctx, %109) + let %110 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %111) + let %112 : Ptr(Array(Float, 5 : Int)) = var + let %113 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%112, %113) + let %114 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%110, %114) + let %115 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %116) + let %117 : Ptr(Int) = var + store(%117, 0 : Int) + store(%115, 0 : Int) + unconditionalBranch(%118) + +block %118: [loopMaxIters(4 : Int)] - loop(%6, %7, %6, true, %3, 0 : Int) + loop(%119, %120, %119, true, %dpy, 0 : Int, 0 : Int) -block %6( +block %119( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag : Bool, @@ -595,846 +7152,2159 @@ block %6( param %t : Float, [primalInstDecoration] [nameHint("i")] - param %i : Int): - ifElse(%x5Fbflag, %8, %9, %8) + param %i : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc : Int): + let %121 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%110, %x5Fpc) + store(%121, %t) + store(%115, %x5Fpc) + ifElse(%x5Fbflag, %122, %123, %122) -block %9: - unconditionalBranch(%7) +block %123: + unconditionalBranch(%120) -block %7: - [BackwardDerivativePrimalReturnDecoration(%t)] - unconditionalBranch(%10) +block %120: + return_val(%t) -block %8: - unconditionalBranch(%11) +block %122: + unconditionalBranch(%124) -block %11: +block %124: [primalInstDecoration] - let %12 : Bool = cmpLT(%i, 3 : Int) - ifElse(%12, %13, %14, %15) + let %125 : Bool = cmpLT(%i, 3 : Int) + ifElse(%125, %126, %127, %128) -block %14: - unconditionalBranch(%15, 0 : Int, 0 : Float) +block %127: + unconditionalBranch(%128, 0 : Int, 0 : Float) -block %13: +block %126: [primalInstDecoration] - let %16 : Float = mul(%t, %t) - unconditionalBranch(%15, 1 : Int, %16) + let %129 : Float = mul(%t, %t) + unconditionalBranch(%128, 1 : Int, %129) -block %15( +block %128( [primalInstDecoration] - param %17 : Int, + param %130 : Int, [primalInstDecoration] - param %18 : Float): - unconditionalBranch(%19) + param %131 : Float): + unconditionalBranch(%132) -block %19: +block %132: [primalInstDecoration] - let %20 : Bool = cmpNE(%17, 1 : Int) - ifElse(%20, %21, %22, %23) + let %133 : Bool = cmpNE(%130, 1 : Int) + ifElse(%133, %134, %135, %136) -block %22: - unconditionalBranch(%23, %x5Fbflag) +block %135: + unconditionalBranch(%136, %x5Fbflag) -block %21: - unconditionalBranch(%23, false) +block %134: + unconditionalBranch(%136, false) -block %23( +block %136( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag1 : Bool): - unconditionalBranch(%24) + unconditionalBranch(%137) -block %24: - ifElse(%x5Fbflag1, %25, %26, %27) +block %137: + ifElse(%x5Fbflag1, %138, %139, %140) -block %26: - unconditionalBranch(%27, %t, %i) +block %139: + unconditionalBranch(%140, %t, %i) -block %25: +block %138: [primalInstDecoration] - let %28 : Int = add(%i, 1 : Int) - unconditionalBranch(%27, %18, %28) + let %141 : Int = add(%i, 1 : Int) + unconditionalBranch(%140, %131, %141) -block %27( +block %140( [primalInstDecoration] [nameHint("t")] param %t1 : Float, [primalInstDecoration] [nameHint("i")] param %i1 : Int): - unconditionalBranch(%6, %x5Fbflag1, %t1, %i1) - -block %10: - [loopMaxIters(4 : Int)] - loop(%29, %30, %29, %4) - -block %29( - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft : Float): - ifElse(%x5Fbflag, %31, %32, %31) - -block %32: - unconditionalBranch(%30) - -block %30: - [diffInstDecoration(Float)] - let %33 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - [diffInstDecoration(Float)] - return_val(%33) - -block %31: - unconditionalBranch(%34) - -block %34: - ifElse(%12, %35, %36, %37) + [primalInstDecoration] + let %142 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%119, %x5Fbflag1, %t1, %i1, %142) +} +[derivativeMemberDecoration(%143)] +let %111 : _ = key +let %116 : _ = key +struct %144 : Type +{ + field(%143, Array(Float, 5 : Int)) +} -block %36: - [diffInstDecoration(Float)] - let %38 : Float = call %floatx5Fdzero() - unconditionalBranch(%37, %38) +func %145 : Func(%144) +{ +block %146: + let %147 : Array(Float, 5 : Int) = call %148() + let %149 : %144 = makeStruct(%147) + return_val(%149) +} +func %150 : Func(%144) +{ +block %151( + param %152 : %144, + param %153 : %144): + let %154 : Array(Float, 5 : Int) = get_field(%152, %143) + let %155 : Array(Float, 5 : Int) = get_field(%153, %143) + let %156 : Array(Float, 5 : Int) = call %157(%154, %155) + let %158 : %144 = makeStruct(%156) + return_val(%158) +} +witness_table %159 : witness_table_t(%IDifferentiable)(%144) +{ + witness_table_entry(%18,%144) -block %35: - [diffInstDecoration(Float)] - let %39 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %40 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %41 : Float = add(%39, %40) - unconditionalBranch(%37, %41) + witness_table_entry(%20,%159) -block %37( - [diffInstDecoration(Float)] - param %42 : Float): - unconditionalBranch(%43) + witness_table_entry(%22,%145) -block %43: - ifElse(%20, %44, %45, %46) + witness_table_entry(%24,%150) -block %45: - unconditionalBranch(%46) +} -block %44: - unconditionalBranch(%46) +witness_table %160 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ + witness_table_entry(%18,%144) -block %46: - unconditionalBranch(%47) + witness_table_entry(%20,%159) -block %47: - ifElse(%x5Fbflag1, %48, %49, %50) + witness_table_entry(%22,%145) -block %49: - unconditionalBranch(%50, %sx5Fdiffx5Ft) + witness_table_entry(%24,%150) -block %48: - unconditionalBranch(%50, %42) +} -block %50( - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft1 : Float): - unconditionalBranch(%29, %sx5Fdiffx5Ft1) +[derivativeMemberDecoration(%143)] +let %143 : _ = key +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + [IntermediateContextFieldDifferentialTypeDecoration(%161)] + field(%111, Array(Float, 5 : Int)) + field(%116, Int) } -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : DiffPair(Float, %1) = param +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ +block %162( + [nameHint("dpy")] + param %dpy1 : InOut(DiffPairUserCode(Float, %75)), + [nameHint("_s_dOut")] + param %x5Fsx5FdOut : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): + unconditionalBranch(%163) + +block %163: + let %164 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %165 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %166 : Ptr(Array(Float, 5 : Int)) = var + store(%166, %165) + store(%166, %164) + let %167 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) + let %168 : Ptr(Int) = var + store(%168, %167) + store(%168, 0 : Int) + let %169 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %170 : Float = GetPrimalUserCode(%169) + unconditionalBranch(%171) + +block %171: + [loopMaxIters(4 : Int)] + loop(%172, %173, %172, true, %170, 0 : Int, 0 : Int) + +block %172( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag2 : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t2 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i2 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc1 : Int): + let %174 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %175 : Ptr(Array(Float, 5 : Int)) = var + store(%175, %174) + let %176 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%175, %x5Fpc1) + store(%176, %t2) + let %177 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) + let %178 : Ptr(Int) = var + store(%178, %177) + store(%178, %x5Fpc1) + ifElse(%x5Fbflag2, %179, %180, %179) + +block %180: + unconditionalBranch(%173) + +block %173: + unconditionalBranch(%181) + +block %181: + unconditionalBranch(%182) + +block %182: + unconditionalBranch(%183) + +block %183: + unconditionalBranch(%184) + +block %184: + unconditionalBranch(%185) + +block %185: + let %186 : Ptr(Float) = var + store(%186, 0 : Float) + let %187 : Ptr(Float) = var + store(%187, 0 : Float) + let %188 : Float = load(%186) + let %189 : Float = add(%x5Fsx5FdOut, %188) + store(%186, %189) + unconditionalBranch(%190) + +block %190: + let %191 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) + let %192 : Int = sub(%191, 1 : Int) + [loopMaxIters(4 : Int)] + loop(%193, %194, %195, %192) -inst with location: 0 (0) -let %1 : Float = PrimalParamRef(%dpy) +block %193( + [primalInstDecoration] + [nameHint("_dc")] + param %x5Fdc : Int): + let %196 : Int = add(%x5Fdc, 0 : Int) + let %197 : Float = load(%186) + store(%186, 0 : Float) + let %198 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%198, %199, %200, %199) + +block %200: + unconditionalBranch(%194, %197) + +block %194( + param %201 : Float): + let %202 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %203 : Float = GetPrimalUserCode(%202) + let %204 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%203, %201) + store(%dpy1, %204) + return_val(void_constant) + +block %199: + unconditionalBranch(%205) + +block %205: + [primalInstDecoration] + let %206 : Bool = cmpLT(%196, 3 : Int) + ifElse(%206, %207, %208, %209) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = DiffParamRef(%dpy) +block %208: + unconditionalBranch(%209, 0 : Int) -inst with location: 0 (0) -unconditionalBranch(%1) +block %207: + unconditionalBranch(%209, 1 : Int) -inst with location: 1515008 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, 0 : Int) +block %209( + [primalInstDecoration] + param %210 : Int): + unconditionalBranch(%211) -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +block %211: + [primalInstDecoration] + let %212 : Bool = cmpNE(%210, 1 : Int) + ifElse(%212, %213, %214, %215) -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %214: + unconditionalBranch(%215, true) -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +block %213: + unconditionalBranch(%215, false) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) +block %215( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag3 : Bool): + unconditionalBranch(%216) + +block %216: + ifElse(%x5Fbflag3, %217, %218, %219) + +block %218: + unconditionalBranch(%219) + +block %217: + unconditionalBranch(%219) + +block %219: + unconditionalBranch(%220) + +block %220: + unconditionalBranch(%221, %197) + +block %221( + param %222 : Float): + ifElse(%x5Fbflag3, %223, %224, %225) + +block %224: + unconditionalBranch(%226, %222) + +block %226( + param %227 : Float): + let %228 : Float = load(%186) + let %229 : Float = add(%227, %228) + store(%186, %229) + unconditionalBranch(%225) + +block %223: + unconditionalBranch(%230, %222) + +block %230( + param %231 : Float): + let %232 : Float = load(%187) + let %233 : Float = add(%231, %232) + store(%187, %233) + unconditionalBranch(%225) + +block %225: + unconditionalBranch(%234) + +block %234: + ifElse(%212, %235, %236, %237) + +block %236: + unconditionalBranch(%237) + +block %235: + unconditionalBranch(%237) + +block %237: + unconditionalBranch(%238) + +block %238: + let %239 : Float = load(%187) + store(%187, 0 : Float) + ifElse(%206, %240, %241, %242) + +block %241: + unconditionalBranch(%243) + +block %243: + unconditionalBranch(%242) + +block %240: + unconditionalBranch(%244, %239) + +block %244( + param %245 : Float): + let %246 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %247 : Ptr(Array(Float, 5 : Int)) = var + store(%247, %246) + let %248 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%247, %x5Fdc) + let %249 : Float = load(%248) + let %250 : Float = mul(%249, %245) + let %251 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %252 : Ptr(Array(Float, 5 : Int)) = var + store(%252, %251) + let %253 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%252, %x5Fdc) + let %254 : Float = load(%253) + let %255 : Float = mul(%254, %245) + let %256 : Float = load(%186) + let %257 : Float = add(%250, %255) + let %258 : Float = add(%257, %256) + store(%186, %258) + unconditionalBranch(%242) + +block %242: + unconditionalBranch(%195) + +block %195: + [primalInstDecoration] + let %259 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%193, %259) -inst with location: 0 (0) -unconditionalBranch(%1) +block %179: + unconditionalBranch(%260) -inst with location: 0 (0) -[BackwardDerivativePrimalReturnDecoration(%t)] -unconditionalBranch(%1) +block %260: + [primalInstDecoration] + let %261 : Bool = cmpLT(%i2, 3 : Int) + ifElse(%261, %262, %263, %264) -inst with location: 0 (0) -unconditionalBranch(%1) +block %263: + unconditionalBranch(%264, 0 : Int, 0 : Float) -inst with location: 1515026 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) +block %262: + [primalInstDecoration] + let %265 : Float = mul(%t2, %t2) + unconditionalBranch(%264, 1 : Int, %265) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %264( + [primalInstDecoration] + param %266 : Int, + [primalInstDecoration] + param %267 : Float): + unconditionalBranch(%268) -inst with location: 0 (0) -unconditionalBranch(%1, 0 : Int, 0 : Float) +block %268: + [primalInstDecoration] + let %269 : Bool = cmpNE(%266, 1 : Int) + ifElse(%269, %270, %271, %272) -inst with location: 1515058 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) +block %271: + unconditionalBranch(%272, %x5Fbflag2) -inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int, %2) +block %270: + unconditionalBranch(%272, false) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param +block %272( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag4 : Bool): + unconditionalBranch(%273) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param +block %273: + ifElse(%x5Fbflag4, %274, %275, %276) -inst with location: 0 (0) -unconditionalBranch(%1) +block %275: + unconditionalBranch(%276, %t2, %i2) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) +block %274: + [primalInstDecoration] + let %277 : Int = add(%i2, 1 : Int) + unconditionalBranch(%276, %267, %277) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %276( + [primalInstDecoration] + [nameHint("t")] + param %t3 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i3 : Int): + [primalInstDecoration] + let %278 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%172, %x5Fbflag4, %t3, %i3, %278) +} +[backwardDifferentiable] +func %157 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) +{ +block %279( + param %280 : Array(Float, 5 : Int), + param %281 : Array(Float, 5 : Int)): + let %282 : Ptr(Array(Float, 5 : Int)) = var + loop(%283, %284, %283, 0 : Int) + +block %283( + param %285 : Int): + let %286 : Bool = cmpLT(%285, 5 : Int) + ifElse(%286, %287, %288, %288) + +block %287: + let %289 : Float = getElement(%280, %285) + let %290 : Float = getElement(%281, %285) + let %291 : Float = add(%289, %290) + let %292 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%282, %285) + store(%292, %291) + unconditionalBranch(%293) + +block %288: + unconditionalBranch(%284) + +block %284: + let %294 : Array(Float, 5 : Int) = load(%282) + return_val(%294) + +block %293: + let %295 : Int = add(%285, 1 : Int) + unconditionalBranch(%283, %295) +} +func %148 : Func(Array(Float, 5 : Int)) +{ +block %296: + let %297 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) + return_val(%297) +} +witness_table %161 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) +{ + witness_table_entry(%18,Array(Float, 5 : Int)) -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag) + witness_table_entry(%20,%161) -inst with location: 0 (0) -unconditionalBranch(%1, false) + witness_table_entry(%24,%157) -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param + witness_table_entry(%22,%148) -inst with location: 0 (0) -unconditionalBranch(%1) +} -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) +GenericSpecializationDictionary +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +### +### AFTER-AUTODIFF: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Void = no_diff +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[export("_ST4core15IDifferentiable12Differential")] +let %18 : _ = key +let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) +[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] +let %20 : _ = key +let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] +let %22 : _ = key +let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %24 : _ = key +let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +[StaticRequirementDecoration] +[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] +let %26 : _ = key +[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] +let %27 : _ = key +[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] +let %28 : _ = key +[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] +let %29 : _ = key +[BuiltinDecoration] +[export("_ST4core13__BuiltinType")] +[nameHint("__BuiltinType")] +let %x5Fx5FBuiltinType : Type = interface +let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) +[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] +let %31 : _ = key +[export("_S4core11IArithmeticI4core11IComparable")] +let %32 : _ = key +[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] +let %33 : _ = key +let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] +let %35 : _ = key +let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] +let %37 : _ = key +let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +[export("_ST4core11IComparable")] +[nameHint("IComparable")] +let %IComparable : Type = interface(%34, %36, %38) +let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) +[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %40 : _ = key +let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %42 : _ = key +let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %44 : _ = key +let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %46 : _ = key +let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] +let %48 : _ = key +let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] +let %50 : _ = key +let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_S4core11IArithmeticR8_24xinitp1pi_i")] +let %52 : _ = key +let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) +[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] +let %54 : _ = key +let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +[export("_ST4core11IArithmetic")] +[nameHint("IArithmetic")] +let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) +let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) +[BuiltinDecoration] +[export("_ST4core23__BuiltinArithmeticType")] +[nameHint("__BuiltinArithmeticType")] +let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) +let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +[BuiltinDecoration] +[export("_ST4core29__BuiltinSignedArithmeticType")] +[nameHint("__BuiltinSignedArithmeticType")] +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) +let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +[BuiltinDecoration] +[export("_ST4core17__BuiltinRealType")] +[nameHint("__BuiltinRealType")] +let %x5Fx5FBuiltinRealType : Type = interface(%58) +generic %59 : Generic +{ +block %60( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("IDifferentiable.T")] + param %IDifferentiablex5FT : type_t, + param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) +} +let %62 : _ = interface_req_entry(%26, %59) +[export("_ST4core15IDifferentiable")] +[nameHint("IDifferentiable")] +let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float5dzerop0pfb")] +[nameHint("float.dzero")] +func %floatx5Fdzero : Func(Float) +{ +block %63: + return_val(0 : Float) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[unsafeForceInlineEarly] +[method] +[export("_S4core5float4daddp2pi_fi_ffb")] +[nameHint("float.dadd")] +func %floatx5Fdadd : Func(Float, Float, Float) +{ +block %64( + [nameHint("a")] + param %a : Float, + [nameHint("b")] + param %b : Float): + let %65 : Float = add(%a, %b) + return_val(%65) +} +generic %66 : Generic +{ +block %67( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU : type_t, + param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) +} +[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] +generic %69 : %66 +{ +block %70( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("float.U")] + param %floatx5FU1 : type_t, + param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [backwardDifferentiable] + [unsafeForceInlineEarly] + [nameHint("float.dmul")] + func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) + { +block %72( + [nameHint("a")] + param %a1 : Attributed(%floatx5FU1, %7), + [nameHint("b")] + param %b1 : Float): + let %73 : Float = floatCast(%a1) + let %74 : Float = mul(%73, %b1) + return_val(%74) +} + return_val(%floatx5Fdmul) +} +[export("_SWf4core15IDifferentiable")] +witness_table %75 : witness_table_t(%IDifferentiable)(Float) +{ + witness_table_entry(%18,Float) -inst with location: 0 (0) -unconditionalBranch(%1, %t, %i) + witness_table_entry(%20,%75) -inst with location: 1515032 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) + witness_table_entry(%22,%floatx5Fdzero) -inst with location: 0 (0) -unconditionalBranch(%1, %2, %3) + witness_table_entry(%24,%floatx5Fdadd) -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param + witness_table_entry(%26,%69) -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +} -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag, %t, %i) +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %76 : witness_table_t(%IBufferDataLayout)(DefaultLayout); -inst with location: 1515008 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, %3) +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %76) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %77( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var + let %78 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %78) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) + let %79 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %80 : DiffPairUserCode(Float, %75) = load(%dpa) + let %81 : Float = GetDifferentialUserCode(%80) + store(%79, %81) + [nameHint("dpa")] + let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var + let %82 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %82) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) + let %83 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %84 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %85 : Float = GetDifferentialUserCode(%84) + store(%83, %85) + return_val(void_constant) +} +[export("_SV16NullDifferential5dummy")] +[nameHint("dummy")] +let %dummy : _ = key +[AutoDiffBuiltinDecoration] +[keepAlive] +[hlslExport] +[export("_ST16NullDifferential")] +[nameHint("NullDifferential")] +struct %NullDifferential : Type +{ + field(%dummy, UInt) +} -inst with location: 1514994 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] +[nameHint("NullDifferential.dzero")] +func %NullDifferentialx5Fdzero : Func(%NullDifferential) +{ +block %86: + let %87 : %NullDifferential = makeStruct(0 : UInt) + return_val(%87) +} +[readNone] +[DifferentiableTypeDictionaryDecoration] +[ForceInline] +[backwardDifferentiable] +[method] +[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] +[nameHint("NullDifferential.dadd")] +func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) +{ +block %88( + [nameHint("SLANG_anonymous_8")] + param %SLANGx5Fanonymousx5F8_ : %NullDifferential, + [nameHint("SLANG_anonymous_9")] + param %SLANGx5Fanonymousx5F9_ : %NullDifferential): + let %89 : %NullDifferential = makeStruct(0 : UInt) + return_val(%89) +} +generic %90 : Generic +{ +block %91( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT : type_t, + param %92 : witness_table_t(%x5Fx5FBuiltinRealType)): + return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) +} +[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] +generic %93 : %90 +{ +block %94( + [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] + [nameHint("NullDifferential.T")] + param %NullDifferentialx5FT1 : type_t, + param %95 : witness_table_t(%x5Fx5FBuiltinRealType)): + [readNone] + [DifferentiableTypeDictionaryDecoration] + [ForceInline] + [backwardDifferentiable] + [nameHint("NullDifferential.dmul")] + func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) + { +block %96( + [nameHint("SLANG_anonymous_10")] + param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), + [nameHint("SLANG_anonymous_11")] + param %SLANGx5Fanonymousx5F11_ : %NullDifferential): + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) +} + return_val(%NullDifferentialx5Fdmul) +} +[keepAlive] +[hlslExport] +[export("_SW16NullDifferential4core15IDifferentiable")] +witness_table %98 : witness_table_t(%IDifferentiable)(%NullDifferential) +{ + witness_table_entry(%18,%NullDifferential) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) + witness_table_entry(%20,%98) -inst with location: 0 (0) -unconditionalBranch(%1) + witness_table_entry(%22,%NullDifferentialx5Fdzero) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) + witness_table_entry(%24,%NullDifferentialx5Fdadd) -inst with location: 0 (0) -[diffInstDecoration(Float)] -return_val(%1) + witness_table_entry(%26,%93) -inst with location: 0 (0) -unconditionalBranch(%1) +} -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_test_simple_loop")] +func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) +{ +block %99( + param %100 : InOut(DiffPairUserCode(Float, %75)), + param %101 : Float): + let %102 : DiffPairUserCode(Float, %75) = load(%100) + let %103 : Float = GetPrimalUserCode(%102) + let %104 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %105 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%103, %104) + let %106 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%104) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%100, %101, %106) + return_val(void_constant) +} +[nameHint("s_primal_ctx_test_simple_loop")] +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) +{ +block %107( + [nameHint("dpy")] + param %dpy : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): + unconditionalBranch(%108) + +block %108: + let %109 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct + store(%x5Fsx5Fdiffx5Fctx, %109) + let %110 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %111) + let %112 : Ptr(Array(Float, 5 : Int)) = var + let %113 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%112, %113) + let %114 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%110, %114) + let %115 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %116) + let %117 : Ptr(Int) = var + store(%117, 0 : Int) + store(%115, 0 : Int) + unconditionalBranch(%118) + +block %118: + [loopMaxIters(4 : Int)] + loop(%119, %120, %119, true, %dpy, 0 : Int, 0 : Int) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = call %floatx5Fdzero() +block %119( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t : Float, + [primalInstDecoration] + [nameHint("i")] + param %i : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc : Int): + let %121 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%110, %x5Fpc) + store(%121, %t) + store(%115, %x5Fpc) + ifElse(%x5Fbflag, %122, %123, %122) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %123: + unconditionalBranch(%120) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) +block %120: + return_val(%t) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) +block %122: + unconditionalBranch(%124) -inst with location: 1515058 (1) -[diffInstDecoration(Float)] -let %1 : Float = add(%2, %3) +block %124: + [primalInstDecoration] + let %125 : Bool = cmpLT(%i, 3 : Int) + ifElse(%125, %126, %127, %128) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %127: + unconditionalBranch(%128, 0 : Int, 0 : Float) -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = param +block %126: + [primalInstDecoration] + let %129 : Float = mul(%t, %t) + unconditionalBranch(%128, 1 : Int, %129) -inst with location: 0 (0) -unconditionalBranch(%1) +block %128( + [primalInstDecoration] + param %130 : Int, + [primalInstDecoration] + param %131 : Float): + unconditionalBranch(%132) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %132: + [primalInstDecoration] + let %133 : Bool = cmpNE(%130, 1 : Int) + ifElse(%133, %134, %135, %136) -inst with location: 0 (0) -unconditionalBranch(%1) +block %135: + unconditionalBranch(%136, %x5Fbflag) -inst with location: 0 (0) -unconditionalBranch(%1) +block %134: + unconditionalBranch(%136, false) -inst with location: 0 (0) -unconditionalBranch(%1) +block %136( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%137) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) +block %137: + ifElse(%x5Fbflag1, %138, %139, %140) -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) +block %139: + unconditionalBranch(%140, %t, %i) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %138: + [primalInstDecoration] + let %141 : Int = add(%i, 1 : Int) + unconditionalBranch(%140, %131, %141) -inst with location: 1514994 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param +block %140( + [primalInstDecoration] + [nameHint("t")] + param %t1 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i1 : Int): + [primalInstDecoration] + let %142 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%119, %x5Fbflag1, %t1, %i1, %142) +} +[derivativeMemberDecoration(%143)] +let %111 : _ = key +let %116 : _ = key +struct %144 : Type +{ + field(%143, Array(Float, 5 : Int)) +} -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) +func %145 : Func(%144) +{ +block %146: + let %147 : Array(Float, 5 : Int) = call %148() + let %149 : %144 = makeStruct(%147) + return_val(%149) +} +func %150 : Func(%144) +{ +block %151( + param %152 : %144, + param %153 : %144): + let %154 : Array(Float, 5 : Int) = get_field(%152, %143) + let %155 : Array(Float, 5 : Int) = get_field(%153, %143) + let %156 : Array(Float, 5 : Int) = call %157(%154, %155) + let %158 : %144 = makeStruct(%156) + return_val(%158) +} +witness_table %159 : witness_table_t(%IDifferentiable)(%144) +{ + witness_table_entry(%18,%144) -(applyCheckpointPolicy) =============================== -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : Float = param + witness_table_entry(%20,%159) -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : InOut(DiffPair(Float, %1)) = param + witness_table_entry(%22,%145) -inst with location: 0 (0) -[nameHint("_s_dOut")] -let %x5Fsx5FdOut : Float = param + witness_table_entry(%24,%150) -inst with location: 0 (0) -[nameHint("_s_diff_ctx")] -let %x5Fsx5Fdiffx5Fctx : BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop) = param +} -inst with location: 0 (0) -unconditionalBranch(%1) +witness_table %160 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ + witness_table_entry(%18,%144) -inst with location: 0 (0) -let %1 : DiffPair(Float, %2) = load(%dpy) + witness_table_entry(%20,%159) -inst with location: 0 (0) -[keepAlive] -let %1 : Float = GetPrimal(%2) + witness_table_entry(%22,%145) -inst with location: 0 (0) -unconditionalBranch(%1) + witness_table_entry(%24,%150) -inst with location: 1515008 (1) -[loopMaxIters(4 : Int)] -let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) +} -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +[derivativeMemberDecoration(%143)] +let %143 : _ = key +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + [IntermediateContextFieldDifferentialTypeDecoration(%161)] + field(%111, Array(Float, 5 : Int)) + field(%116, Int) +} -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +[FloatingPointModeOverride(1 : Int)] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ +block %162( + [nameHint("dpy")] + param %dpy1 : InOut(DiffPairUserCode(Float, %75)), + [nameHint("_s_dOut")] + param %x5Fsx5FdOut : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): + unconditionalBranch(%163) + +block %163: + let %164 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %165 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %166 : Ptr(Array(Float, 5 : Int)) = var + store(%166, %165) + store(%166, %164) + let %167 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) + let %168 : Ptr(Int) = var + store(%168, %167) + store(%168, 0 : Int) + let %169 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %170 : Float = GetPrimalUserCode(%169) + unconditionalBranch(%171) + +block %171: + [loopMaxIters(4 : Int)] + loop(%172, %173, %172, true, %170, 0 : Int, 0 : Int) -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +block %172( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag2 : Bool, + [primalInstDecoration] + [nameHint("t")] + param %t2 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i2 : Int, + [primalInstDecoration] + [nameHint("_pc")] + [loopCounterDecoration] + param %x5Fpc1 : Int): + let %174 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %175 : Ptr(Array(Float, 5 : Int)) = var + store(%175, %174) + let %176 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%175, %x5Fpc1) + store(%176, %t2) + let %177 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) + let %178 : Ptr(Int) = var + store(%178, %177) + store(%178, %x5Fpc1) + ifElse(%x5Fbflag2, %179, %180, %179) + +block %180: + unconditionalBranch(%173) + +block %173: + unconditionalBranch(%181) + +block %181: + unconditionalBranch(%182) + +block %182: + unconditionalBranch(%183) + +block %183: + unconditionalBranch(%184) + +block %184: + unconditionalBranch(%185) + +block %185: + let %186 : Ptr(Float) = var + store(%186, 0 : Float) + let %187 : Ptr(Float) = var + store(%187, 0 : Float) + let %188 : Float = load(%186) + let %189 : Float = add(%x5Fsx5FdOut, %188) + store(%186, %189) + unconditionalBranch(%190) + +block %190: + let %191 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) + let %192 : Int = sub(%191, 1 : Int) + [loopMaxIters(4 : Int)] + loop(%193, %194, %195, %192) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) +block %193( + [primalInstDecoration] + [nameHint("_dc")] + param %x5Fdc : Int): + let %196 : Int = add(%x5Fdc, 0 : Int) + let %197 : Float = load(%186) + store(%186, 0 : Float) + let %198 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%198, %199, %200, %199) + +block %200: + unconditionalBranch(%194, %197) + +block %194( + param %201 : Float): + let %202 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %203 : Float = GetPrimalUserCode(%202) + let %204 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%203, %201) + store(%dpy1, %204) + return_val(void_constant) + +block %199: + unconditionalBranch(%205) + +block %205: + [primalInstDecoration] + let %206 : Bool = cmpLT(%196, 3 : Int) + ifElse(%206, %207, %208, %209) -inst with location: 0 (0) -unconditionalBranch(%1) +block %208: + unconditionalBranch(%209, 0 : Int) -inst with location: 0 (0) -[BackwardDerivativePrimalReturnDecoration(%t)] -unconditionalBranch(%1) +block %207: + unconditionalBranch(%209, 1 : Int) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() +block %209( + [primalInstDecoration] + param %210 : Int): + unconditionalBranch(%211) -inst with location: 0 (0) -let %1 : Ptr(Float) = var +block %211: + [primalInstDecoration] + let %212 : Bool = cmpNE(%210, 1 : Int) + ifElse(%212, %213, %214, %215) -inst with location: 0 (0) -store(%1, %2) +block %214: + unconditionalBranch(%215, true) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() +block %213: + unconditionalBranch(%215, false) -inst with location: 0 (0) -let %1 : Ptr(Float) = var +block %215( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag3 : Bool): + unconditionalBranch(%216) + +block %216: + ifElse(%x5Fbflag3, %217, %218, %219) + +block %218: + unconditionalBranch(%219) + +block %217: + unconditionalBranch(%219) + +block %219: + unconditionalBranch(%220) + +block %220: + unconditionalBranch(%221, %197) + +block %221( + param %222 : Float): + ifElse(%x5Fbflag3, %223, %224, %225) + +block %224: + unconditionalBranch(%226, %222) + +block %226( + param %227 : Float): + let %228 : Float = load(%186) + let %229 : Float = add(%227, %228) + store(%186, %229) + unconditionalBranch(%225) + +block %223: + unconditionalBranch(%230, %222) + +block %230( + param %231 : Float): + let %232 : Float = load(%187) + let %233 : Float = add(%231, %232) + store(%187, %233) + unconditionalBranch(%225) + +block %225: + unconditionalBranch(%234) + +block %234: + ifElse(%212, %235, %236, %237) + +block %236: + unconditionalBranch(%237) + +block %235: + unconditionalBranch(%237) + +block %237: + unconditionalBranch(%238) + +block %238: + let %239 : Float = load(%187) + store(%187, 0 : Float) + ifElse(%206, %240, %241, %242) + +block %241: + unconditionalBranch(%243) + +block %243: + unconditionalBranch(%242) + +block %240: + unconditionalBranch(%244, %239) + +block %244( + param %245 : Float): + let %246 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %247 : Ptr(Array(Float, 5 : Int)) = var + store(%247, %246) + let %248 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%247, %x5Fdc) + let %249 : Float = load(%248) + let %250 : Float = mul(%249, %245) + let %251 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) + let %252 : Ptr(Array(Float, 5 : Int)) = var + store(%252, %251) + let %253 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%252, %x5Fdc) + let %254 : Float = load(%253) + let %255 : Float = mul(%254, %245) + let %256 : Float = load(%186) + let %257 : Float = add(%250, %255) + let %258 : Float = add(%257, %256) + store(%186, %258) + unconditionalBranch(%242) + +block %242: + unconditionalBranch(%195) + +block %195: + [primalInstDecoration] + let %259 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%193, %259) -inst with location: 0 (0) -store(%1, %2) +block %179: + unconditionalBranch(%260) -inst with location: 0 (0) -let %1 : Float = load(%2) +block %260: + [primalInstDecoration] + let %261 : Bool = cmpLT(%i2, 3 : Int) + ifElse(%261, %262, %263, %264) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %2) +block %263: + unconditionalBranch(%264, 0 : Int, 0 : Float) -inst with location: 0 (0) -store(%1, %2) +block %262: + [primalInstDecoration] + let %265 : Float = mul(%t2, %t2) + unconditionalBranch(%264, 1 : Int, %265) -inst with location: 0 (0) -unconditionalBranch(%1) +block %264( + [primalInstDecoration] + param %266 : Int, + [primalInstDecoration] + param %267 : Float): + unconditionalBranch(%268) -inst with location: 0 (0) -[diffInstDecoration(Void, %1)] -[loopMaxIters(4 : Int)] -loop(%2, %3, %4) +block %268: + [primalInstDecoration] + let %269 : Bool = cmpNE(%266, 1 : Int) + ifElse(%269, %270, %271, %272) -inst with location: 0 (0) -let %1 : Float = load(%2) +block %271: + unconditionalBranch(%272, %x5Fbflag2) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() +block %270: + unconditionalBranch(%272, false) -inst with location: 0 (0) -store(%1, %2) +block %272( + [primalInstDecoration] + [nameHint("_bflag")] + param %x5Fbflag4 : Bool): + unconditionalBranch(%273) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) +block %273: + ifElse(%x5Fbflag4, %274, %275, %276) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %275: + unconditionalBranch(%276, %t2, %i2) -inst with location: 0 (0) -let %1 : Float = param +block %274: + [primalInstDecoration] + let %277 : Int = add(%i2, 1 : Int) + unconditionalBranch(%276, %267, %277) -inst with location: 0 (0) -let %1 : DiffPair(Float, %2) = load(%dpy) +block %276( + [primalInstDecoration] + [nameHint("t")] + param %t3 : Float, + [primalInstDecoration] + [nameHint("i")] + param %i3 : Int): + [primalInstDecoration] + let %278 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%172, %x5Fbflag4, %t3, %i3, %278) +} +[backwardDifferentiable] +func %157 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) +{ +block %279( + param %280 : Array(Float, 5 : Int), + param %281 : Array(Float, 5 : Int)): + let %282 : Ptr(Array(Float, 5 : Int)) = var + loop(%283, %284, %283, 0 : Int) + +block %283( + param %285 : Int): + let %286 : Bool = cmpLT(%285, 5 : Int) + ifElse(%286, %287, %288, %288) + +block %287: + let %289 : Float = getElement(%280, %285) + let %290 : Float = getElement(%281, %285) + let %291 : Float = add(%289, %290) + let %292 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%282, %285) + store(%292, %291) + unconditionalBranch(%293) + +block %288: + unconditionalBranch(%284) + +block %284: + let %294 : Array(Float, 5 : Int) = load(%282) + return_val(%294) + +block %293: + let %295 : Int = add(%285, 1 : Int) + unconditionalBranch(%283, %295) +} +func %148 : Func(Array(Float, 5 : Int)) +{ +block %296: + let %297 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) + return_val(%297) +} +witness_table %161 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) +{ + witness_table_entry(%18,Array(Float, 5 : Int)) -inst with location: 0 (0) -let %1 : Float = GetPrimal(%2) + witness_table_entry(%20,%161) -inst with location: 0 (0) -let %1 : DiffPair(Float, %2) = MakeDiffPair(%3, %4) + witness_table_entry(%24,%157) -inst with location: 0 (0) -store(%dpy, %1) + witness_table_entry(%22,%148) -inst with location: 0 (0) -return_val(void_constant) +} -inst with location: 0 (0) -unconditionalBranch(%1, %2) +GenericSpecializationDictionary +ExistentialFuncSpecializationDictionary +ExistentialTypeSpecializationDictionary +### +### BEFORE-LOWER-GENERICS: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +[nameHint("DiffPair_float")] +struct %DiffPairx5Ffloat : Type +{ + field(%primal, Float) + field(%differential, Float) +} -inst with location: 0 (0) -let %1 : Float = param +let %7 : Void = EntryPointLayout(%8, %9) +let %9 : Void = varLayout(%10) +let %8 : Void = varLayout(%11) +let %11 : Void = structTypeLayout(%12) +let %12 : Void = fieldLayout(%13, %14) +let %14 : Void = varLayout(%10, %15, %16) +let %16 : Void = stage(6 : Int) +let %15 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %10 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %13 : _ = key +[export("_ST4core17IBufferDataLayout")] +[nameHint("IBufferDataLayout")] +let %IBufferDataLayout : Type = interface +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %17 : witness_table_t(%IBufferDataLayout)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %17) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%7)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %18( + [layout(%14)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(%DiffPairx5Ffloat) = var + let %19 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) + store(%dpa, %19) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) + let %20 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %21 : %DiffPairx5Ffloat = load(%dpa) + let %22 : Float = get_field(%21, %differential) + store(%20, %22) + [nameHint("dpa")] + let %dpa1 : Ptr(%DiffPairx5Ffloat) = var + let %23 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) + store(%dpa1, %23) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) + let %24 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %25 : %DiffPairx5Ffloat = load(%dpa1) + let %26 : Float = get_field(%25, %differential) + store(%24, %26) + return_val(void_constant) +} +[readNone] +[FloatingPointModeOverride(1 : Int)] +[backwardDifferentiable] +[nameHint("s_bwd_test_simple_loop")] +func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) +{ +block %27( + param %28 : InOut(%DiffPairx5Ffloat), + param %29 : Float): + let %30 : %DiffPairx5Ffloat = load(%28) + let %31 : Float = get_field(%30, %primal) + let %32 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %33 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%31, %32) + let %34 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%32) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%28, %29, %34) + return_val(void_constant) +} +[readNone] +[nameHint("s_primal_ctx_test_simple_loop")] +[FloatingPointModeOverride(1 : Int)] +[backwardDifferentiable] +func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) +{ +block %35( + [nameHint("dpy")] + param %dpy : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): + let %36 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %37 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%36, 0 : Int) + store(%x5Fsx5Fdiffx5Fctx, %37) + let %38 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %39) + let %40 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%38, %40) + let %41 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %42) + store(%41, 0 : Int) + [loopMaxIters(4 : Int)] + loop(%43, %44, %43, true, %dpy, 0 : Int, 0 : Int) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) +block %43( + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int, + [nameHint("_pc")] + param %x5Fpc : Int): + let %45 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%38, %x5Fpc) + store(%45, %t) + store(%41, %x5Fpc) + ifElse(%x5Fbflag, %46, %47, %46) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %47: + unconditionalBranch(%44) -inst with location: 0 (0) -let %1 : Float = param +block %44: + return_val(%t) -inst with location: 0 (0) -let %1 : Float = load(%2) +block %46: + unconditionalBranch(%48) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) +block %48: + let %49 : Bool = cmpLT(%i, 3 : Int) + ifElse(%49, %50, %51, %52) -inst with location: 0 (0) -store(%1, %2) +block %51: + unconditionalBranch(%52, 0 : Int, 0 : Float) -inst with location: 0 (0) -unconditionalBranch(%1) +block %50: + let %53 : Float = mul(%t, %t) + unconditionalBranch(%52, 1 : Int, %53) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %52( + param %54 : Int, + param %55 : Float): + unconditionalBranch(%56) -inst with location: 0 (0) -let %1 : Float = param +block %56: + let %57 : Bool = cmpNE(%54, 1 : Int) + ifElse(%57, %58, %59, %60) -inst with location: 0 (0) -let %1 : Float = load(%2) +block %59: + unconditionalBranch(%60, %x5Fbflag) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) +block %58: + unconditionalBranch(%60, false) -inst with location: 0 (0) -store(%1, %2) +block %60( + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%61) -inst with location: 0 (0) -unconditionalBranch(%1) +block %61: + ifElse(%x5Fbflag1, %62, %63, %64) -inst with location: 0 (0) -unconditionalBranch(%1) +block %63: + unconditionalBranch(%64, %t, %i) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %62: + let %65 : Int = add(%i, 1 : Int) + unconditionalBranch(%64, %55, %65) -inst with location: 0 (0) -unconditionalBranch(%1) +block %64( + [nameHint("t")] + param %t1 : Float, + [nameHint("i")] + param %i1 : Int): + let %66 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%43, %x5Fbflag1, %t1, %i1, %66) +} +let %39 : _ = key +let %42 : _ = key +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + field(%39, Array(Float, 5 : Int)) + field(%42, Int) +} -inst with location: 0 (0) -unconditionalBranch(%1) +[readNone] +[FloatingPointModeOverride(1 : Int)] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ +block %67( + [nameHint("dpy")] + param %dpy1 : InOut(%DiffPairx5Ffloat), + [nameHint("_s_dOut")] + param %x5Fsx5FdOut : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): + let %68 : %DiffPairx5Ffloat = load(%dpy1) + let %69 : Float = get_field(%68, %primal) + [loopMaxIters(4 : Int)] + loop(%70, %71, %70, true, %69, 0 : Int, 0 : Int) -inst with location: 0 (0) -unconditionalBranch(%1) +block %70( + [nameHint("_bflag")] + param %x5Fbflag2 : Bool, + [nameHint("t")] + param %t2 : Float, + [nameHint("i")] + param %i2 : Int, + [nameHint("_pc")] + param %x5Fpc1 : Int): + let %72 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) + let %73 : Ptr(Array(Float, 5 : Int)) = var + store(%73, %72) + let %74 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%73, %x5Fpc1) + store(%74, %t2) + ifElse(%x5Fbflag2, %75, %76, %75) + +block %76: + unconditionalBranch(%71) + +block %71: + unconditionalBranch(%77) + +block %77: + let %78 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %42) + let %79 : Int = sub(%78, 1 : Int) + [loopMaxIters(4 : Int)] + loop(%80, %81, %82, %79, %x5Fsx5FdOut) + +block %80( + [nameHint("_dc")] + param %x5Fdc : Int, + param %83 : Float): + let %84 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%84, %85, %86, %85) -inst with location: 0 (0) -let %1 : Float = load(%2) +block %86: + unconditionalBranch(%81) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() +block %81: + let %87 : %DiffPairx5Ffloat = load(%dpy1) + let %88 : Float = get_field(%87, %primal) + let %89 : %DiffPairx5Ffloat = makeStruct(%88, %83) + store(%dpy1, %89) + return_val(void_constant) -inst with location: 0 (0) -store(%1, %2) +block %85: + unconditionalBranch(%90) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %90: + let %91 : Bool = cmpLT(%x5Fdc, 3 : Int) + ifElse(%91, %92, %93, %94) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %93: + unconditionalBranch(%94, 0 : Int) -inst with location: 0 (0) -let %1 : Float = param +block %92: + unconditionalBranch(%94, 1 : Int) -inst with location: 0 (0) -unconditionalBranch(%1) +block %94( + param %95 : Int): + unconditionalBranch(%96) -inst with location: 0 (0) -unconditionalBranch(%1, %2) +block %96: + let %97 : Bool = cmpNE(%95, 1 : Int) + let %98 : Bool = not(%97) + ifElse(%98, %99, %100, %101) -inst with location: 0 (0) -let %1 : Float = param +block %100: + unconditionalBranch(%101, 0 : Float, %83) -inst with location: 0 (0) -let %1 : Float = mul(%t, %2) +block %99: + unconditionalBranch(%101, %83, 0 : Float) -inst with location: 0 (0) -let %1 : Float = mul(%t, %2) +block %101( + param %102 : Float, + param %103 : Float): + unconditionalBranch(%104) -inst with location: 0 (0) -let %1 : Float = load(%2) +block %104: + ifElse(%91, %105, %106, %107) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) +block %106: + unconditionalBranch(%107, %103) -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) +block %105: + let %108 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) + let %109 : Float = getElement(%108, %x5Fdc) + let %110 : Float = mul(%109, %102) + let %111 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) + let %112 : Float = getElement(%111, %x5Fdc) + let %113 : Float = mul(%112, %102) + let %114 : Float = add(%110, %113) + let %115 : Float = add(%114, %103) + unconditionalBranch(%107, %115) -inst with location: 0 (0) -store(%1, %2) +block %107( + param %116 : Float): + unconditionalBranch(%82) -inst with location: 0 (0) -unconditionalBranch(%1) +block %82: + let %117 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%80, %117, %116) -inst with location: 0 (0) -unconditionalBranch(%1) +block %75: + unconditionalBranch(%118) -inst with location: 0 (0) -unconditionalBranch(%1) +block %118: + let %119 : Bool = cmpLT(%i2, 3 : Int) + ifElse(%119, %120, %121, %122) -inst with location: 0 (0) -unconditionalBranch(%1) +block %121: + unconditionalBranch(%122, 0 : Int, 0 : Float) -inst with location: 1515026 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) +block %120: + let %123 : Float = mul(%t2, %t2) + unconditionalBranch(%122, 1 : Int, %123) -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +block %122( + param %124 : Int, + param %125 : Float): + unconditionalBranch(%126) -inst with location: 0 (0) -unconditionalBranch(%1, 0 : Int, 0 : Float) +block %126: + let %127 : Bool = cmpNE(%124, 1 : Int) + ifElse(%127, %128, %129, %130) -inst with location: 1515058 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) +block %129: + unconditionalBranch(%130, %x5Fbflag2) + +block %128: + unconditionalBranch(%130, false) -inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int, %2) +block %130( + [nameHint("_bflag")] + param %x5Fbflag3 : Bool): + unconditionalBranch(%131) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param +block %131: + ifElse(%x5Fbflag3, %132, %133, %134) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param +block %133: + unconditionalBranch(%134, %t2, %i2) -inst with location: 0 (0) -unconditionalBranch(%1) +block %132: + let %135 : Int = add(%i2, 1 : Int) + unconditionalBranch(%134, %125, %135) -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) +block %134( + [nameHint("t")] + param %t3 : Float, + [nameHint("i")] + param %i3 : Int): + let %136 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%70, %x5Fbflag3, %t3, %i3, %136) +} +[nameHint("primal")] +let %primal : _ = key +[nameHint("differential")] +let %differential : _ = key +### +### AFTER-LOWER-GENERICS: +undefined +let %1 : Void = varLayout(%2, %3) +let %3 : Void = offset(9 : Int, 0 : Int) +let %2 : Void = structuredBufferTypeLayout(%4, %5) +let %5 : Void = size(9 : Int, 1 : Int) +let %4 : Void = typeLayout(%6) +let %6 : Void = size(8 : Int, 4 : Int) +let %7 : Vec(UInt, 2 : Int) = makeVector(0 : UInt, 0 : UInt) +[nameHint("DiffPair_float")] +struct %DiffPairx5Ffloat : Type +{ + field(%primal, Float) + field(%differential, Float) +} -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) +let %8 : Void = EntryPointLayout(%9, %10) +let %10 : Void = varLayout(%11) +let %9 : Void = varLayout(%12) +let %12 : Void = structTypeLayout(%13) +let %13 : Void = fieldLayout(%14, %15) +let %15 : Void = varLayout(%11, %16, %17) +let %17 : Void = stage(6 : Int) +let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) +let %11 : Void = typeLayout +[keepAlive] +global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") +let %14 : _ = key +[SequentialIDDecoration(0 : UInt)] +[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] +witness_table %18 : witness_table_t(0 : Int)(DefaultLayout); + +[nameHint("outputBuffer")] +[export("_SVR15reverse_2Dxloop12outputBuffer")] +[layout(%1)] +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %7) = global_param +[keepAlive] +[entryPoint(6 : Int, "computeMain", "reverse-loop")] +[numThreads(1 : Int, 1 : Int, 1 : Int)] +[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] +[nameHint("computeMain")] +[layout(%8)] +func %computeMain : Func(Void, Vec(UInt, 3 : Int)) +{ +block %19( + [layout(%15)] + [nameHint("dispatchThreadID")] + [semantic("SV_DispatchThreadID", 0 : Int)] + param %dispatchThreadID : Vec(UInt, 3 : Int)): + [nameHint("dpa")] + let %dpa : Ptr(%DiffPairx5Ffloat) = var + let %20 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) + store(%dpa, %20) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) + let %21 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %22 : %DiffPairx5Ffloat = load(%dpa) + let %23 : Float = get_field(%22, %differential) + store(%21, %23) + [nameHint("dpa")] + let %dpa1 : Ptr(%DiffPairx5Ffloat) = var + let %24 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) + store(%dpa1, %24) + call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) + let %25 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %26 : %DiffPairx5Ffloat = load(%dpa1) + let %27 : Float = get_field(%26, %differential) + store(%25, %27) + return_val(void_constant) +} +[readNone] +[FloatingPointModeOverride(1 : Int)] +[backwardDifferentiable] +[nameHint("s_bwd_test_simple_loop")] +func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) +{ +block %28( + param %29 : InOut(%DiffPairx5Ffloat), + param %30 : Float): + let %31 : %DiffPairx5Ffloat = load(%29) + let %32 : Float = get_field(%31, %primal) + let %33 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %34 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%32, %33) + let %35 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%33) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%29, %30, %35) + return_val(void_constant) +} +[readNone] +[nameHint("s_primal_ctx_test_simple_loop")] +[FloatingPointModeOverride(1 : Int)] +[backwardDifferentiable] +func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) +{ +block %36( + [nameHint("dpy")] + param %dpy : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): + let %37 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %38 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%37, 0 : Int) + store(%x5Fsx5Fdiffx5Fctx, %38) + let %39 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %40) + let %41 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%39, %41) + let %42 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %43) + store(%42, 0 : Int) + [loopMaxIters(4 : Int)] + loop(%44, %45, %44, true, %dpy, 0 : Int, 0 : Int) -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag) +block %44( + [nameHint("_bflag")] + param %x5Fbflag : Bool, + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int, + [nameHint("_pc")] + param %x5Fpc : Int): + let %46 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%39, %x5Fpc) + store(%46, %t) + store(%42, %x5Fpc) + ifElse(%x5Fbflag, %47, %48, %47) -inst with location: 0 (0) -unconditionalBranch(%1, false) +block %48: + unconditionalBranch(%45) -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +block %45: + return_val(%t) -inst with location: 0 (0) -unconditionalBranch(%1) +block %47: + unconditionalBranch(%49) -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) +block %49: + let %50 : Bool = cmpLT(%i, 3 : Int) + ifElse(%50, %51, %52, %53) -inst with location: 0 (0) -unconditionalBranch(%1, %t, %i) +block %52: + unconditionalBranch(%53, 0 : Int, 0 : Float) -inst with location: 1515032 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) +block %51: + let %54 : Float = mul(%t, %t) + unconditionalBranch(%53, 1 : Int, %54) -inst with location: 0 (0) -unconditionalBranch(%1, %2, %3) +block %53( + param %55 : Int, + param %56 : Float): + unconditionalBranch(%57) -inst with location: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %57: + let %58 : Bool = cmpNE(%55, 1 : Int) + ifElse(%58, %59, %60, %61) -inst with location: 1515017 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +block %60: + unconditionalBranch(%61, %x5Fbflag) -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag, %t, %i) +block %59: + unconditionalBranch(%61, false) -Adding counter for primalLoop: -[loopMaxIters(4 : Int)] -let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) +block %61( + [nameHint("_bflag")] + param %x5Fbflag1 : Bool): + unconditionalBranch(%62) - > sourceLoc: 1515008 (1) ->> Counter for primalLoop: -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param +block %62: + ifElse(%x5Fbflag1, %63, %64, %65) - > sourceLoc: 1515008 (1) -### Slang::AutodiffCheckpointPolicyBase::processFunc -processing workList -use with usedVal: -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %64: + unconditionalBranch(%65, %t, %i) +block %63: + let %66 : Int = add(%i, 1 : Int) + unconditionalBranch(%65, %56, %66) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513345E0 to storeSet -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %65( + [nameHint("t")] + param %t1 : Float, + [nameHint("i")] + param %i1 : Int): + let %67 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%44, %x5Fbflag1, %t1, %i1, %67) +} +let %40 : _ = key +let %43 : _ = key +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + field(%40, Array(Float, 5 : Int)) + field(%43, Int) +} -inst with location: 1514994 (1) -use with usedVal: -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +[readNone] +[FloatingPointModeOverride(1 : Int)] +[backwardDifferentiable] +[nameHint("s_bwd_prop_test_simple_loop")] +func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +{ +block %68( + [nameHint("dpy")] + param %dpy1 : InOut(%DiffPairx5Ffloat), + [nameHint("_s_dOut")] + param %x5Fsx5FdOut : Float, + [nameHint("_s_diff_ctx")] + param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): + let %69 : %DiffPairx5Ffloat = load(%dpy1) + let %70 : Float = get_field(%69, %primal) + [loopMaxIters(4 : Int)] + loop(%71, %72, %71, true, %70, 0 : Int, 0 : Int) +block %71( + [nameHint("_bflag")] + param %x5Fbflag2 : Bool, + [nameHint("t")] + param %t2 : Float, + [nameHint("i")] + param %i2 : Int, + [nameHint("_pc")] + param %x5Fpc1 : Int): + let %73 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) + let %74 : Ptr(Array(Float, 5 : Int)) = var + store(%74, %73) + let %75 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%74, %x5Fpc1) + store(%75, %t2) + ifElse(%x5Fbflag2, %76, %77, %76) + +block %77: + unconditionalBranch(%72) + +block %72: + unconditionalBranch(%78) + +block %78: + let %79 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %43) + let %80 : Int = sub(%79, 1 : Int) + [loopMaxIters(4 : Int)] + loop(%81, %82, %83, %80, %x5Fsx5FdOut) + +block %81( + [nameHint("_dc")] + param %x5Fdc : Int, + param %84 : Float): + let %85 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%85, %86, %87, %86) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513345E0 to storeSet -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %87: + unconditionalBranch(%82) -inst with location: 1514994 (1) -use with usedVal: -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) +block %82: + let %88 : %DiffPairx5Ffloat = load(%dpy1) + let %89 : Float = get_field(%88, %primal) + let %90 : %DiffPairx5Ffloat = makeStruct(%89, %84) + store(%dpy1, %90) + return_val(void_constant) -use with usedVal: -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param +block %86: + unconditionalBranch(%91) -use with usedVal: -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) +block %91: + let %92 : Bool = cmpLT(%x5Fdc, 3 : Int) + ifElse(%92, %93, %94, %95) -use with usedVal: -[primalInstDecoration] -let %1 : Int = param +block %94: + unconditionalBranch(%95, 0 : Int) -use with usedVal: -0 +block %93: + unconditionalBranch(%95, 1 : Int) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C51311B10 to storeSet -0 -inst with location: 0 (0) -use with usedVal: -1 +block %95( + param %96 : Int): + unconditionalBranch(%97) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513116E0 to storeSet -1 -inst with location: 0 (0) -use with usedVal: -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +block %97: + let %98 : Bool = cmpNE(%96, 1 : Int) + let %99 : Bool = not(%98) + ifElse(%99, %100, %101, %102) -use with usedVal: -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +block %101: + unconditionalBranch(%102, 0 : Float, %84) -use with usedVal: +block %100: + unconditionalBranch(%102, %84, 0 : Float) +block %102( + param %103 : Float, + param %104 : Float): + unconditionalBranch(%105) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C513397D0 to storeSet +block %105: + ifElse(%92, %106, %107, %108) -inst with location: 0 (0) -use with usedVal: -[nameHint("dpy")] -let %dpy : InOut(DiffPair(Float, %1)) = param +block %107: + unconditionalBranch(%108, %104) -use with usedVal: -[nameHint("dpy")] -let %dpy : InOut(DiffPair(Float, %1)) = param +block %106: + let %109 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) + let %110 : Float = getElement(%109, %x5Fdc) + let %111 : Float = mul(%110, %103) + let %112 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) + let %113 : Float = getElement(%112, %x5Fdc) + let %114 : Float = mul(%113, %103) + let %115 : Float = add(%111, %114) + let %116 : Float = add(%115, %104) + unconditionalBranch(%108, %116) -use with usedVal: -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param +block %108( + param %117 : Float): + unconditionalBranch(%83) +block %83: + let %118 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%81, %118, %117) -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000020C5133F928 to storeSet -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param +block %76: + unconditionalBranch(%119) -inst with location: 1515008 (1) -use with usedVal: -[nameHint("_s_dOut")] -let %x5Fsx5FdOut : Float = param +block %119: + let %120 : Bool = cmpLT(%i2, 3 : Int) + ifElse(%120, %121, %122, %123) -****** (before legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 1514994 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %122: + unconditionalBranch(%123, 0 : Int, 0 : Float) -source loc recorded: 1515008 (1) -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param +block %121: + let %124 : Float = mul(%t2, %t2) + unconditionalBranch(%123, 1 : Int, %124) -****** ensureInstAvailable -ensureInstAvailable, worklist element: -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param +block %123( + param %125 : Int, + param %126 : Float): + unconditionalBranch(%127) ->> LOOP COUNTER! -% localVar: -let %1 : Ptr(Int) = var +block %127: + let %128 : Bool = cmpNE(%125, 1 : Int) + ifElse(%128, %129, %130, %131) -ensureInstAvailable, worklist element: -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param +block %130: + unconditionalBranch(%131, %x5Fbflag2) + +block %129: + unconditionalBranch(%131, false) -% localVar: -let %1 : Ptr(Array(Float, 5 : Int)) = var +block %131( + [nameHint("_bflag")] + param %x5Fbflag3 : Bool): + unconditionalBranch(%132) -ensureInstAvailable, worklist element: -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param +block %132: + ifElse(%x5Fbflag3, %133, %134, %135) ->> NO OUT OF SCOPE USES -ensureInstAvailable, worklist element: -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) +block %134: + unconditionalBranch(%135, %t2, %i2) ->> NO OUT OF SCOPE USES -ensureInstAvailable, worklist element: -[primalInstDecoration] -let %1 : Int = param +block %133: + let %136 : Int = add(%i2, 1 : Int) + unconditionalBranch(%135, %126, %136) ->> NO OUT OF SCOPE USES -ensureInstAvailable, worklist element: -[primalInstDecoration] -let %1 : Bool = cmpLT(%2, 3 : Int) +block %135( + [nameHint("t")] + param %t3 : Float, + [nameHint("i")] + param %i3 : Int): + let %137 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%71, %x5Fbflag3, %t3, %i3, %137) +} +[nameHint("primal")] +let %primal : _ = key +[nameHint("differential")] +let %differential : _ = key +### +checking for checkpointing structures: +checkpoint intermediate struct +sourceLocs: 1514954 (1) +[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] +[CheckpointIntermediateDecoration] +struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type +{ + field(%1, Array(Float, 5 : Int)) + field(%2, Int) +} ->> NO OUT OF SCOPE USES -****** (after legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 1515008 (1) -let %1 : Ptr(Int) = var -tests/autodiff/reverse-loop.slang(16): note: also see pipeline definition - for (int i = 0; i < 3; i++) - ^~~ -source loc recorded: 1514994 (1) -let %1 : Ptr(Array(Float, 5 : Int)) = var +tests/autodiff/reverse-loop.slang(12): note: also see pipeline definition +float test_simple_loop(float y) + ^~~~~~~~~~~~~~~~ +size of struct: 24 (4) +fields: sourceLocs: 1514994 (1) + [Offset(0 : Int, 0 : Int)] +field(%1, Array(Float, 5 : Int)) -tests/autodiff/reverse-loop.slang(14): note: also see pipeline definition - float t = y; - ^ diff --git a/reverse-loop.slang-ast b/reverse-loop.slang-ast deleted file mode 100644 index 73e228d57a..0000000000 --- a/reverse-loop.slang-ast +++ /dev/null @@ -1,1154 +0,0 @@ -ModuleDecl:0 { - astNodeType : ModuleDecl - loc : SourceLoc(1514807) tests/autodiff/reverse-loop.slang:6 - modifiers : { - } - parentDecl : null - nameAndLoc : NameLoc{"reverse-loop", SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - VarDecl:1, - TypeDefDecl:2, - EmptyDecl:3, - TypeDefDecl:4, - EmptyDecl:5, - FuncDecl:6, - FuncDecl:7 - } - closingSourceLoc : SourceLoc(1515508) tests/autodiff/reverse-loop.slang:41 - ownedScope : ::?::reverse-loop - module : Unknown@0x0000020c43be4040 - mapDeclToAssociatedDecls : { - } - isInLegacyLanguage : 1 -} -VarDecl:1 { - astNodeType : VarDecl - loc : SourceLoc(1514833) tests/autodiff/reverse-loop.slang:6 - modifiers : { - } - parentDecl : ModuleDecl:0 - nameAndLoc : NameLoc{"outputBuffer", SourceLoc(1514833) tests/autodiff/reverse-loop.slang:6 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - GenericAppExpr:8, - null - } - initExpr : null - val : null -} -TypeDefDecl:2 { - astNodeType : TypeDefDecl - loc : SourceLoc(1514882) tests/autodiff/reverse-loop.slang:8 - modifiers : { - } - parentDecl : ModuleDecl:0 - nameAndLoc : NameLoc{"dpfloat", SourceLoc(1514882) tests/autodiff/reverse-loop.slang:8 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - GenericAppExpr:9, - null - } -} -EmptyDecl:3 { - astNodeType : EmptyDecl - loc : SourceLoc(1514889) tests/autodiff/reverse-loop.slang:8 - modifiers : { - } - parentDecl : ModuleDecl:0 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null -} -TypeDefDecl:4 { - astNodeType : TypeDefDecl - loc : SourceLoc(1514919) tests/autodiff/reverse-loop.slang:9 - modifiers : { - } - parentDecl : ModuleDecl:0 - nameAndLoc : NameLoc{"dfloat", SourceLoc(1514919) tests/autodiff/reverse-loop.slang:9 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - MemberExpr:10, - null - } -} -EmptyDecl:5 { - astNodeType : EmptyDecl - loc : SourceLoc(1514925) tests/autodiff/reverse-loop.slang:9 - modifiers : { - } - parentDecl : ModuleDecl:0 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null -} -FuncDecl:6 { - astNodeType : FuncDecl - loc : SourceLoc(1514954) tests/autodiff/reverse-loop.slang:12 - modifiers : { - UncheckedAttribute:11 - } - parentDecl : ModuleDecl:0 - nameAndLoc : NameLoc{"test_simple_loop", SourceLoc(1514954) tests/autodiff/reverse-loop.slang:12 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - ParamDecl:12 - } - closingSourceLoc : SourceLoc(1515088) tests/autodiff/reverse-loop.slang:22 - ownedScope : ::?::reverse-loop::test_simple_loop - returnType : { - VarExpr:13, - null - } - errorType : { - null, - null - } - primaryDecl : null - nextDecl : null - body : BlockStmt:14 -} -FuncDecl:7 { - astNodeType : FuncDecl - loc : SourceLoc(1515121) tests/autodiff/reverse-loop.slang:25 - modifiers : { - UncheckedAttribute:15 - } - parentDecl : ModuleDecl:0 - nameAndLoc : NameLoc{"computeMain", SourceLoc(1515121) tests/autodiff/reverse-loop.slang:25 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - ParamDecl:16 - } - closingSourceLoc : SourceLoc(1515505) tests/autodiff/reverse-loop.slang:40 - ownedScope : ::?::reverse-loop::computeMain - returnType : { - VarExpr:17, - null - } - errorType : { - null, - null - } - primaryDecl : null - nextDecl : null - body : BlockStmt:18 -} -GenericAppExpr:8 { - astNodeType : GenericAppExpr - loc : SourceLoc(1514807) tests/autodiff/reverse-loop.slang:6 - type : rvalue null - arguments : { - VarExpr:19 - } - functionExpr : VarExpr:20 - originalFunctionExpr : null - argumentDelimeterLocs : { - } -} -GenericAppExpr:9 { - astNodeType : GenericAppExpr - loc : SourceLoc(1514858) tests/autodiff/reverse-loop.slang:8 - type : rvalue null - arguments : { - VarExpr:21 - } - functionExpr : VarExpr:22 - originalFunctionExpr : null - argumentDelimeterLocs : { - } -} -MemberExpr:10 { - astNodeType : MemberExpr - loc : SourceLoc(1514906) tests/autodiff/reverse-loop.slang:9 - type : rvalue null - declRef : - name : "Differential" - originalExpr : null - baseExpression : VarExpr:23 - memberOperatorLoc : SourceLoc(1514905) tests/autodiff/reverse-loop.slang:9 -} -UncheckedAttribute:11 { - astNodeType : UncheckedAttribute - loc : SourceLoc(1514931) tests/autodiff/reverse-loop.slang:11 - next : null - keywordName : "Differentiable" - attributeDecl : null - originalIdentifierToken : { identifier, SourceLoc(1514931) tests/autodiff/reverse-loop.slang:11, "Differentiable" } - args : { - } -} -ParamDecl:12 { - astNodeType : ParamDecl - loc : SourceLoc(1514977) tests/autodiff/reverse-loop.slang:12 - modifiers : { - } - parentDecl : FuncDecl:6 - nameAndLoc : NameLoc{"y", SourceLoc(1514977) tests/autodiff/reverse-loop.slang:12 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - VarExpr:24, - null - } - initExpr : null - val : null -} -VarExpr:13 { - astNodeType : VarExpr - loc : SourceLoc(1514948) tests/autodiff/reverse-loop.slang:12 - type : rvalue null - declRef : - name : "float" - originalExpr : null -} -BlockStmt:14 { - astNodeType : BlockStmt - loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 - modifiers : { - } - scopeDecl : ScopeDecl:25 - closingSourceLoc : SourceLoc(1515088) tests/autodiff/reverse-loop.slang:22 - body : SeqStmt:26 -} -UncheckedAttribute:15 { - astNodeType : UncheckedAttribute - loc : SourceLoc(1515094) tests/autodiff/reverse-loop.slang:24 - next : null - keywordName : "numthreads" - attributeDecl : null - originalIdentifierToken : { identifier, SourceLoc(1515094) tests/autodiff/reverse-loop.slang:24, "numthreads" } - args : { - IntegerLiteralExpr:27, - IntegerLiteralExpr:28, - IntegerLiteralExpr:29 - } -} -ParamDecl:16 { - astNodeType : ParamDecl - loc : SourceLoc(1515139) tests/autodiff/reverse-loop.slang:25 - modifiers : { - HLSLSimpleSemantic:30 - } - parentDecl : FuncDecl:7 - nameAndLoc : NameLoc{"dispatchThreadID", SourceLoc(1515139) tests/autodiff/reverse-loop.slang:25 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - VarExpr:31, - null - } - initExpr : null - val : null -} -VarExpr:17 { - astNodeType : VarExpr - loc : SourceLoc(1515116) tests/autodiff/reverse-loop.slang:25 - type : rvalue null - declRef : - name : "void" - originalExpr : null -} -BlockStmt:18 { - astNodeType : BlockStmt - loc : SourceLoc(1515187) tests/autodiff/reverse-loop.slang:27 - modifiers : { - } - scopeDecl : ScopeDecl:32 - closingSourceLoc : SourceLoc(1515505) tests/autodiff/reverse-loop.slang:40 - body : SeqStmt:33 -} -VarExpr:19 { - astNodeType : VarExpr - loc : SourceLoc(1514826) tests/autodiff/reverse-loop.slang:6 - type : rvalue null - declRef : - name : "float" - originalExpr : null -} -VarExpr:20 { - astNodeType : VarExpr - loc : SourceLoc(1514807) tests/autodiff/reverse-loop.slang:6 - type : rvalue null - declRef : - name : "RWStructuredBuffer" - originalExpr : null -} -VarExpr:21 { - astNodeType : VarExpr - loc : SourceLoc(1514875) tests/autodiff/reverse-loop.slang:8 - type : rvalue null - declRef : - name : "float" - originalExpr : null -} -VarExpr:22 { - astNodeType : VarExpr - loc : SourceLoc(1514858) tests/autodiff/reverse-loop.slang:8 - type : rvalue null - declRef : - name : "DifferentialPair" - originalExpr : null -} -VarExpr:23 { - astNodeType : VarExpr - loc : SourceLoc(1514900) tests/autodiff/reverse-loop.slang:9 - type : rvalue null - declRef : - name : "float" - originalExpr : null -} -VarExpr:24 { - astNodeType : VarExpr - loc : SourceLoc(1514971) tests/autodiff/reverse-loop.slang:12 - type : rvalue null - declRef : - name : "float" - originalExpr : null -} -ScopeDecl:25 { - astNodeType : ScopeDecl - loc : SourceLoc(0) - modifiers : { - } - parentDecl : FuncDecl:6 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - VarDecl:34 - } - closingSourceLoc : SourceLoc(0) - ownedScope : ::?::reverse-loop::test_simple_loop::? -} -SeqStmt:26 { - astNodeType : SeqStmt - loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 - modifiers : { - } - stmts : { - DeclStmt:35, - ForStmt:36, - ReturnStmt:37 - } -} -IntegerLiteralExpr:27 { - astNodeType : IntegerLiteralExpr - loc : SourceLoc(1515105) tests/autodiff/reverse-loop.slang:24 - type : rvalue null - token : { integer literal, SourceLoc(1515105) tests/autodiff/reverse-loop.slang:24, "1" } - suffixType : int - value : 1 -} -IntegerLiteralExpr:28 { - astNodeType : IntegerLiteralExpr - loc : SourceLoc(1515108) tests/autodiff/reverse-loop.slang:24 - type : rvalue null - token : { integer literal, SourceLoc(1515108) tests/autodiff/reverse-loop.slang:24, "1" } - suffixType : int - value : 1 -} -IntegerLiteralExpr:29 { - astNodeType : IntegerLiteralExpr - loc : SourceLoc(1515111) tests/autodiff/reverse-loop.slang:24 - type : rvalue null - token : { integer literal, SourceLoc(1515111) tests/autodiff/reverse-loop.slang:24, "1" } - suffixType : int - value : 1 -} -HLSLSimpleSemantic:30 { - astNodeType : HLSLSimpleSemantic - loc : SourceLoc(1515158) tests/autodiff/reverse-loop.slang:25 - next : null - keywordName : null - name : { identifier, SourceLoc(1515158) tests/autodiff/reverse-loop.slang:25, "SV_DispatchThreadID" } -} -VarExpr:31 { - astNodeType : VarExpr - loc : SourceLoc(1515133) tests/autodiff/reverse-loop.slang:25 - type : rvalue null - declRef : - name : "uint3" - originalExpr : null -} -ScopeDecl:32 { - astNodeType : ScopeDecl - loc : SourceLoc(0) - modifiers : { - } - parentDecl : FuncDecl:7 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - } - closingSourceLoc : SourceLoc(0) - ownedScope : ::?::reverse-loop::computeMain::? -} -SeqStmt:33 { - astNodeType : SeqStmt - loc : SourceLoc(1515187) tests/autodiff/reverse-loop.slang:27 - modifiers : { - } - stmts : { - BlockStmt:38, - BlockStmt:39 - } -} -VarDecl:34 { - astNodeType : VarDecl - loc : SourceLoc(1514994) tests/autodiff/reverse-loop.slang:14 - modifiers : { - } - parentDecl : ScopeDecl:25 - nameAndLoc : NameLoc{"t", SourceLoc(1514994) tests/autodiff/reverse-loop.slang:14 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - VarExpr:40, - null - } - initExpr : VarExpr:41 - val : null -} -DeclStmt:35 { - astNodeType : DeclStmt - loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 - modifiers : { - } - decl : VarDecl:34 -} -ForStmt:36 { - astNodeType : ForStmt - loc : SourceLoc(1515008) tests/autodiff/reverse-loop.slang:16 - modifiers : { - } - scopeDecl : ScopeDecl:42 - initialStatement : DeclStmt:43 - sideEffectExpression : PostfixExpr:44 - predicateExpression : InfixExpr:45 - statement : BlockStmt:46 -} -ReturnStmt:37 { - astNodeType : ReturnStmt - loc : SourceLoc(1515077) tests/autodiff/reverse-loop.slang:21 - modifiers : { - } - expression : VarExpr:47 -} -BlockStmt:38 { - astNodeType : BlockStmt - loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 - modifiers : { - } - scopeDecl : ScopeDecl:48 - closingSourceLoc : SourceLoc(1515337) tests/autodiff/reverse-loop.slang:32 - body : SeqStmt:49 -} -BlockStmt:39 { - astNodeType : BlockStmt - loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 - modifiers : { - } - scopeDecl : ScopeDecl:50 - closingSourceLoc : SourceLoc(1515502) tests/autodiff/reverse-loop.slang:39 - body : SeqStmt:51 -} -VarExpr:40 { - astNodeType : VarExpr - loc : SourceLoc(1514988) tests/autodiff/reverse-loop.slang:14 - type : rvalue null - declRef : - name : "float" - originalExpr : null -} -VarExpr:41 { - astNodeType : VarExpr - loc : SourceLoc(1514998) tests/autodiff/reverse-loop.slang:14 - type : rvalue null - declRef : - name : "y" - originalExpr : null -} -ScopeDecl:42 { - astNodeType : ScopeDecl - loc : SourceLoc(0) - modifiers : { - } - parentDecl : ScopeDecl:25 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - VarDecl:52 - } - closingSourceLoc : SourceLoc(0) - ownedScope : ::?::reverse-loop::test_simple_loop::?::? -} -DeclStmt:43 { - astNodeType : DeclStmt - loc : SourceLoc(1515013) tests/autodiff/reverse-loop.slang:16 - modifiers : { - } - decl : VarDecl:52 -} -PostfixExpr:44 { - astNodeType : PostfixExpr - loc : SourceLoc(1515032) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - arguments : { - VarExpr:53 - } - functionExpr : VarExpr:54 - originalFunctionExpr : null - argumentDelimeterLocs : { - } -} -InfixExpr:45 { - astNodeType : InfixExpr - loc : SourceLoc(1515026) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - arguments : { - VarExpr:55, - IntegerLiteralExpr:56 - } - functionExpr : VarExpr:57 - originalFunctionExpr : null - argumentDelimeterLocs : { - } -} -BlockStmt:46 { - astNodeType : BlockStmt - loc : SourceLoc(1515052) tests/autodiff/reverse-loop.slang:18 - modifiers : { - } - scopeDecl : ScopeDecl:58 - closingSourceLoc : SourceLoc(1515068) tests/autodiff/reverse-loop.slang:19 - body : ExpressionStmt:59 -} -VarExpr:47 { - astNodeType : VarExpr - loc : SourceLoc(1515084) tests/autodiff/reverse-loop.slang:21 - type : rvalue null - declRef : - name : "t" - originalExpr : null -} -ScopeDecl:48 { - astNodeType : ScopeDecl - loc : SourceLoc(0) - modifiers : { - } - parentDecl : ScopeDecl:32 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - VarDecl:60 - } - closingSourceLoc : SourceLoc(0) - ownedScope : ::?::reverse-loop::computeMain::?::? -} -SeqStmt:49 { - astNodeType : SeqStmt - loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 - modifiers : { - } - stmts : { - DeclStmt:61, - ExpressionStmt:62, - ExpressionStmt:63 - } -} -ScopeDecl:50 { - astNodeType : ScopeDecl - loc : SourceLoc(0) - modifiers : { - } - parentDecl : ScopeDecl:32 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - VarDecl:64 - } - closingSourceLoc : SourceLoc(0) - ownedScope : ::?::reverse-loop::computeMain::?::? -} -SeqStmt:51 { - astNodeType : SeqStmt - loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 - modifiers : { - } - stmts : { - DeclStmt:65, - ExpressionStmt:66, - ExpressionStmt:67 - } -} -VarDecl:52 { - astNodeType : VarDecl - loc : SourceLoc(1515017) tests/autodiff/reverse-loop.slang:16 - modifiers : { - } - parentDecl : ScopeDecl:42 - nameAndLoc : NameLoc{"i", SourceLoc(1515017) tests/autodiff/reverse-loop.slang:16 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - VarExpr:68, - null - } - initExpr : IntegerLiteralExpr:69 - val : null -} -VarExpr:53 { - astNodeType : VarExpr - loc : SourceLoc(1515031) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - declRef : - name : "i" - originalExpr : null -} -VarExpr:54 { - astNodeType : VarExpr - loc : SourceLoc(1515032) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - declRef : - name : "++" - originalExpr : null -} -VarExpr:55 { - astNodeType : VarExpr - loc : SourceLoc(1515024) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - declRef : - name : "i" - originalExpr : null -} -IntegerLiteralExpr:56 { - astNodeType : IntegerLiteralExpr - loc : SourceLoc(1515028) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - token : { integer literal, SourceLoc(1515028) tests/autodiff/reverse-loop.slang:16, "3" } - suffixType : int - value : 3 -} -VarExpr:57 { - astNodeType : VarExpr - loc : SourceLoc(1515026) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - declRef : - name : "<" - originalExpr : null -} -ScopeDecl:58 { - astNodeType : ScopeDecl - loc : SourceLoc(0) - modifiers : { - } - parentDecl : ScopeDecl:42 - nameAndLoc : NameLoc{null, SourceLoc(0) } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - members : { - } - closingSourceLoc : SourceLoc(0) - ownedScope : ::?::reverse-loop::test_simple_loop::?::?::? -} -ExpressionStmt:59 { - astNodeType : ExpressionStmt - loc : SourceLoc(1515052) tests/autodiff/reverse-loop.slang:18 - modifiers : { - } - expression : AssignExpr:70 -} -VarDecl:60 { - astNodeType : VarDecl - loc : SourceLoc(1515206) tests/autodiff/reverse-loop.slang:28 - modifiers : { - } - parentDecl : ScopeDecl:48 - nameAndLoc : NameLoc{"dpa", SourceLoc(1515206) tests/autodiff/reverse-loop.slang:28 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - VarExpr:71, - null - } - initExpr : InvokeExpr:72 - val : null -} -DeclStmt:61 { - astNodeType : DeclStmt - loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 - modifiers : { - } - decl : VarDecl:60 -} -ExpressionStmt:62 { - astNodeType : ExpressionStmt - loc : SourceLoc(1515242) tests/autodiff/reverse-loop.slang:30 - modifiers : { - } - expression : InvokeExpr:73 -} -ExpressionStmt:63 { - astNodeType : ExpressionStmt - loc : SourceLoc(1515292) tests/autodiff/reverse-loop.slang:31 - modifiers : { - } - expression : AssignExpr:74 -} -VarDecl:64 { - astNodeType : VarDecl - loc : SourceLoc(1515365) tests/autodiff/reverse-loop.slang:35 - modifiers : { - } - parentDecl : ScopeDecl:50 - nameAndLoc : NameLoc{"dpa", SourceLoc(1515365) tests/autodiff/reverse-loop.slang:35 } - inferredCapabilityRequirements : capability_set() - markup : null - checkState : DeclCheckStateExt{0, 0} - nextInContainerWithSameName : null - type : { - VarExpr:75, - null - } - initExpr : InvokeExpr:76 - val : null -} -DeclStmt:65 { - astNodeType : DeclStmt - loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 - modifiers : { - } - decl : VarDecl:64 -} -ExpressionStmt:66 { - astNodeType : ExpressionStmt - loc : SourceLoc(1515401) tests/autodiff/reverse-loop.slang:37 - modifiers : { - } - expression : InvokeExpr:77 -} -ExpressionStmt:67 { - astNodeType : ExpressionStmt - loc : SourceLoc(1515451) tests/autodiff/reverse-loop.slang:38 - modifiers : { - } - expression : AssignExpr:78 -} -VarExpr:68 { - astNodeType : VarExpr - loc : SourceLoc(1515013) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - declRef : - name : "int" - originalExpr : null -} -IntegerLiteralExpr:69 { - astNodeType : IntegerLiteralExpr - loc : SourceLoc(1515021) tests/autodiff/reverse-loop.slang:16 - type : rvalue null - token : { integer literal, SourceLoc(1515021) tests/autodiff/reverse-loop.slang:16, "0" } - suffixType : int - value : 0 -} -AssignExpr:70 { - astNodeType : AssignExpr - loc : SourceLoc(1515054) tests/autodiff/reverse-loop.slang:18 - type : rvalue null - left : VarExpr:79 - right : InfixExpr:80 -} -VarExpr:71 { - astNodeType : VarExpr - loc : SourceLoc(1515198) tests/autodiff/reverse-loop.slang:28 - type : rvalue null - declRef : - name : "dpfloat" - originalExpr : null -} -InvokeExpr:72 { - astNodeType : InvokeExpr - loc : SourceLoc(1515219) tests/autodiff/reverse-loop.slang:28 - type : rvalue null - arguments : { - FloatingPointLiteralExpr:81, - FloatingPointLiteralExpr:82 - } - functionExpr : VarExpr:83 - originalFunctionExpr : null - argumentDelimeterLocs : { - SourceLoc(1515219) tests/autodiff/reverse-loop.slang:28, - SourceLoc(1515223) tests/autodiff/reverse-loop.slang:28, - SourceLoc(1515228) tests/autodiff/reverse-loop.slang:28 - } -} -InvokeExpr:73 { - astNodeType : InvokeExpr - loc : SourceLoc(1515270) tests/autodiff/reverse-loop.slang:30 - type : rvalue null - arguments : { - VarExpr:84, - FloatingPointLiteralExpr:85 - } - functionExpr : BackwardDifferentiateExpr:86 - originalFunctionExpr : null - argumentDelimeterLocs : { - SourceLoc(1515270) tests/autodiff/reverse-loop.slang:30, - SourceLoc(1515274) tests/autodiff/reverse-loop.slang:30, - SourceLoc(1515280) tests/autodiff/reverse-loop.slang:30 - } -} -AssignExpr:74 { - astNodeType : AssignExpr - loc : SourceLoc(1515308) tests/autodiff/reverse-loop.slang:31 - type : rvalue null - left : IndexExpr:87 - right : MemberExpr:88 -} -VarExpr:75 { - astNodeType : VarExpr - loc : SourceLoc(1515357) tests/autodiff/reverse-loop.slang:35 - type : rvalue null - declRef : - name : "dpfloat" - originalExpr : null -} -InvokeExpr:76 { - astNodeType : InvokeExpr - loc : SourceLoc(1515378) tests/autodiff/reverse-loop.slang:35 - type : rvalue null - arguments : { - FloatingPointLiteralExpr:89, - FloatingPointLiteralExpr:90 - } - functionExpr : VarExpr:91 - originalFunctionExpr : null - argumentDelimeterLocs : { - SourceLoc(1515378) tests/autodiff/reverse-loop.slang:35, - SourceLoc(1515382) tests/autodiff/reverse-loop.slang:35, - SourceLoc(1515387) tests/autodiff/reverse-loop.slang:35 - } -} -InvokeExpr:77 { - astNodeType : InvokeExpr - loc : SourceLoc(1515429) tests/autodiff/reverse-loop.slang:37 - type : rvalue null - arguments : { - VarExpr:92, - FloatingPointLiteralExpr:93 - } - functionExpr : BackwardDifferentiateExpr:94 - originalFunctionExpr : null - argumentDelimeterLocs : { - SourceLoc(1515429) tests/autodiff/reverse-loop.slang:37, - SourceLoc(1515433) tests/autodiff/reverse-loop.slang:37, - SourceLoc(1515439) tests/autodiff/reverse-loop.slang:37 - } -} -AssignExpr:78 { - astNodeType : AssignExpr - loc : SourceLoc(1515467) tests/autodiff/reverse-loop.slang:38 - type : rvalue null - left : IndexExpr:95 - right : MemberExpr:96 -} -VarExpr:79 { - astNodeType : VarExpr - loc : SourceLoc(1515052) tests/autodiff/reverse-loop.slang:18 - type : rvalue null - declRef : - name : "t" - originalExpr : null -} -InfixExpr:80 { - astNodeType : InfixExpr - loc : SourceLoc(1515058) tests/autodiff/reverse-loop.slang:18 - type : rvalue null - arguments : { - VarExpr:97, - VarExpr:98 - } - functionExpr : VarExpr:99 - originalFunctionExpr : null - argumentDelimeterLocs : { - } -} -FloatingPointLiteralExpr:81 { - astNodeType : FloatingPointLiteralExpr - loc : SourceLoc(1515220) tests/autodiff/reverse-loop.slang:28 - type : rvalue null - token : { floating-point literal, SourceLoc(1515220) tests/autodiff/reverse-loop.slang:28, "1.0" } - suffixType : float - value : 1.0 -} -FloatingPointLiteralExpr:82 { - astNodeType : FloatingPointLiteralExpr - loc : SourceLoc(1515225) tests/autodiff/reverse-loop.slang:28 - type : rvalue null - token : { floating-point literal, SourceLoc(1515225) tests/autodiff/reverse-loop.slang:28, "0.0" } - suffixType : float - value : 0.0 -} -VarExpr:83 { - astNodeType : VarExpr - loc : SourceLoc(1515212) tests/autodiff/reverse-loop.slang:28 - type : rvalue null - declRef : - name : "dpfloat" - originalExpr : null -} -VarExpr:84 { - astNodeType : VarExpr - loc : SourceLoc(1515271) tests/autodiff/reverse-loop.slang:30 - type : rvalue null - declRef : - name : "dpa" - originalExpr : null -} -FloatingPointLiteralExpr:85 { - astNodeType : FloatingPointLiteralExpr - loc : SourceLoc(1515276) tests/autodiff/reverse-loop.slang:30 - type : rvalue null - token : { floating-point literal, SourceLoc(1515276) tests/autodiff/reverse-loop.slang:30, "1.0f" } - suffixType : float - value : 1.0 -} -BackwardDifferentiateExpr:86 { - astNodeType : BackwardDifferentiateExpr - loc : SourceLoc(1515242) tests/autodiff/reverse-loop.slang:30 - type : rvalue null - baseFunction : VarExpr:100 - newParameterNames : { - } -} -IndexExpr:87 { - astNodeType : IndexExpr - loc : SourceLoc(1515304) tests/autodiff/reverse-loop.slang:31 - type : rvalue null - baseExpression : VarExpr:101 - indexExprs : { - IntegerLiteralExpr:102 - } - argumentDelimeterLocs : { - SourceLoc(1515304) tests/autodiff/reverse-loop.slang:31, - SourceLoc(1515306) tests/autodiff/reverse-loop.slang:31 - } -} -MemberExpr:88 { - astNodeType : MemberExpr - loc : SourceLoc(1515314) tests/autodiff/reverse-loop.slang:31 - type : rvalue null - declRef : - name : "d" - originalExpr : null - baseExpression : VarExpr:103 - memberOperatorLoc : SourceLoc(1515313) tests/autodiff/reverse-loop.slang:31 -} -FloatingPointLiteralExpr:89 { - astNodeType : FloatingPointLiteralExpr - loc : SourceLoc(1515379) tests/autodiff/reverse-loop.slang:35 - type : rvalue null - token : { floating-point literal, SourceLoc(1515379) tests/autodiff/reverse-loop.slang:35, "0.4" } - suffixType : float - value : 0.40000000000000002 -} -FloatingPointLiteralExpr:90 { - astNodeType : FloatingPointLiteralExpr - loc : SourceLoc(1515384) tests/autodiff/reverse-loop.slang:35 - type : rvalue null - token : { floating-point literal, SourceLoc(1515384) tests/autodiff/reverse-loop.slang:35, "0.0" } - suffixType : float - value : 0.0 -} -VarExpr:91 { - astNodeType : VarExpr - loc : SourceLoc(1515371) tests/autodiff/reverse-loop.slang:35 - type : rvalue null - declRef : - name : "dpfloat" - originalExpr : null -} -VarExpr:92 { - astNodeType : VarExpr - loc : SourceLoc(1515430) tests/autodiff/reverse-loop.slang:37 - type : rvalue null - declRef : - name : "dpa" - originalExpr : null -} -FloatingPointLiteralExpr:93 { - astNodeType : FloatingPointLiteralExpr - loc : SourceLoc(1515435) tests/autodiff/reverse-loop.slang:37 - type : rvalue null - token : { floating-point literal, SourceLoc(1515435) tests/autodiff/reverse-loop.slang:37, "1.0f" } - suffixType : float - value : 1.0 -} -BackwardDifferentiateExpr:94 { - astNodeType : BackwardDifferentiateExpr - loc : SourceLoc(1515401) tests/autodiff/reverse-loop.slang:37 - type : rvalue null - baseFunction : VarExpr:104 - newParameterNames : { - } -} -IndexExpr:95 { - astNodeType : IndexExpr - loc : SourceLoc(1515463) tests/autodiff/reverse-loop.slang:38 - type : rvalue null - baseExpression : VarExpr:105 - indexExprs : { - IntegerLiteralExpr:106 - } - argumentDelimeterLocs : { - SourceLoc(1515463) tests/autodiff/reverse-loop.slang:38, - SourceLoc(1515465) tests/autodiff/reverse-loop.slang:38 - } -} -MemberExpr:96 { - astNodeType : MemberExpr - loc : SourceLoc(1515473) tests/autodiff/reverse-loop.slang:38 - type : rvalue null - declRef : - name : "d" - originalExpr : null - baseExpression : VarExpr:107 - memberOperatorLoc : SourceLoc(1515472) tests/autodiff/reverse-loop.slang:38 -} -VarExpr:97 { - astNodeType : VarExpr - loc : SourceLoc(1515056) tests/autodiff/reverse-loop.slang:18 - type : rvalue null - declRef : - name : "t" - originalExpr : null -} -VarExpr:98 { - astNodeType : VarExpr - loc : SourceLoc(1515060) tests/autodiff/reverse-loop.slang:18 - type : rvalue null - declRef : - name : "t" - originalExpr : null -} -VarExpr:99 { - astNodeType : VarExpr - loc : SourceLoc(1515058) tests/autodiff/reverse-loop.slang:18 - type : rvalue null - declRef : - name : "*" - originalExpr : null -} -VarExpr:100 { - astNodeType : VarExpr - loc : SourceLoc(1515253) tests/autodiff/reverse-loop.slang:30 - type : rvalue null - declRef : - name : "test_simple_loop" - originalExpr : null -} -VarExpr:101 { - astNodeType : VarExpr - loc : SourceLoc(1515292) tests/autodiff/reverse-loop.slang:31 - type : rvalue null - declRef : - name : "outputBuffer" - originalExpr : null -} -IntegerLiteralExpr:102 { - astNodeType : IntegerLiteralExpr - loc : SourceLoc(1515305) tests/autodiff/reverse-loop.slang:31 - type : rvalue null - token : { integer literal, SourceLoc(1515305) tests/autodiff/reverse-loop.slang:31, "0" } - suffixType : int - value : 0 -} -VarExpr:103 { - astNodeType : VarExpr - loc : SourceLoc(1515310) tests/autodiff/reverse-loop.slang:31 - type : rvalue null - declRef : - name : "dpa" - originalExpr : null -} -VarExpr:104 { - astNodeType : VarExpr - loc : SourceLoc(1515412) tests/autodiff/reverse-loop.slang:37 - type : rvalue null - declRef : - name : "test_simple_loop" - originalExpr : null -} -VarExpr:105 { - astNodeType : VarExpr - loc : SourceLoc(1515451) tests/autodiff/reverse-loop.slang:38 - type : rvalue null - declRef : - name : "outputBuffer" - originalExpr : null -} -IntegerLiteralExpr:106 { - astNodeType : IntegerLiteralExpr - loc : SourceLoc(1515464) tests/autodiff/reverse-loop.slang:38 - type : rvalue null - token : { integer literal, SourceLoc(1515464) tests/autodiff/reverse-loop.slang:38, "1" } - suffixType : int - value : 1 -} -VarExpr:107 { - astNodeType : VarExpr - loc : SourceLoc(1515469) tests/autodiff/reverse-loop.slang:38 - type : rvalue null - declRef : - name : "dpa" - originalExpr : null -} diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 8881deedc5..25263a6520 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -34,6 +34,7 @@ #include "slang-ir-wgsl-legalize.h" #include "slang-ir-insts.h" #include "slang-ir-inline.h" +#include "slang-ir-layout.h" #include "slang-ir-legalize-array-return-type.h" #include "slang-ir-legalize-mesh-outputs.h" #include "slang-ir-legalize-varying-params.h" @@ -1531,6 +1532,48 @@ Result linkAndOptimizeIR( #endif validateIRModuleIfEnabled(codeGenContext, irModule); + EndToEndCompileRequest *compileRequest = codeGenContext->isEndToEndCompile(); + CompilerOptionSet &optionSet = compileRequest->getOptionSet(); + SLANG_ASSERT(compileRequest); + + printf("checking for checkpointing structures:\n"); + for (auto inst : irModule->getGlobalInsts()) { + IRStructType *structType = as(inst); + if (!structType) + continue; + + if (structType->findDecoration()) { + printf("checkpoint intermediate struct\n"); + printf("sourceLocs: %d (%d)\n", + structType->sourceLoc.getRaw(), + structType->sourceLoc.isValid()); + inst->dump(); + + IRSizeAndAlignment sizeInfo; + getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); + printf("size of struct: %d (%d)\n", sizeInfo.size, sizeInfo.alignment); + + sink->diagnose(structType, Diagnostics::alsoSeePipelineDefinition); + + printf("fields:"); + for (auto field : structType->getFields()) { + printf("\tsourceLocs: %d (%d)\n", + field->sourceLoc.getRaw(), + field->sourceLoc.isValid()); + printf("\t"); + field->dump(); + + IRType *fieldType = field->getFieldType(); + printf("field type: %p\n", fieldType); + IRSizeAndAlignment sizeInfo; + getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); + printf("\tsize of struct: %d (%d)\n", sizeInfo.size, sizeInfo.alignment); + + sink->diagnose(field, Diagnostics::alsoSeePipelineDefinition); + } + } + } + if ( (target != CodeGenTarget::SPIRV) && (target != CodeGenTarget::SPIRVAssembly) ) { // We need to perform a final pass to ensure that all the diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp index 9b3e3a324a..6cdef473ce 100644 --- a/source/slang/slang-ir-autodiff-unzip.cpp +++ b/source/slang/slang-ir-autodiff-unzip.cpp @@ -58,6 +58,7 @@ struct ExtractPrimalFuncContext IRBuilder builder(module); builder.setInsertBefore(func); auto intermediateType = builder.createStructType(); + builder.addDecoration(intermediateType, kIROp_CheckpointIntermediateDecoration); if (auto nameHint = func->findDecoration()) { StringBuilder newName; @@ -75,6 +76,7 @@ struct ExtractPrimalFuncContext builder.setInsertBefore(destFunc); IRFuncType* originalFuncType = nullptr; outIntermediateType = createIntermediateType(destFunc); + outIntermediateType->sourceLoc = originalFunc->sourceLoc; GenericChildrenMigrationContext migrationContext; migrationContext.init(as(findOuterGeneric(originalFunc)), as(findOuterGeneric(destFunc)), destFunc); @@ -178,6 +180,10 @@ struct ExtractPrimalFuncContext auto newFuncType = generatePrimalFuncType(unzippedFunc, originalFunc, intermediateType); outIntermediateType = intermediateType; func->setFullType((IRType*)newFuncType); + + printf("in unzipping function:\n"); + printf("createIntermediate type:\n"); + intermediateType->dump(); auto paramBlock = func->getFirstBlock(); builder.setInsertInto(paramBlock); @@ -218,7 +224,12 @@ struct ExtractPrimalFuncContext { if (inst->hasUses()) { + printf("adding field to outIntermediatery\n"); + printf("inst: %d (%d)\n", inst->sourceLoc.getRaw(), inst->sourceLoc.isValid()); + inst->dump(); auto field = addIntermediateContextField(cast(inst->getDataType())->getValueType(), outIntermediary); + field->sourceLoc = inst->sourceLoc; + field->dump(); builder.setInsertBefore(inst); auto fieldAddr = builder.emitFieldAddress( inst->getFullType(), outIntermediary, field->getKey()); diff --git a/source/slang/slang-ir-inst-defs.h b/source/slang/slang-ir-inst-defs.h index b526df3a92..934ad0c82b 100644 --- a/source/slang/slang-ir-inst-defs.h +++ b/source/slang/slang-ir-inst-defs.h @@ -1056,6 +1056,9 @@ INST_RANGE(BindingQuery, GetRegisterIndex, GetRegisterSpace) /// Hint that the result from a call to the decorated function should be recomputed in backward prop function. INST(PreferRecomputeDecoration, PreferRecomputeDecoration, 0, 0) + /// Hint that a struct is used for reverse mode checkpointing + INST(CheckpointIntermediateDecoration, CheckpointIntermediateDecoration, 0, 0) + INST_RANGE(CheckpointHintDecoration, PreferCheckpointDecoration, PreferRecomputeDecoration) /// Marks a function whose return value is never dynamic uniform. diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h index 69f1299862..cb38627bb1 100644 --- a/source/slang/slang-ir-insts.h +++ b/source/slang/slang-ir-insts.h @@ -947,6 +947,14 @@ struct IRPreferCheckpointDecoration : IRCheckpointHintDecoration IR_LEAF_ISA(PreferCheckpointDecoration) }; +struct IRCheckpointIntermediateDecoration : IRCheckpointHintDecoration +{ + enum + { + kOp = kIROp_CheckpointIntermediateDecoration + }; + IR_LEAF_ISA(CheckpointIntermediateDecoration) +}; struct IRLoopCounterDecoration : IRDecoration { diff --git a/tests/modules/ad-report b/tests/modules/ad-report new file mode 100644 index 0000000000..e197cbb89d --- /dev/null +++ b/tests/modules/ad-report @@ -0,0 +1 @@ +(0): error 1: cannot open file 'tests/autodiff/reverse-loop.slang'. From 95eb9dfd1baaa00dcc6832dca3c2feac9a7242ba Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 9 Sep 2024 13:53:30 -0700 Subject: [PATCH 05/32] More readable output format --- ad-report | 3263 +++++++++-------- out.glsl | 121 +- .../compiler-core/slang-diagnostic-sink.cpp | 2 +- source/compiler-core/slang-diagnostic-sink.h | 2 + source/slang/slang-emit.cpp | 54 +- source/slang/slang-ir-autodiff-unzip.cpp | 8 +- source/slang/slang-ir-inst-defs.h | 2 +- source/slang/slang-ir-insts.h | 7 + 8 files changed, 1815 insertions(+), 1644 deletions(-) diff --git a/ad-report b/ad-report index 37861bb975..77ad2fbaef 100644 --- a/ad-report +++ b/ad-report @@ -3,281 +3,295 @@ undefined let %1 : Void = no_diff let %2 : witness_table_t(%IDifferentiable) = lookupWitness(%3, %4) let %3 : witness_table_t(%IFloat) = lookupWitness(%5, %6) -let %7 : CapabilitySet = capabilityDisjunction(%8, %9, %10, %11, %12, %13, %14, %15, %16, %17, %18, %19, %20, %21, %22, %23, %24, %25, %26, %27, %28, %29, %30, %31, %32, %33, %34, %35, %36, %37, %38, %39, %40, %41, %42, %43, %44, %45, %46, %47, %48, %49, %50, %51, %52, %53, %54, %55, %56, %57, %58, %59, %60, %61, %62, %63, %64, %65, %66, %67, %68, %69, %70, %71, %72, %73, %74, %75, %76, %77, %78, %79, %80, %81, %82, %83, %84, %85, %86, %87, %88, %89, %90, %91, %92, %93, %94, %95, %96, %97, %98, %99, %100, %101, %102, %103, %104, %105) -let %105 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 74 : Int) -let %104 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 73 : Int) -let %103 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 72 : Int) -let %102 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 71 : Int) -let %101 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 70 : Int) -let %100 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 69 : Int) -let %99 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 68 : Int) -let %98 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 67 : Int) -let %97 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 66 : Int) -let %96 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 65 : Int) -let %95 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 64 : Int) -let %94 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 63 : Int) -let %93 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 62 : Int) -let %92 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 61 : Int) -let %91 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 74 : Int) -let %90 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 73 : Int) -let %89 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 72 : Int) -let %88 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 71 : Int) -let %87 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 70 : Int) -let %86 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 69 : Int) -let %85 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 68 : Int) -let %84 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 67 : Int) -let %83 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 66 : Int) -let %82 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 65 : Int) -let %81 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 64 : Int) -let %80 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 63 : Int) -let %79 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 62 : Int) -let %78 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 61 : Int) -let %77 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 74 : Int) -let %76 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 73 : Int) -let %75 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 72 : Int) -let %74 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 71 : Int) -let %73 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 70 : Int) -let %72 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 69 : Int) -let %71 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 68 : Int) -let %70 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 67 : Int) -let %69 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 66 : Int) -let %68 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 65 : Int) -let %67 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 64 : Int) -let %66 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 63 : Int) -let %65 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 62 : Int) -let %64 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 61 : Int) -let %63 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 74 : Int) -let %62 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 73 : Int) -let %61 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 72 : Int) -let %60 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 71 : Int) -let %59 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 70 : Int) -let %58 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 69 : Int) -let %57 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 68 : Int) -let %56 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 67 : Int) -let %55 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 66 : Int) -let %54 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 65 : Int) -let %53 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 64 : Int) -let %52 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 63 : Int) -let %51 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 62 : Int) -let %50 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 61 : Int) -let %49 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 74 : Int) -let %48 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 73 : Int) -let %47 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 72 : Int) -let %46 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 71 : Int) -let %45 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 70 : Int) -let %44 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 69 : Int) -let %43 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 68 : Int) -let %42 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 67 : Int) -let %41 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 66 : Int) -let %40 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 65 : Int) -let %39 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 64 : Int) -let %38 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 63 : Int) -let %37 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 62 : Int) -let %36 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 61 : Int) -let %35 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 74 : Int) -let %34 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 73 : Int) -let %33 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 72 : Int) -let %32 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 71 : Int) -let %31 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 70 : Int) -let %30 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 69 : Int) -let %29 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 68 : Int) -let %28 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 67 : Int) -let %27 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 66 : Int) -let %26 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 65 : Int) -let %25 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 64 : Int) -let %24 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 63 : Int) -let %23 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 62 : Int) -let %22 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 61 : Int) -let %21 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 74 : Int) -let %20 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 73 : Int) -let %19 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 72 : Int) -let %18 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 71 : Int) -let %17 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 70 : Int) -let %16 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 69 : Int) -let %15 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 68 : Int) -let %14 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 67 : Int) -let %13 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 66 : Int) -let %12 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 65 : Int) -let %11 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 64 : Int) -let %10 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 63 : Int) -let %9 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 62 : Int) -let %8 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 61 : Int) +let %7 : CapabilitySet = capabilityDisjunction(%8, %9, %10, %11, %12, %13, %14, %15, %16, %17, %18, %19, %20, %21, %22, %23, %24, %25, %26, %27, %28, %29, %30, %31, %32, %33, %34, %35, %36, %37, %38, %39, %40, %41, %42, %43, %44, %45, %46, %47, %48, %49, %50, %51, %52, %53, %54, %55, %56, %57, %58, %59, %60, %61, %62, %63, %64, %65, %66, %67, %68, %69, %70, %71, %72, %73, %74, %75, %76, %77, %78, %79, %80, %81, %82, %83, %84, %85, %86, %87, %88, %89, %90, %91, %92, %93, %94, %95, %96, %97, %98, %99, %100, %101, %102, %103, %104, %105, %106, %107, %108, %109, %110, %111, %112, %113, %114, %115, %116, %117, %118, %119) +let %119 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 75 : Int) +let %118 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 74 : Int) +let %117 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 73 : Int) +let %116 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 72 : Int) +let %115 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 71 : Int) +let %114 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 70 : Int) +let %113 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 69 : Int) +let %112 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 68 : Int) +let %111 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 67 : Int) +let %110 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 66 : Int) +let %109 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 65 : Int) +let %108 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 64 : Int) +let %107 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 63 : Int) +let %106 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 62 : Int) +let %105 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 75 : Int) +let %104 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 74 : Int) +let %103 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 73 : Int) +let %102 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 72 : Int) +let %101 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 71 : Int) +let %100 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 70 : Int) +let %99 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 69 : Int) +let %98 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 68 : Int) +let %97 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 67 : Int) +let %96 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 66 : Int) +let %95 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 65 : Int) +let %94 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 64 : Int) +let %93 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 63 : Int) +let %92 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 62 : Int) +let %91 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 75 : Int) +let %90 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 74 : Int) +let %89 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 73 : Int) +let %88 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 72 : Int) +let %87 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 71 : Int) +let %86 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 70 : Int) +let %85 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 69 : Int) +let %84 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 68 : Int) +let %83 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 67 : Int) +let %82 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 66 : Int) +let %81 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 65 : Int) +let %80 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 64 : Int) +let %79 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 63 : Int) +let %78 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 62 : Int) +let %77 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 75 : Int) +let %76 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 74 : Int) +let %75 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 73 : Int) +let %74 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 72 : Int) +let %73 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 71 : Int) +let %72 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 70 : Int) +let %71 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 69 : Int) +let %70 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 68 : Int) +let %69 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 67 : Int) +let %68 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 66 : Int) +let %67 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 65 : Int) +let %66 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 64 : Int) +let %65 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 63 : Int) +let %64 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 62 : Int) +let %63 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 75 : Int) +let %62 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 74 : Int) +let %61 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 73 : Int) +let %60 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 72 : Int) +let %59 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 71 : Int) +let %58 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 70 : Int) +let %57 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 69 : Int) +let %56 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 68 : Int) +let %55 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 67 : Int) +let %54 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 66 : Int) +let %53 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 65 : Int) +let %52 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 64 : Int) +let %51 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 63 : Int) +let %50 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 62 : Int) +let %49 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 75 : Int) +let %48 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 74 : Int) +let %47 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 73 : Int) +let %46 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 72 : Int) +let %45 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 71 : Int) +let %44 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 70 : Int) +let %43 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 69 : Int) +let %42 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 68 : Int) +let %41 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 67 : Int) +let %40 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 66 : Int) +let %39 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 65 : Int) +let %38 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 64 : Int) +let %37 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 63 : Int) +let %36 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 62 : Int) +let %35 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 75 : Int) +let %34 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 74 : Int) +let %33 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 73 : Int) +let %32 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 72 : Int) +let %31 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 71 : Int) +let %30 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 70 : Int) +let %29 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 69 : Int) +let %28 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 68 : Int) +let %27 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 67 : Int) +let %26 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 66 : Int) +let %25 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 65 : Int) +let %24 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 64 : Int) +let %23 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 63 : Int) +let %22 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 62 : Int) +let %21 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 75 : Int) +let %20 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 74 : Int) +let %19 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 73 : Int) +let %18 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 72 : Int) +let %17 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 71 : Int) +let %16 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 70 : Int) +let %15 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 69 : Int) +let %14 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 68 : Int) +let %13 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 67 : Int) +let %12 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 66 : Int) +let %11 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 65 : Int) +let %10 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 64 : Int) +let %9 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 63 : Int) +let %8 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 62 : Int) let %5 : witness_table_t(%x5Fx5FBuiltinFloatingPointType) = thisTypeWitness -let %106 : _ = interface_req_entry(%107, witness_table_t(%x5Fx5FBuiltinRealType)) -let %108 : _ = interface_req_entry(%6, witness_table_t(%IFloat)) -let %109 : _ = interface_req_entry(%110, Func(this_type(%x5Fx5FBuiltinFloatingPointType))) -let %111 : _ = interface_req_entry(%112, Func(DiffPairUserCode(this_type(%x5Fx5FBuiltinFloatingPointType), %2))) -let %113 : _ = interface_req_entry(%114, Func(Void, associated_type(%IDifferentiable))) +let %120 : _ = interface_req_entry(%121, witness_table_t(%x5Fx5FBuiltinRealType)) +let %122 : _ = interface_req_entry(%6, witness_table_t(%IFloat)) +let %123 : _ = interface_req_entry(%124, Func(this_type(%x5Fx5FBuiltinFloatingPointType))) +let %125 : _ = interface_req_entry(%126, Func(DiffPairUserCode(this_type(%x5Fx5FBuiltinFloatingPointType), %2))) +let %127 : _ = interface_req_entry(%128, Func(Void, associated_type(%IDifferentiable))) [treatAsDifferentiableDecoration] [BuiltinDecoration] [import("_ST4core26__BuiltinFloatingPointType")] [nameHint("__BuiltinFloatingPointType")] -let %x5Fx5FBuiltinFloatingPointType : Type = interface(%106, %108, %109, %111, %113) +let %x5Fx5FBuiltinFloatingPointType : Type = interface(%120, %122, %123, %125, %127) [import("_S4core26__BuiltinFloatingPointTypeI4core17__BuiltinRealType")] -let %107 : _ = key -let %115 : _ = interface_req_entry(%116, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) +let %121 : _ = key +let %129 : _ = interface_req_entry(%130, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) [BuiltinDecoration] [import("_ST4core17__BuiltinRealType")] [nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%115) +let %x5Fx5FBuiltinRealType : Type = interface(%129) [import("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %116 : _ = key -let %117 : _ = interface_req_entry(%118, witness_table_t(%x5Fx5FBuiltinArithmeticType)) +let %130 : _ = key +let %131 : _ = interface_req_entry(%132, witness_table_t(%x5Fx5FBuiltinArithmeticType)) [BuiltinDecoration] [import("_ST4core29__BuiltinSignedArithmeticType")] [nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%117) +let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%131) [import("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %118 : _ = key -let %119 : _ = interface_req_entry(%120, witness_table_t(%x5Fx5FBuiltinType)) -let %121 : _ = interface_req_entry(%122, witness_table_t(%IArithmetic)) +let %132 : _ = key +let %133 : _ = interface_req_entry(%134, witness_table_t(%x5Fx5FBuiltinType)) +let %135 : _ = interface_req_entry(%136, witness_table_t(%IArithmetic)) [BuiltinDecoration] [import("_ST4core23__BuiltinArithmeticType")] [nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%119, %121) +let %x5Fx5FBuiltinArithmeticType : Type = interface(%133, %135) [import("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %120 : _ = key +let %134 : _ = key [BuiltinDecoration] [import("_ST4core13__BuiltinType")] [nameHint("__BuiltinType")] let %x5Fx5FBuiltinType : Type = interface [import("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %122 : _ = key -let %123 : _ = interface_req_entry(%124, witness_table_t(%IComparable)) -let %125 : _ = interface_req_entry(%126, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %127 : _ = interface_req_entry(%128, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %129 : _ = interface_req_entry(%130, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %131 : _ = interface_req_entry(%132, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %133 : _ = interface_req_entry(%134, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %135 : _ = interface_req_entry(%136, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -let %137 : _ = interface_req_entry(%138, Func(this_type(%IArithmetic), Int)) -let %139 : _ = interface_req_entry(%140, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +let %136 : _ = key +let %137 : _ = interface_req_entry(%138, witness_table_t(%IComparable)) +let %139 : _ = interface_req_entry(%140, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %141 : _ = interface_req_entry(%142, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %143 : _ = interface_req_entry(%144, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %145 : _ = interface_req_entry(%146, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %147 : _ = interface_req_entry(%148, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) +let %149 : _ = interface_req_entry(%150, Func(this_type(%IArithmetic), this_type(%IArithmetic))) +let %151 : _ = interface_req_entry(%152, Func(this_type(%IArithmetic), Int)) +let %153 : _ = interface_req_entry(%154, Func(this_type(%IArithmetic), this_type(%IArithmetic))) [import("_ST4core11IArithmetic")] [nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%123, %125, %127, %129, %131, %133, %135, %137, %139) +let %IArithmetic : Type = interface(%137, %139, %141, %143, %145, %147, %149, %151, %153) [import("_S4core11IArithmeticI4core11IComparable")] -let %124 : _ = key -let %141 : _ = interface_req_entry(%142, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -let %143 : _ = interface_req_entry(%144, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -let %145 : _ = interface_req_entry(%146, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +let %138 : _ = key +let %155 : _ = interface_req_entry(%156, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +let %157 : _ = interface_req_entry(%158, Func(Bool, this_type(%IComparable), this_type(%IComparable))) +let %159 : _ = interface_req_entry(%160, Func(Bool, this_type(%IComparable), this_type(%IComparable))) [import("_ST4core11IComparable")] [nameHint("IComparable")] -let %IComparable : Type = interface(%141, %143, %145) +let %IComparable : Type = interface(%155, %157, %159) [import("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %142 : _ = key +let %156 : _ = key [import("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %144 : _ = key +let %158 : _ = key [import("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %146 : _ = key +let %160 : _ = key [import("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %126 : _ = key +let %140 : _ = key [import("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %128 : _ = key +let %142 : _ = key [import("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %130 : _ = key +let %144 : _ = key [import("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %132 : _ = key +let %146 : _ = key [import("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %134 : _ = key +let %148 : _ = key [import("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %136 : _ = key +let %150 : _ = key [import("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %138 : _ = key +let %152 : _ = key [import("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %140 : _ = key +let %154 : _ = key [import("_S4core26__BuiltinFloatingPointTypeI4core6IFloat")] let %6 : _ = key -let %147 : _ = interface_req_entry(%148, witness_table_t(%IArithmetic)) -let %149 : _ = interface_req_entry(%4, witness_table_t(%IDifferentiable)) -let %150 : _ = interface_req_entry(%151, Func(this_type(%IFloat), Float)) -let %152 : _ = interface_req_entry(%153, Func(Float, this_type(%IFloat))) -let %154 : _ = interface_req_entry(%155, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %156 : _ = interface_req_entry(%157, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %158 : _ = interface_req_entry(%159, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %160 : _ = interface_req_entry(%161, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %162 : _ = interface_req_entry(%163, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %164 : _ = interface_req_entry(%165, Func(this_type(%IFloat), this_type(%IFloat))) -let %166 : _ = interface_req_entry(%167, Func(this_type(%IFloat), this_type(%IFloat))) -let %168 : _ = interface_req_entry(%169, %170) +let %161 : _ = interface_req_entry(%162, witness_table_t(%IArithmetic)) +let %163 : _ = interface_req_entry(%4, witness_table_t(%IDifferentiable)) +let %164 : _ = interface_req_entry(%165, Func(this_type(%IFloat), Float)) +let %166 : _ = interface_req_entry(%167, Func(Float, this_type(%IFloat))) +let %168 : _ = interface_req_entry(%169, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %170 : _ = interface_req_entry(%171, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %172 : _ = interface_req_entry(%173, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %174 : _ = interface_req_entry(%175, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %176 : _ = interface_req_entry(%177, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) +let %178 : _ = interface_req_entry(%179, Func(this_type(%IFloat), this_type(%IFloat))) +let %180 : _ = interface_req_entry(%181, Func(this_type(%IFloat), this_type(%IFloat))) +let %182 : _ = interface_req_entry(%183, %184) [import("_ST4core6IFloat")] [nameHint("IFloat")] -let %IFloat : Type = interface(%147, %149, %150, %152, %154, %156, %158, %160, %162, %164, %166, %168) +let %IFloat : Type = interface(%161, %163, %164, %166, %168, %170, %172, %174, %176, %178, %180, %182) [import("_S4core6IFloatI4core11IArithmetic")] -let %148 : _ = key +let %162 : _ = key [import("_S4core6IFloatI4core15IDifferentiable")] let %4 : _ = key -let %171 : _ = interface_req_entry(%172, associated_type(%IDifferentiable)) -let %173 : _ = interface_req_entry(%174, witness_table_t(%IDifferentiable)) -let %175 : _ = interface_req_entry(%176, Func(associated_type(%IDifferentiable))) -let %177 : _ = interface_req_entry(%178, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -let %179 : _ = interface_req_entry(%180, %181) +let %185 : _ = interface_req_entry(%186, associated_type(%IDifferentiable)) +let %187 : _ = interface_req_entry(%188, witness_table_t(%IDifferentiable)) +let %189 : _ = interface_req_entry(%190, Func(associated_type(%IDifferentiable))) +let %191 : _ = interface_req_entry(%192, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) +let %193 : _ = interface_req_entry(%194, %195) [import("_ST4core15IDifferentiable")] [nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%171, %173, %175, %177, %179) +let %IDifferentiable : Type = interface(%185, %187, %189, %191, %193) [import("_ST4core15IDifferentiable12Differential")] -let %172 : _ = key +let %186 : _ = key [import("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %174 : _ = key +let %188 : _ = key [StaticRequirementDecoration] [import("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %176 : _ = key +let %190 : _ = key [StaticRequirementDecoration] [import("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %178 : _ = key +let %192 : _ = key [StaticRequirementDecoration] [import("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %180 : _ = key -generic %181 : Generic +let %194 : _ = key +generic %195 : Generic { -block %182( +block %196( [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] [nameHint("IDifferentiable.T")] param %IDifferentiablex5FT : type_t, - param %183 : witness_table_t(%x5Fx5FBuiltinRealType)): + param %197 : witness_table_t(%x5Fx5FBuiltinRealType)): return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) } [import("_S4core6IFloatR8_24xinitp1pi_f")] -let %151 : _ = key +let %165 : _ = key [import("_S4core6IFloat7toFloatp0pf")] -let %153 : _ = key +let %167 : _ = key [import("_S4core6IFloat3addp1pi_4core6IFloat4This4core6IFloat4This")] -let %155 : _ = key +let %169 : _ = key [import("_S4core6IFloat3subp1pi_4core6IFloat4This4core6IFloat4This")] -let %157 : _ = key +let %171 : _ = key [import("_S4core6IFloat3mulp1pi_4core6IFloat4This4core6IFloat4This")] -let %159 : _ = key +let %173 : _ = key [import("_S4core6IFloat3divp1pi_4core6IFloat4This4core6IFloat4This")] -let %161 : _ = key +let %175 : _ = key [import("_S4core6IFloat3modp1pi_4core6IFloat4This4core6IFloat4This")] -let %163 : _ = key +let %177 : _ = key [import("_S4core6IFloat3negp0p4core6IFloat4This")] -let %165 : _ = key +let %179 : _ = key [import("_S4core6IFloatR8_24xinitp1pi_4core6IFloat4This")] -let %167 : _ = key +let %181 : _ = key [import("_S4core6IFloat5scaleg2TC4core6IFloat1T4core26__BuiltinFloatingPointTypep1pi_4core6IFloat1T4core6IFloat4This")] -let %169 : _ = key -generic %170 : Generic +let %183 : _ = key +generic %184 : Generic { -block %184( +block %198( [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] [nameHint("IFloat.T")] param %IFloatx5FT : type_t, - param %185 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): + param %199 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): return_val(Func(this_type(%IFloat), this_type(%IFloat), %IFloatx5FT)) } -[backwardDiffReference(%114)] -[fwdDerivative(%112)] +[backwardDiffReference(%128)] +[fwdDerivative(%126)] [StaticRequirementDecoration] [import("_S4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] -let %110 : _ = key +let %124 : _ = key [StaticRequirementDecoration] [import("_SFwdReq_4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] -let %112 : _ = key +let %126 : _ = key [StaticRequirementDecoration] [import("_SBwdReq_4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] -let %114 : _ = key +let %128 : _ = key [export("_SWf4core13__BuiltinType")] -witness_table %186 : witness_table_t(%x5Fx5FBuiltinType)(Float); +witness_table %200 : witness_table_t(%x5Fx5FBuiltinType)(Float); [intrinsicOp(272 : Int)] [method] @@ -298,13 +312,13 @@ func %floatx5FlessThan : Func(Bool, Float, Float); func %floatx5FlessThanOrEquals : Func(Bool, Float, Float); [export("_SWf4core11IComparable")] -witness_table %187 : witness_table_t(%IComparable)(Float) +witness_table %201 : witness_table_t(%IComparable)(Float) { - witness_table_entry(%142,%floatx5Fequals) + witness_table_entry(%156,%floatx5Fequals) - witness_table_entry(%144,%floatx5FlessThan) + witness_table_entry(%158,%floatx5FlessThan) - witness_table_entry(%146,%floatx5FlessThanOrEquals) + witness_table_entry(%160,%floatx5FlessThanOrEquals) } @@ -358,82 +372,82 @@ func %floatx5Fx24init : Func(Float, Int); func %floatx5Fx24init1 : Func(Float, Float); [export("_SWf4core11IArithmetic")] -witness_table %188 : witness_table_t(%IArithmetic)(Float) +witness_table %202 : witness_table_t(%IArithmetic)(Float) { - witness_table_entry(%124,%187) + witness_table_entry(%138,%201) - witness_table_entry(%126,%floatx5Fadd) + witness_table_entry(%140,%floatx5Fadd) - witness_table_entry(%128,%floatx5Fsub) + witness_table_entry(%142,%floatx5Fsub) - witness_table_entry(%130,%floatx5Fmul) + witness_table_entry(%144,%floatx5Fmul) - witness_table_entry(%132,%floatx5Fdiv) + witness_table_entry(%146,%floatx5Fdiv) - witness_table_entry(%134,%floatx5Fmod) + witness_table_entry(%148,%floatx5Fmod) - witness_table_entry(%136,%floatx5Fneg) + witness_table_entry(%150,%floatx5Fneg) - witness_table_entry(%138,%floatx5Fx24init) + witness_table_entry(%152,%floatx5Fx24init) - witness_table_entry(%140,%floatx5Fx24init1) + witness_table_entry(%154,%floatx5Fx24init1) } [export("_SWf4core23__BuiltinArithmeticType")] -witness_table %189 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Float) +witness_table %203 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Float) { - witness_table_entry(%120,%186) + witness_table_entry(%134,%200) - witness_table_entry(%122,%188) + witness_table_entry(%136,%202) } [export("_SWf4core29__BuiltinSignedArithmeticType")] -witness_table %190 : witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)(Float) +witness_table %204 : witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)(Float) { - witness_table_entry(%118,%189) + witness_table_entry(%132,%203) } [export("_SWf4core17__BuiltinRealType")] -witness_table %191 : witness_table_t(%x5Fx5FBuiltinRealType)(Float) +witness_table %205 : witness_table_t(%x5Fx5FBuiltinRealType)(Float) { - witness_table_entry(%116,%190) + witness_table_entry(%130,%204) } [export("_SWf4core11IComparable")] -witness_table %192 : witness_table_t(%IComparable)(Float) +witness_table %206 : witness_table_t(%IComparable)(Float) { - witness_table_entry(%142,%floatx5Fequals) + witness_table_entry(%156,%floatx5Fequals) - witness_table_entry(%144,%floatx5FlessThan) + witness_table_entry(%158,%floatx5FlessThan) - witness_table_entry(%146,%floatx5FlessThanOrEquals) + witness_table_entry(%160,%floatx5FlessThanOrEquals) } [export("_SWf4core11IArithmetic")] -witness_table %193 : witness_table_t(%IArithmetic)(Float) +witness_table %207 : witness_table_t(%IArithmetic)(Float) { - witness_table_entry(%124,%192) + witness_table_entry(%138,%206) - witness_table_entry(%126,%floatx5Fadd) + witness_table_entry(%140,%floatx5Fadd) - witness_table_entry(%128,%floatx5Fsub) + witness_table_entry(%142,%floatx5Fsub) - witness_table_entry(%130,%floatx5Fmul) + witness_table_entry(%144,%floatx5Fmul) - witness_table_entry(%132,%floatx5Fdiv) + witness_table_entry(%146,%floatx5Fdiv) - witness_table_entry(%134,%floatx5Fmod) + witness_table_entry(%148,%floatx5Fmod) - witness_table_entry(%136,%floatx5Fneg) + witness_table_entry(%150,%floatx5Fneg) - witness_table_entry(%138,%floatx5Fx24init) + witness_table_entry(%152,%floatx5Fx24init) - witness_table_entry(%140,%floatx5Fx24init1) + witness_table_entry(%154,%floatx5Fx24init1) } @@ -445,7 +459,7 @@ witness_table %193 : witness_table_t(%IArithmetic)(Float) [nameHint("float.dzero")] func %floatx5Fdzero : Func(Float) { -block %194: +block %208: return_val(0 : Float) } [DifferentiableTypeDictionaryDecoration] @@ -456,60 +470,60 @@ block %194: [nameHint("float.dadd")] func %floatx5Fdadd : Func(Float, Float, Float) { -block %195( +block %209( [nameHint("a")] param %a : Float, [nameHint("b")] param %b : Float): - let %196 : Float = add(%a, %b) - return_val(%196) + let %210 : Float = add(%a, %b) + return_val(%210) } -generic %197 : Generic +generic %211 : Generic { -block %198( +block %212( [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] [nameHint("float.U")] param %floatx5FU : type_t, - param %199 : witness_table_t(%x5Fx5FBuiltinRealType)): + param %213 : witness_table_t(%x5Fx5FBuiltinRealType)): return_val(Func(Float, Attributed(%floatx5FU, %1), Float)) } [import("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %200 : %197 +generic %214 : %211 { -block %201( +block %215( [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] [nameHint("float.U")] param %floatx5FU1 : type_t, - param %202 : witness_table_t(%x5Fx5FBuiltinRealType)): + param %216 : witness_table_t(%x5Fx5FBuiltinRealType)): [DifferentiableTypeDictionaryDecoration] [backwardDifferentiable] [unsafeForceInlineEarly] [nameHint("float.dmul")] func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %1), Float) { -block %203( +block %217( [nameHint("a")] param %a1 : Attributed(%floatx5FU1, %1), [nameHint("b")] param %b1 : Float): - let %204 : Float = floatCast(%a1) - let %205 : Float = mul(%204, %b1) - return_val(%205) + let %218 : Float = floatCast(%a1) + let %219 : Float = mul(%218, %b1) + return_val(%219) } return_val(%floatx5Fdmul) } [export("_SWf4core15IDifferentiable")] -witness_table %206 : witness_table_t(%IDifferentiable)(Float) +witness_table %220 : witness_table_t(%IDifferentiable)(Float) { - witness_table_entry(%172,Float) + witness_table_entry(%186,Float) - witness_table_entry(%174,%206) + witness_table_entry(%188,%220) - witness_table_entry(%176,%floatx5Fdzero) + witness_table_entry(%190,%floatx5Fdzero) - witness_table_entry(%178,%floatx5Fdadd) + witness_table_entry(%192,%floatx5Fdadd) - witness_table_entry(%180,%200) + witness_table_entry(%194,%214) } @@ -519,23 +533,23 @@ witness_table %206 : witness_table_t(%IDifferentiable)(Float) [nameHint("float.toFloat")] func %floatx5FtoFloat : Func(Float, Float); -generic %207 : Generic +generic %221 : Generic { -block %208( +block %222( [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] [nameHint("float.T")] param %floatx5FT : type_t, - param %209 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): + param %223 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): return_val(Func(Float, Float, %floatx5FT)) } [import("_S4core5float5scaleg2TC4core5float1T4core26__BuiltinFloatingPointTypep1pi_4core5float1Tf")] -generic %210 : %207 +generic %224 : %221 { -block %211( +block %225( [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] [nameHint("float.T")] param %floatx5FT1 : type_t, - param %212 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): + param %226 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): [intrinsicOp(266 : Int)] [nameHint("float.scale")] func %floatx5Fscale : Func(Float, Float, %floatx5FT1); @@ -543,36 +557,36 @@ block %211( return_val(%floatx5Fscale) } [export("_SWf4core6IFloat")] -witness_table %213 : witness_table_t(%IFloat)(Float) +witness_table %227 : witness_table_t(%IFloat)(Float) { - witness_table_entry(%148,%193) + witness_table_entry(%162,%207) - witness_table_entry(%4,%206) + witness_table_entry(%4,%220) - witness_table_entry(%151,%floatx5Fx24init1) + witness_table_entry(%165,%floatx5Fx24init1) - witness_table_entry(%153,%floatx5FtoFloat) + witness_table_entry(%167,%floatx5FtoFloat) - witness_table_entry(%155,%floatx5Fadd) + witness_table_entry(%169,%floatx5Fadd) - witness_table_entry(%157,%floatx5Fsub) + witness_table_entry(%171,%floatx5Fsub) - witness_table_entry(%159,%floatx5Fmul) + witness_table_entry(%173,%floatx5Fmul) - witness_table_entry(%161,%floatx5Fdiv) + witness_table_entry(%175,%floatx5Fdiv) - witness_table_entry(%163,%floatx5Fmod) + witness_table_entry(%177,%floatx5Fmod) - witness_table_entry(%165,%floatx5Fneg) + witness_table_entry(%179,%floatx5Fneg) - witness_table_entry(%167,%floatx5Fx24init1) + witness_table_entry(%181,%floatx5Fx24init1) - witness_table_entry(%169,%210) + witness_table_entry(%183,%224) } [export("_SWi4core13__BuiltinType")] -witness_table %214 : witness_table_t(%x5Fx5FBuiltinType)(Int); +witness_table %228 : witness_table_t(%x5Fx5FBuiltinType)(Int); [intrinsicOp(272 : Int)] [method] @@ -593,13 +607,13 @@ func %intx5FlessThan : Func(Bool, Int, Int); func %intx5FlessThanOrEquals : Func(Bool, Int, Int); [export("_SWi4core11IComparable")] -witness_table %215 : witness_table_t(%IComparable)(Int) +witness_table %229 : witness_table_t(%IComparable)(Int) { - witness_table_entry(%142,%intx5Fequals) + witness_table_entry(%156,%intx5Fequals) - witness_table_entry(%144,%intx5FlessThan) + witness_table_entry(%158,%intx5FlessThan) - witness_table_entry(%146,%intx5FlessThanOrEquals) + witness_table_entry(%160,%intx5FlessThanOrEquals) } @@ -627,7 +641,7 @@ func %intx5Fmul : Func(Int, Int, Int); [nameHint("int.div")] func %intx5Fdiv : Func(Int, Int, Int); -[intrinsicOp(269 : Int)] +[intrinsicOp(268 : Int)] [method] [import("_S4core3int3modp1pi_ii")] [nameHint("int.mod")] @@ -646,34 +660,34 @@ func %intx5Fneg : Func(Int, Int); func %intx5Fx24init : Func(Int, Int); [export("_SWi4core11IArithmetic")] -witness_table %216 : witness_table_t(%IArithmetic)(Int) +witness_table %230 : witness_table_t(%IArithmetic)(Int) { - witness_table_entry(%124,%215) + witness_table_entry(%138,%229) - witness_table_entry(%126,%intx5Fadd) + witness_table_entry(%140,%intx5Fadd) - witness_table_entry(%128,%intx5Fsub) + witness_table_entry(%142,%intx5Fsub) - witness_table_entry(%130,%intx5Fmul) + witness_table_entry(%144,%intx5Fmul) - witness_table_entry(%132,%intx5Fdiv) + witness_table_entry(%146,%intx5Fdiv) - witness_table_entry(%134,%intx5Fmod) + witness_table_entry(%148,%intx5Fmod) - witness_table_entry(%136,%intx5Fneg) + witness_table_entry(%150,%intx5Fneg) - witness_table_entry(%138,%intx5Fx24init) + witness_table_entry(%152,%intx5Fx24init) - witness_table_entry(%140,%intx5Fx24init) + witness_table_entry(%154,%intx5Fx24init) } [export("_SWi4core23__BuiltinArithmeticType")] -witness_table %217 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Int) +witness_table %231 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Int) { - witness_table_entry(%120,%214) + witness_table_entry(%134,%228) - witness_table_entry(%122,%216) + witness_table_entry(%136,%230) } @@ -683,70 +697,70 @@ witness_table %217 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Int) [nameHint("test_simple_loop")] func %testx5Fsimplex5Floop : Func(Float, Float) { -block %218( +block %232( [nameHint("y")] param %y : Float): [loopMaxIters(3 : Int)] - loop(%219, %220, %221, %y, 0 : Int) + loop(%233, %234, %235, %y, 0 : Int) -block %219( +block %233( [nameHint("t")] param %t : Float, [nameHint("i")] param %i : Int): - let %222 : Bool = cmpLT(%i, 3 : Int) - ifElse(%222, %223, %220, %223) + let %236 : Bool = cmpLT(%i, 3 : Int) + ifElse(%236, %237, %234, %237) -block %223: - let %224 : Float = mul(%t, %t) - unconditionalBranch(%221) +block %237: + let %238 : Float = mul(%t, %t) + unconditionalBranch(%235) -block %221: - let %225 : Int = add(%i, 1 : Int) - unconditionalBranch(%219, %224, %225) +block %235: + let %239 : Int = add(%i, 1 : Int) + unconditionalBranch(%233, %238, %239) -block %220: +block %234: return_val(%t) } [import("_ST4core17IBufferDataLayout")] [nameHint("IBufferDataLayout")] let %IBufferDataLayout : Type = interface [import("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %226 : witness_table_t(%IBufferDataLayout)(DefaultLayout); +witness_table %240 : witness_table_t(%IBufferDataLayout)(DefaultLayout); [nameHint("outputBuffer")] [export("_SVR15reverse_2Dxloop12outputBuffer")] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %226) = global_param +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %240) = global_param [entryPoint(6 : Int, "computeMain", "reverse-loop")] [numThreads(1 : Int, 1 : Int, 1 : Int)] [export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] [nameHint("computeMain")] func %computeMain : Func(Void, Vec(UInt, 3 : Int)) { -block %227( +block %241( [nameHint("dispatchThreadID")] [semantic("SV_DispatchThreadID", 0 : Int)] param %dispatchThreadID : Vec(UInt, 3 : Int)): [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %206)) = var - let %228 : DiffPairUserCode(Float, %206) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %228) - let %229 : Func(Void, InOut(DiffPairUserCode(Float, %206)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %229(%dpa, 1 : Float) - let %230 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %231 : DiffPairUserCode(Float, %206) = load(%dpa) - let %232 : Float = GetDifferentialUserCode(%231) - store(%230, %232) + let %dpa : Ptr(DiffPairUserCode(Float, %220)) = var + let %242 : DiffPairUserCode(Float, %220) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %242) + let %243 : Func(Void, InOut(DiffPairUserCode(Float, %220)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %243(%dpa, 1 : Float) + let %244 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %245 : DiffPairUserCode(Float, %220) = load(%dpa) + let %246 : Float = GetDifferentialUserCode(%245) + store(%244, %246) [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %206)) = var - let %233 : DiffPairUserCode(Float, %206) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %233) - let %234 : Func(Void, InOut(DiffPairUserCode(Float, %206)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %234(%dpa1, 1 : Float) - let %235 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %236 : DiffPairUserCode(Float, %206) = load(%dpa1) - let %237 : Float = GetDifferentialUserCode(%236) - store(%235, %237) + let %dpa1 : Ptr(DiffPairUserCode(Float, %220)) = var + let %247 : DiffPairUserCode(Float, %220) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %247) + let %248 : Func(Void, InOut(DiffPairUserCode(Float, %220)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) + call %248(%dpa1, 1 : Float) + let %249 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %250 : DiffPairUserCode(Float, %220) = load(%dpa1) + let %251 : Float = GetDifferentialUserCode(%250) + store(%249, %251) return_val(void_constant) } ### @@ -2244,50 +2258,50 @@ BACKWARD DIFFERENTIATE BACKWARD DIFFERENTIATE PRIMAL BACKWARD DIFFERENTIATE PROPOGATE (result before eliminating phis)=============================== -inst with location: 1514954 (1) +inst with location: 1515366 (1) [nameHint("y")] let %y : Float = param -inst with location: 1515008 (1) +inst with location: 1515420 (1) [loopMaxIters(4 : Int)] loop(%1, %2, %1, %y, 0 : Int) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [nameHint("t")] let %t : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [nameHint("i")] let %i : Int = param -inst with location: 1515008 (1) +inst with location: 1515420 (1) loop(%1, %2, %1) -inst with location: 1515026 (1) +inst with location: 1515438 (1) let %1 : Bool = cmpLT(%i, 3 : Int) -inst with location: 1515008 (1) +inst with location: 1515420 (1) ifElse(%1, %2, %3, %2) -inst with location: 1515008 (1) +inst with location: 1515420 (1) unconditionalBranch(%1) -inst with location: 1515058 (1) +inst with location: 1515470 (1) let %1 : Float = mul(%t, %t) -inst with location: 1515008 (1) +inst with location: 1515420 (1) unconditionalBranch(%1) -inst with location: 1515008 (1) +inst with location: 1515420 (1) unconditionalBranch(%1) -inst with location: 1515032 (1) +inst with location: 1515444 (1) let %1 : Int = add(%i, 1 : Int) -inst with location: 1515008 (1) +inst with location: 1515420 (1) unconditionalBranch(%1, %2, %3) -inst with location: 1515077 (1) +inst with location: 1515489 (1) return_val(%t) (fwdDiffFunc from generateNewForwardDerivative)=============================== @@ -2426,15 +2440,15 @@ inst with location: 0 (0) [nameHint("dpy")] let %dpy : DiffPair(Float, %1) = param -inst with location: 1514954 (1) +inst with location: 1515366 (1) [diffInstDecoration(Float)] let %1 : Float = GetDifferential(%dpy) -inst with location: 1514954 (1) +inst with location: 1515366 (1) [primalInstDecoration] let %1 : Float = GetPrimal(%dpy) -inst with location: 1515008 (1) +inst with location: 1515420 (1) [mixedDiffInstDecoration()] [loopMaxIters(4 : Int)] loop(%1, %2, %1, true, %3, %4, 0 : Int) @@ -2444,17 +2458,17 @@ inst with location: 0 (0) [nameHint("_bflag")] let %x5Fbflag : Bool = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -2471,7 +2485,7 @@ inst with location: 0 (0) [mixedDiffInstDecoration(DiffPair(Float, %1))] let %2 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) -inst with location: 1515077 (1) +inst with location: 1515489 (1) [mixedDiffInstDecoration(DiffPair(Float, %1))] return_val(%2) @@ -2479,7 +2493,7 @@ inst with location: 0 (0) [mixedDiffInstDecoration()] unconditionalBranch(%1) -inst with location: 1515026 (1) +inst with location: 1515438 (1) [primalInstDecoration] let %1 : Bool = cmpLT(%i, 3 : Int) @@ -2495,7 +2509,7 @@ inst with location: 0 (0) [mixedDiffInstDecoration()] unconditionalBranch(%1, 0 : Int, 0 : Float, %2) -inst with location: 1515058 (1) +inst with location: 1515470 (1) [primalInstDecoration] let %1 : Float = mul(%t, %t) @@ -2507,7 +2521,7 @@ inst with location: 0 (0) [diffInstDecoration(Float)] let %1 : Float = mul(%sx5Fdiffx5Ft, %t) -inst with location: 1515058 (1) +inst with location: 1515470 (1) [diffInstDecoration(Float)] let %1 : Float = add(%2, %3) @@ -2564,7 +2578,7 @@ inst with location: 0 (0) [mixedDiffInstDecoration()] unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) -inst with location: 1515032 (1) +inst with location: 1515444 (1) [primalInstDecoration] let %1 : Int = add(%i, 1 : Int) @@ -2572,17 +2586,17 @@ inst with location: 0 (0) [mixedDiffInstDecoration()] unconditionalBranch(%1, %2, %3, %4) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -2614,7 +2628,7 @@ let %1 : Float = DiffParamRef(%dpy) inst with location: 0 (0) unconditionalBranch(%1) -inst with location: 1515008 (1) +inst with location: 1515420 (1) [loopMaxIters(4 : Int)] loop(%1, %2, %1, true, %3, 0 : Int) @@ -2623,12 +2637,12 @@ inst with location: 0 (0) [nameHint("_bflag")] let %x5Fbflag : Bool = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -2646,7 +2660,7 @@ unconditionalBranch(%1) inst with location: 0 (0) unconditionalBranch(%1) -inst with location: 1515026 (1) +inst with location: 1515438 (1) [primalInstDecoration] let %1 : Bool = cmpLT(%i, 3 : Int) @@ -2656,7 +2670,7 @@ ifElse(%1, %2, %3, %4) inst with location: 0 (0) unconditionalBranch(%1, 0 : Int, 0 : Float) -inst with location: 1515058 (1) +inst with location: 1515470 (1) [primalInstDecoration] let %1 : Float = mul(%t, %t) @@ -2701,19 +2715,19 @@ ifElse(%x5Fbflag, %1, %2, %3) inst with location: 0 (0) unconditionalBranch(%1, %t, %i) -inst with location: 1515032 (1) +inst with location: 1515444 (1) [primalInstDecoration] let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) unconditionalBranch(%1, %2, %3) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -2721,11 +2735,11 @@ let %i : Int = param inst with location: 0 (0) unconditionalBranch(%1, %x5Fbflag, %t, %i) -inst with location: 1515008 (1) +inst with location: 1515420 (1) [loopMaxIters(4 : Int)] loop(%1, %2, %1, %3) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param @@ -2765,7 +2779,7 @@ inst with location: 0 (0) [diffInstDecoration(Float)] let %1 : Float = mul(%sx5Fdiffx5Ft, %t) -inst with location: 1515058 (1) +inst with location: 1515470 (1) [diffInstDecoration(Float)] let %1 : Float = add(%2, %3) @@ -2800,7 +2814,7 @@ unconditionalBranch(%1, %sx5Fdiffx5Ft) inst with location: 0 (0) unconditionalBranch(%1, %2) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param @@ -2992,7 +3006,7 @@ let %1 : Float = DiffParamRef(%dpy) inst with location: 0 (0) unconditionalBranch(%1) -inst with location: 1515008 (1) +inst with location: 1515420 (1) [loopMaxIters(4 : Int)] loop(%1, %2, %1, true, %3, 0 : Int) @@ -3001,12 +3015,12 @@ inst with location: 0 (0) [nameHint("_bflag")] let %x5Fbflag : Bool = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -3024,7 +3038,7 @@ unconditionalBranch(%1) inst with location: 0 (0) unconditionalBranch(%1) -inst with location: 1515026 (1) +inst with location: 1515438 (1) [primalInstDecoration] let %1 : Bool = cmpLT(%i, 3 : Int) @@ -3034,7 +3048,7 @@ ifElse(%1, %2, %3, %4) inst with location: 0 (0) unconditionalBranch(%1, 0 : Int, 0 : Float) -inst with location: 1515058 (1) +inst with location: 1515470 (1) [primalInstDecoration] let %1 : Float = mul(%t, %t) @@ -3079,19 +3093,19 @@ ifElse(%x5Fbflag, %1, %2, %3) inst with location: 0 (0) unconditionalBranch(%1, %t, %i) -inst with location: 1515032 (1) +inst with location: 1515444 (1) [primalInstDecoration] let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) unconditionalBranch(%1, %2, %3) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -3099,11 +3113,11 @@ let %i : Int = param inst with location: 0 (0) unconditionalBranch(%1, %x5Fbflag, %t, %i) -inst with location: 1515008 (1) +inst with location: 1515420 (1) [loopMaxIters(4 : Int)] loop(%1, %2, %1, %3) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param @@ -3143,7 +3157,7 @@ inst with location: 0 (0) [diffInstDecoration(Float)] let %1 : Float = mul(%sx5Fdiffx5Ft, %t) -inst with location: 1515058 (1) +inst with location: 1515470 (1) [diffInstDecoration(Float)] let %1 : Float = add(%2, %3) @@ -3178,7 +3192,7 @@ unconditionalBranch(%1, %sx5Fdiffx5Ft) inst with location: 0 (0) unconditionalBranch(%1, %2) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [diffInstDecoration(Float)] [nameHint("s_diff_t")] let %sx5Fdiffx5Ft : Float = param @@ -3216,7 +3230,7 @@ let %1 : Float = GetPrimal(%2) inst with location: 0 (0) unconditionalBranch(%1) -inst with location: 1515008 (1) +inst with location: 1515420 (1) [loopMaxIters(4 : Int)] let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) @@ -3225,12 +3239,12 @@ inst with location: 0 (0) [nameHint("_bflag")] let %x5Fbflag : Bool = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -3430,7 +3444,7 @@ unconditionalBranch(%1) inst with location: 0 (0) unconditionalBranch(%1) -inst with location: 1515026 (1) +inst with location: 1515438 (1) [primalInstDecoration] let %1 : Bool = cmpLT(%i, 3 : Int) @@ -3440,7 +3454,7 @@ ifElse(%1, %2, %3, %4) inst with location: 0 (0) unconditionalBranch(%1, 0 : Int, 0 : Float) -inst with location: 1515058 (1) +inst with location: 1515470 (1) [primalInstDecoration] let %1 : Float = mul(%t, %t) @@ -3485,19 +3499,19 @@ ifElse(%x5Fbflag, %1, %2, %3) inst with location: 0 (0) unconditionalBranch(%1, %t, %i) -inst with location: 1515032 (1) +inst with location: 1515444 (1) [primalInstDecoration] let %1 : Int = add(%i, 1 : Int) inst with location: 0 (0) unconditionalBranch(%1, %2, %3) -inst with location: 1514994 (1) +inst with location: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1515017 (1) +inst with location: 1515429 (1) [primalInstDecoration] [nameHint("i")] let %i : Int = param @@ -3509,14 +3523,14 @@ Adding counter for primalLoop: [loopMaxIters(4 : Int)] let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) - > sourceLoc: 1515008 (1) + > sourceLoc: 1515420 (1) >> Counter for primalLoop: [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] let %x5Fpc : Int = param - > sourceLoc: 1515008 (1) + > sourceLoc: 1515420 (1) ### Slang::AutodiffCheckpointPolicyBase::processFunc processing workList use with usedVal: @@ -3525,24 +3539,24 @@ use with usedVal: let %t : Float = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3CC5E0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D622580 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) use with usedVal: [primalInstDecoration] [nameHint("t")] let %t : Float = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3CC5E0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D622580 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param -inst with location: 1514994 (1) +inst with location: 1515406 (1) use with usedVal: [primalInstDecoration] let %1 : Bool = cmpLT(%i, 3 : Int) @@ -3563,13 +3577,13 @@ let %1 : Int = param use with usedVal: 0 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3BDB60 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7A2E3BC0 to storeSet 0 inst with location: 0 (0) use with usedVal: 1 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3BD730 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7A2E3790 to storeSet 1 inst with location: 0 (0) use with usedVal: @@ -3585,7 +3599,7 @@ let %x5Fbflag : Bool = param use with usedVal: -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3C97B0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D617730 to storeSet inst with location: 0 (0) use with usedVal: @@ -3603,24 +3617,24 @@ use with usedVal: let %x5Fpc : Int = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 000001B72F3E5848 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D62D8C8 to storeSet [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] let %x5Fpc : Int = param -inst with location: 1515008 (1) +inst with location: 1515420 (1) use with usedVal: [nameHint("_s_dOut")] let %x5Fsx5FdOut : Float = param ****** (before legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 1514994 (1) +source loc recorded: 1515406 (1) [primalInstDecoration] [nameHint("t")] let %t : Float = param -source loc recorded: 1515008 (1) +source loc recorded: 1515420 (1) [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] @@ -3667,13 +3681,13 @@ let %1 : Bool = cmpLT(%2, 3 : Int) >> NO OUT OF SCOPE USES ****** (after legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 1515008 (1) +source loc recorded: 1515420 (1) let %1 : Ptr(Int) = var tests/autodiff/reverse-loop.slang(16): note: also see pipeline definition for (int i = 0; i < 3; i++) ^~~ -source loc recorded: 1514994 (1) +source loc recorded: 1515406 (1) let %1 : Ptr(Array(Float, 5 : Int)) = var tests/autodiff/reverse-loop.slang(14): note: also see pipeline definition @@ -3681,24 +3695,11 @@ tests/autodiff/reverse-loop.slang(14): note: also see pipeline definition ^ in unzipping function: createIntermediate type: +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type; -adding field to outIntermediatery -inst: 1514994 (1) -let %1 : Ptr(Array(Float, 5 : Int)) = var - -[IntermediateContextFieldDifferentialTypeDecoration(%1)] -field(%2, Array(Float, 5 : Int)) - -adding field to outIntermediatery -inst: 1515008 (1) -let %1 : Ptr(Int) = var - -field(%1, Int) - ### AFTER-AUTODIFF: undefined let %1 : Void = varLayout(%2, %3) @@ -4344,8 +4345,8 @@ witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5F [derivativeMemberDecoration(%175)] let %175 : _ = key +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%193)] @@ -5362,8 +5363,8 @@ witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5F [derivativeMemberDecoration(%175)] let %175 : _ = key +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%193)] @@ -6379,8 +6380,8 @@ witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5F [derivativeMemberDecoration(%175)] let %175 : _ = key +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%193)] @@ -6955,16 +6956,53 @@ witness_table %75 : witness_table_t(%IDifferentiable)(Float) } +[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] +[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] +[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] +[primalInstDecoration] +[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) + +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) + +block %78: + return_val(%t) + +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) + +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) +} [export("_ST4core17IBufferDataLayout")] [nameHint("IBufferDataLayout")] let %IBufferDataLayout : Type = interface [export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %76 : witness_table_t(%IBufferDataLayout)(DefaultLayout); +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); [nameHint("outputBuffer")] [export("_SVR15reverse_2Dxloop12outputBuffer")] [layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %76) = global_param +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param [keepAlive] [entryPoint(6 : Int, "computeMain", "reverse-loop")] [numThreads(1 : Int, 1 : Int, 1 : Int)] @@ -6973,29 +7011,29 @@ let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %76) = global_para [layout(%8)] func %computeMain : Func(Void, Vec(UInt, 3 : Int)) { -block %77( +block %85( [layout(%15)] [nameHint("dispatchThreadID")] [semantic("SV_DispatchThreadID", 0 : Int)] param %dispatchThreadID : Vec(UInt, 3 : Int)): [nameHint("dpa")] let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %78 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %78) + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %79 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %80 : DiffPairUserCode(Float, %75) = load(%dpa) - let %81 : Float = GetDifferentialUserCode(%80) - store(%79, %81) + let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %88 : DiffPairUserCode(Float, %75) = load(%dpa) + let %89 : Float = GetDifferentialUserCode(%88) + store(%87, %89) [nameHint("dpa")] let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %82 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %82) + let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %90) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %83 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %84 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %85 : Float = GetDifferentialUserCode(%84) - store(%83, %85) + let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %93 : Float = GetDifferentialUserCode(%92) + store(%91, %93) return_val(void_constant) } [export("_SV16NullDifferential5dummy")] @@ -7020,9 +7058,9 @@ struct %NullDifferential : Type [nameHint("NullDifferential.dzero")] func %NullDifferentialx5Fdzero : Func(%NullDifferential) { -block %86: - let %87 : %NullDifferential = makeStruct(0 : UInt) - return_val(%87) +block %94: + let %95 : %NullDifferential = makeStruct(0 : UInt) + return_val(%95) } [readNone] [DifferentiableTypeDictionaryDecoration] @@ -7033,31 +7071,31 @@ block %86: [nameHint("NullDifferential.dadd")] func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) { -block %88( +block %96( [nameHint("SLANG_anonymous_8")] param %SLANGx5Fanonymousx5F8_ : %NullDifferential, [nameHint("SLANG_anonymous_9")] param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %89 : %NullDifferential = makeStruct(0 : UInt) - return_val(%89) + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) } -generic %90 : Generic +generic %98 : Generic { -block %91( +block %99( [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] [nameHint("NullDifferential.T")] param %NullDifferentialx5FT : type_t, - param %92 : witness_table_t(%x5Fx5FBuiltinRealType)): + param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) } [export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %93 : %90 +generic %101 : %98 { -block %94( +block %102( [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] [nameHint("NullDifferential.T")] param %NullDifferentialx5FT1 : type_t, - param %95 : witness_table_t(%x5Fx5FBuiltinRealType)): + param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): [readNone] [DifferentiableTypeDictionaryDecoration] [ForceInline] @@ -7065,30 +7103,30 @@ block %94( [nameHint("NullDifferential.dmul")] func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) { -block %96( +block %104( [nameHint("SLANG_anonymous_10")] param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), [nameHint("SLANG_anonymous_11")] param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) + let %105 : %NullDifferential = makeStruct(0 : UInt) + return_val(%105) } return_val(%NullDifferentialx5Fdmul) } [keepAlive] [hlslExport] [export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %98 : witness_table_t(%IDifferentiable)(%NullDifferential) +witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) { witness_table_entry(%18,%NullDifferential) - witness_table_entry(%20,%98) + witness_table_entry(%20,%106) witness_table_entry(%22,%NullDifferentialx5Fdzero) witness_table_entry(%24,%NullDifferentialx5Fdadd) - witness_table_entry(%26,%93) + witness_table_entry(%26,%101) } @@ -7100,15 +7138,15 @@ ExistentialTypeSpecializationDictionary [nameHint("s_bwd_test_simple_loop")] func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) { -block %99( - param %100 : InOut(DiffPairUserCode(Float, %75)), - param %101 : Float): - let %102 : DiffPairUserCode(Float, %75) = load(%100) - let %103 : Float = GetPrimalUserCode(%102) - let %104 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %105 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%103, %104) - let %106 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%104) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%100, %101, %106) +block %107( + param %108 : InOut(DiffPairUserCode(Float, %75)), + param %109 : Float): + let %110 : DiffPairUserCode(Float, %75) = load(%108) + let %111 : Float = GetPrimalUserCode(%110) + let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) + let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) return_val(void_constant) } [nameHint("s_primal_ctx_test_simple_loop")] @@ -7117,178 +7155,178 @@ block %99( [backwardDifferentiable] func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) { -block %107( +block %115( [nameHint("dpy")] param %dpy : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - unconditionalBranch(%108) + unconditionalBranch(%116) -block %108: - let %109 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct - store(%x5Fsx5Fdiffx5Fctx, %109) - let %110 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %111) - let %112 : Ptr(Array(Float, 5 : Int)) = var - let %113 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%112, %113) - let %114 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%110, %114) - let %115 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %116) - let %117 : Ptr(Int) = var - store(%117, 0 : Int) - store(%115, 0 : Int) - unconditionalBranch(%118) - -block %118: +block %116: + let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct + store(%x5Fsx5Fdiffx5Fctx, %117) + let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) + let %120 : Ptr(Array(Float, 5 : Int)) = var + let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%120, %121) + let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%118, %122) + let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + let %125 : Ptr(Int) = var + store(%125, 0 : Int) + store(%123, 0 : Int) + unconditionalBranch(%126) + +block %126: [loopMaxIters(4 : Int)] - loop(%119, %120, %119, true, %dpy, 0 : Int, 0 : Int) + loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) -block %119( +block %127( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag : Bool, [primalInstDecoration] [nameHint("t")] - param %t : Float, + param %t1 : Float, [primalInstDecoration] [nameHint("i")] - param %i : Int, + param %i1 : Int, [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] param %x5Fpc : Int): - let %121 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%110, %x5Fpc) - store(%121, %t) - store(%115, %x5Fpc) - ifElse(%x5Fbflag, %122, %123, %122) + let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) + store(%129, %t1) + store(%123, %x5Fpc) + ifElse(%x5Fbflag, %130, %131, %130) -block %123: - unconditionalBranch(%120) +block %131: + unconditionalBranch(%128) -block %120: - return_val(%t) +block %128: + return_val(%t1) -block %122: - unconditionalBranch(%124) +block %130: + unconditionalBranch(%132) -block %124: +block %132: [primalInstDecoration] - let %125 : Bool = cmpLT(%i, 3 : Int) - ifElse(%125, %126, %127, %128) + let %133 : Bool = cmpLT(%i1, 3 : Int) + ifElse(%133, %134, %135, %136) -block %127: - unconditionalBranch(%128, 0 : Int, 0 : Float) +block %135: + unconditionalBranch(%136, 0 : Int, 0 : Float) -block %126: +block %134: [primalInstDecoration] - let %129 : Float = mul(%t, %t) - unconditionalBranch(%128, 1 : Int, %129) + let %137 : Float = mul(%t1, %t1) + unconditionalBranch(%136, 1 : Int, %137) -block %128( +block %136( [primalInstDecoration] - param %130 : Int, + param %138 : Int, [primalInstDecoration] - param %131 : Float): - unconditionalBranch(%132) + param %139 : Float): + unconditionalBranch(%140) -block %132: +block %140: [primalInstDecoration] - let %133 : Bool = cmpNE(%130, 1 : Int) - ifElse(%133, %134, %135, %136) + let %141 : Bool = cmpNE(%138, 1 : Int) + ifElse(%141, %142, %143, %144) -block %135: - unconditionalBranch(%136, %x5Fbflag) +block %143: + unconditionalBranch(%144, %x5Fbflag) -block %134: - unconditionalBranch(%136, false) +block %142: + unconditionalBranch(%144, false) -block %136( +block %144( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag1 : Bool): - unconditionalBranch(%137) + unconditionalBranch(%145) -block %137: - ifElse(%x5Fbflag1, %138, %139, %140) +block %145: + ifElse(%x5Fbflag1, %146, %147, %148) -block %139: - unconditionalBranch(%140, %t, %i) +block %147: + unconditionalBranch(%148, %t1, %i1) -block %138: +block %146: [primalInstDecoration] - let %141 : Int = add(%i, 1 : Int) - unconditionalBranch(%140, %131, %141) + let %149 : Int = add(%i1, 1 : Int) + unconditionalBranch(%148, %139, %149) -block %140( +block %148( [primalInstDecoration] [nameHint("t")] - param %t1 : Float, + param %t2 : Float, [primalInstDecoration] [nameHint("i")] - param %i1 : Int): + param %i2 : Int): [primalInstDecoration] - let %142 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%119, %x5Fbflag1, %t1, %i1, %142) + let %150 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) } -[derivativeMemberDecoration(%143)] -let %111 : _ = key -let %116 : _ = key -struct %144 : Type +[derivativeMemberDecoration(%151)] +let %119 : _ = key +let %124 : _ = key +struct %152 : Type { - field(%143, Array(Float, 5 : Int)) + field(%151, Array(Float, 5 : Int)) } -func %145 : Func(%144) +func %153 : Func(%152) { -block %146: - let %147 : Array(Float, 5 : Int) = call %148() - let %149 : %144 = makeStruct(%147) - return_val(%149) +block %154: + let %155 : Array(Float, 5 : Int) = call %156() + let %157 : %152 = makeStruct(%155) + return_val(%157) } -func %150 : Func(%144) +func %158 : Func(%152) { -block %151( - param %152 : %144, - param %153 : %144): - let %154 : Array(Float, 5 : Int) = get_field(%152, %143) - let %155 : Array(Float, 5 : Int) = get_field(%153, %143) - let %156 : Array(Float, 5 : Int) = call %157(%154, %155) - let %158 : %144 = makeStruct(%156) - return_val(%158) +block %159( + param %160 : %152, + param %161 : %152): + let %162 : Array(Float, 5 : Int) = get_field(%160, %151) + let %163 : Array(Float, 5 : Int) = get_field(%161, %151) + let %164 : Array(Float, 5 : Int) = call %165(%162, %163) + let %166 : %152 = makeStruct(%164) + return_val(%166) } -witness_table %159 : witness_table_t(%IDifferentiable)(%144) +witness_table %167 : witness_table_t(%IDifferentiable)(%152) { - witness_table_entry(%18,%144) + witness_table_entry(%18,%152) - witness_table_entry(%20,%159) + witness_table_entry(%20,%167) - witness_table_entry(%22,%145) + witness_table_entry(%22,%153) - witness_table_entry(%24,%150) + witness_table_entry(%24,%158) } -witness_table %160 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +witness_table %168 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { - witness_table_entry(%18,%144) + witness_table_entry(%18,%152) - witness_table_entry(%20,%159) + witness_table_entry(%20,%167) - witness_table_entry(%22,%145) + witness_table_entry(%22,%153) - witness_table_entry(%24,%150) + witness_table_entry(%24,%158) } -[derivativeMemberDecoration(%143)] -let %143 : _ = key +[derivativeMemberDecoration(%151)] +let %151 : _ = key +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { - [IntermediateContextFieldDifferentialTypeDecoration(%161)] - field(%111, Array(Float, 5 : Int)) - field(%116, Int) + [IntermediateContextFieldDifferentialTypeDecoration(%169)] + field(%119, Array(Float, 5 : Int)) + field(%124, Int) } [FloatingPointModeOverride(1 : Int)] @@ -7297,355 +7335,355 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type [nameHint("s_bwd_prop_test_simple_loop")] func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { -block %162( +block %170( [nameHint("dpy")] param %dpy1 : InOut(DiffPairUserCode(Float, %75)), [nameHint("_s_dOut")] param %x5Fsx5FdOut : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - unconditionalBranch(%163) - -block %163: - let %164 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %165 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %166 : Ptr(Array(Float, 5 : Int)) = var - store(%166, %165) - store(%166, %164) - let %167 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) - let %168 : Ptr(Int) = var - store(%168, %167) - store(%168, 0 : Int) - let %169 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %170 : Float = GetPrimalUserCode(%169) unconditionalBranch(%171) block %171: + let %172 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %173 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %174 : Ptr(Array(Float, 5 : Int)) = var + store(%174, %173) + store(%174, %172) + let %175 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %176 : Ptr(Int) = var + store(%176, %175) + store(%176, 0 : Int) + let %177 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %178 : Float = GetPrimalUserCode(%177) + unconditionalBranch(%179) + +block %179: [loopMaxIters(4 : Int)] - loop(%172, %173, %172, true, %170, 0 : Int, 0 : Int) + loop(%180, %181, %180, true, %178, 0 : Int, 0 : Int) -block %172( +block %180( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag2 : Bool, [primalInstDecoration] [nameHint("t")] - param %t2 : Float, + param %t3 : Float, [primalInstDecoration] [nameHint("i")] - param %i2 : Int, + param %i3 : Int, [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] param %x5Fpc1 : Int): - let %174 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %175 : Ptr(Array(Float, 5 : Int)) = var - store(%175, %174) - let %176 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%175, %x5Fpc1) - store(%176, %t2) - let %177 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) - let %178 : Ptr(Int) = var - store(%178, %177) - store(%178, %x5Fpc1) - ifElse(%x5Fbflag2, %179, %180, %179) - -block %180: - unconditionalBranch(%173) - -block %173: + let %182 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %183 : Ptr(Array(Float, 5 : Int)) = var + store(%183, %182) + let %184 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%183, %x5Fpc1) + store(%184, %t3) + let %185 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %186 : Ptr(Int) = var + store(%186, %185) + store(%186, %x5Fpc1) + ifElse(%x5Fbflag2, %187, %188, %187) + +block %188: unconditionalBranch(%181) block %181: - unconditionalBranch(%182) + unconditionalBranch(%189) -block %182: - unconditionalBranch(%183) +block %189: + unconditionalBranch(%190) -block %183: - unconditionalBranch(%184) +block %190: + unconditionalBranch(%191) -block %184: - unconditionalBranch(%185) +block %191: + unconditionalBranch(%192) -block %185: - let %186 : Ptr(Float) = var - store(%186, 0 : Float) - let %187 : Ptr(Float) = var - store(%187, 0 : Float) - let %188 : Float = load(%186) - let %189 : Float = add(%x5Fsx5FdOut, %188) - store(%186, %189) - unconditionalBranch(%190) +block %192: + unconditionalBranch(%193) -block %190: - let %191 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) - let %192 : Int = sub(%191, 1 : Int) +block %193: + let %194 : Ptr(Float) = var + store(%194, 0 : Float) + let %195 : Ptr(Float) = var + store(%195, 0 : Float) + let %196 : Float = load(%194) + let %197 : Float = add(%x5Fsx5FdOut, %196) + store(%194, %197) + unconditionalBranch(%198) + +block %198: + let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %200 : Int = sub(%199, 1 : Int) [loopMaxIters(4 : Int)] - loop(%193, %194, %195, %192) + loop(%201, %202, %203, %200) -block %193( +block %201( [primalInstDecoration] [nameHint("_dc")] param %x5Fdc : Int): - let %196 : Int = add(%x5Fdc, 0 : Int) - let %197 : Float = load(%186) - store(%186, 0 : Float) - let %198 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%198, %199, %200, %199) + let %204 : Int = add(%x5Fdc, 0 : Int) + let %205 : Float = load(%194) + store(%194, 0 : Float) + let %206 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%206, %207, %208, %207) -block %200: - unconditionalBranch(%194, %197) - -block %194( - param %201 : Float): - let %202 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %203 : Float = GetPrimalUserCode(%202) - let %204 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%203, %201) - store(%dpy1, %204) +block %208: + unconditionalBranch(%202, %205) + +block %202( + param %209 : Float): + let %210 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %211 : Float = GetPrimalUserCode(%210) + let %212 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%211, %209) + store(%dpy1, %212) return_val(void_constant) -block %199: - unconditionalBranch(%205) +block %207: + unconditionalBranch(%213) -block %205: +block %213: [primalInstDecoration] - let %206 : Bool = cmpLT(%196, 3 : Int) - ifElse(%206, %207, %208, %209) + let %214 : Bool = cmpLT(%204, 3 : Int) + ifElse(%214, %215, %216, %217) -block %208: - unconditionalBranch(%209, 0 : Int) +block %216: + unconditionalBranch(%217, 0 : Int) -block %207: - unconditionalBranch(%209, 1 : Int) +block %215: + unconditionalBranch(%217, 1 : Int) -block %209( +block %217( [primalInstDecoration] - param %210 : Int): - unconditionalBranch(%211) + param %218 : Int): + unconditionalBranch(%219) -block %211: +block %219: [primalInstDecoration] - let %212 : Bool = cmpNE(%210, 1 : Int) - ifElse(%212, %213, %214, %215) + let %220 : Bool = cmpNE(%218, 1 : Int) + ifElse(%220, %221, %222, %223) -block %214: - unconditionalBranch(%215, true) +block %222: + unconditionalBranch(%223, true) -block %213: - unconditionalBranch(%215, false) +block %221: + unconditionalBranch(%223, false) -block %215( +block %223( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag3 : Bool): - unconditionalBranch(%216) - -block %216: - ifElse(%x5Fbflag3, %217, %218, %219) - -block %218: - unconditionalBranch(%219) + unconditionalBranch(%224) -block %217: - unconditionalBranch(%219) +block %224: + ifElse(%x5Fbflag3, %225, %226, %227) -block %219: - unconditionalBranch(%220) +block %226: + unconditionalBranch(%227) -block %220: - unconditionalBranch(%221, %197) +block %225: + unconditionalBranch(%227) -block %221( - param %222 : Float): - ifElse(%x5Fbflag3, %223, %224, %225) +block %227: + unconditionalBranch(%228) -block %224: - unconditionalBranch(%226, %222) +block %228: + unconditionalBranch(%229, %205) -block %226( - param %227 : Float): - let %228 : Float = load(%186) - let %229 : Float = add(%227, %228) - store(%186, %229) - unconditionalBranch(%225) +block %229( + param %230 : Float): + ifElse(%x5Fbflag3, %231, %232, %233) -block %223: - unconditionalBranch(%230, %222) +block %232: + unconditionalBranch(%234, %230) -block %230( - param %231 : Float): - let %232 : Float = load(%187) - let %233 : Float = add(%231, %232) - store(%187, %233) - unconditionalBranch(%225) +block %234( + param %235 : Float): + let %236 : Float = load(%194) + let %237 : Float = add(%235, %236) + store(%194, %237) + unconditionalBranch(%233) -block %225: - unconditionalBranch(%234) +block %231: + unconditionalBranch(%238, %230) -block %234: - ifElse(%212, %235, %236, %237) +block %238( + param %239 : Float): + let %240 : Float = load(%195) + let %241 : Float = add(%239, %240) + store(%195, %241) + unconditionalBranch(%233) -block %236: - unconditionalBranch(%237) +block %233: + unconditionalBranch(%242) -block %235: - unconditionalBranch(%237) +block %242: + ifElse(%220, %243, %244, %245) -block %237: - unconditionalBranch(%238) +block %244: + unconditionalBranch(%245) -block %238: - let %239 : Float = load(%187) - store(%187, 0 : Float) - ifElse(%206, %240, %241, %242) +block %243: + unconditionalBranch(%245) -block %241: - unconditionalBranch(%243) +block %245: + unconditionalBranch(%246) -block %243: - unconditionalBranch(%242) +block %246: + let %247 : Float = load(%195) + store(%195, 0 : Float) + ifElse(%214, %248, %249, %250) -block %240: - unconditionalBranch(%244, %239) +block %249: + unconditionalBranch(%251) -block %244( - param %245 : Float): - let %246 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %247 : Ptr(Array(Float, 5 : Int)) = var - store(%247, %246) - let %248 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%247, %x5Fdc) - let %249 : Float = load(%248) - let %250 : Float = mul(%249, %245) - let %251 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %252 : Ptr(Array(Float, 5 : Int)) = var - store(%252, %251) - let %253 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%252, %x5Fdc) - let %254 : Float = load(%253) - let %255 : Float = mul(%254, %245) - let %256 : Float = load(%186) - let %257 : Float = add(%250, %255) - let %258 : Float = add(%257, %256) - store(%186, %258) - unconditionalBranch(%242) +block %251: + unconditionalBranch(%250) -block %242: - unconditionalBranch(%195) +block %248: + unconditionalBranch(%252, %247) + +block %252( + param %253 : Float): + let %254 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %255 : Ptr(Array(Float, 5 : Int)) = var + store(%255, %254) + let %256 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%255, %x5Fdc) + let %257 : Float = load(%256) + let %258 : Float = mul(%257, %253) + let %259 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %260 : Ptr(Array(Float, 5 : Int)) = var + store(%260, %259) + let %261 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%260, %x5Fdc) + let %262 : Float = load(%261) + let %263 : Float = mul(%262, %253) + let %264 : Float = load(%194) + let %265 : Float = add(%258, %263) + let %266 : Float = add(%265, %264) + store(%194, %266) + unconditionalBranch(%250) + +block %250: + unconditionalBranch(%203) -block %195: +block %203: [primalInstDecoration] - let %259 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%193, %259) + let %267 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%201, %267) -block %179: - unconditionalBranch(%260) +block %187: + unconditionalBranch(%268) -block %260: +block %268: [primalInstDecoration] - let %261 : Bool = cmpLT(%i2, 3 : Int) - ifElse(%261, %262, %263, %264) + let %269 : Bool = cmpLT(%i3, 3 : Int) + ifElse(%269, %270, %271, %272) -block %263: - unconditionalBranch(%264, 0 : Int, 0 : Float) +block %271: + unconditionalBranch(%272, 0 : Int, 0 : Float) -block %262: +block %270: [primalInstDecoration] - let %265 : Float = mul(%t2, %t2) - unconditionalBranch(%264, 1 : Int, %265) + let %273 : Float = mul(%t3, %t3) + unconditionalBranch(%272, 1 : Int, %273) -block %264( +block %272( [primalInstDecoration] - param %266 : Int, + param %274 : Int, [primalInstDecoration] - param %267 : Float): - unconditionalBranch(%268) + param %275 : Float): + unconditionalBranch(%276) -block %268: +block %276: [primalInstDecoration] - let %269 : Bool = cmpNE(%266, 1 : Int) - ifElse(%269, %270, %271, %272) + let %277 : Bool = cmpNE(%274, 1 : Int) + ifElse(%277, %278, %279, %280) -block %271: - unconditionalBranch(%272, %x5Fbflag2) +block %279: + unconditionalBranch(%280, %x5Fbflag2) -block %270: - unconditionalBranch(%272, false) +block %278: + unconditionalBranch(%280, false) -block %272( +block %280( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag4 : Bool): - unconditionalBranch(%273) + unconditionalBranch(%281) -block %273: - ifElse(%x5Fbflag4, %274, %275, %276) +block %281: + ifElse(%x5Fbflag4, %282, %283, %284) -block %275: - unconditionalBranch(%276, %t2, %i2) +block %283: + unconditionalBranch(%284, %t3, %i3) -block %274: +block %282: [primalInstDecoration] - let %277 : Int = add(%i2, 1 : Int) - unconditionalBranch(%276, %267, %277) + let %285 : Int = add(%i3, 1 : Int) + unconditionalBranch(%284, %275, %285) -block %276( +block %284( [primalInstDecoration] [nameHint("t")] - param %t3 : Float, + param %t4 : Float, [primalInstDecoration] [nameHint("i")] - param %i3 : Int): + param %i4 : Int): [primalInstDecoration] - let %278 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%172, %x5Fbflag4, %t3, %i3, %278) + let %286 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%180, %x5Fbflag4, %t4, %i4, %286) } [backwardDifferentiable] -func %157 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) -{ -block %279( - param %280 : Array(Float, 5 : Int), - param %281 : Array(Float, 5 : Int)): - let %282 : Ptr(Array(Float, 5 : Int)) = var - loop(%283, %284, %283, 0 : Int) - -block %283( - param %285 : Int): - let %286 : Bool = cmpLT(%285, 5 : Int) - ifElse(%286, %287, %288, %288) +func %165 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) +{ +block %287( + param %288 : Array(Float, 5 : Int), + param %289 : Array(Float, 5 : Int)): + let %290 : Ptr(Array(Float, 5 : Int)) = var + loop(%291, %292, %291, 0 : Int) + +block %291( + param %293 : Int): + let %294 : Bool = cmpLT(%293, 5 : Int) + ifElse(%294, %295, %296, %296) + +block %295: + let %297 : Float = getElement(%288, %293) + let %298 : Float = getElement(%289, %293) + let %299 : Float = add(%297, %298) + let %300 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%290, %293) + store(%300, %299) + unconditionalBranch(%301) -block %287: - let %289 : Float = getElement(%280, %285) - let %290 : Float = getElement(%281, %285) - let %291 : Float = add(%289, %290) - let %292 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%282, %285) - store(%292, %291) - unconditionalBranch(%293) - -block %288: - unconditionalBranch(%284) +block %296: + unconditionalBranch(%292) -block %284: - let %294 : Array(Float, 5 : Int) = load(%282) - return_val(%294) +block %292: + let %302 : Array(Float, 5 : Int) = load(%290) + return_val(%302) -block %293: - let %295 : Int = add(%285, 1 : Int) - unconditionalBranch(%283, %295) +block %301: + let %303 : Int = add(%293, 1 : Int) + unconditionalBranch(%291, %303) } -func %148 : Func(Array(Float, 5 : Int)) +func %156 : Func(Array(Float, 5 : Int)) { -block %296: - let %297 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) - return_val(%297) +block %304: + let %305 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) + return_val(%305) } -witness_table %161 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) +witness_table %169 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) { witness_table_entry(%18,Array(Float, 5 : Int)) - witness_table_entry(%20,%161) + witness_table_entry(%20,%169) - witness_table_entry(%24,%157) + witness_table_entry(%24,%165) - witness_table_entry(%22,%148) + witness_table_entry(%22,%156) } @@ -7853,16 +7891,53 @@ witness_table %75 : witness_table_t(%IDifferentiable)(Float) } +[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] +[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] +[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] +[primalInstDecoration] +[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] +[readNone] +[DifferentiableTypeDictionaryDecoration] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %76( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%77, %78, %79, %y, 0 : Int) + +block %77( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %80 : Bool = cmpLT(%i, 3 : Int) + ifElse(%80, %81, %78, %81) + +block %78: + return_val(%t) + +block %81: + let %82 : Float = mul(%t, %t) + unconditionalBranch(%79) + +block %79: + let %83 : Int = add(%i, 1 : Int) + unconditionalBranch(%77, %82, %83) +} [export("_ST4core17IBufferDataLayout")] [nameHint("IBufferDataLayout")] let %IBufferDataLayout : Type = interface [export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %76 : witness_table_t(%IBufferDataLayout)(DefaultLayout); +witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); [nameHint("outputBuffer")] [export("_SVR15reverse_2Dxloop12outputBuffer")] [layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %76) = global_param +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param [keepAlive] [entryPoint(6 : Int, "computeMain", "reverse-loop")] [numThreads(1 : Int, 1 : Int, 1 : Int)] @@ -7871,29 +7946,29 @@ let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %76) = global_para [layout(%8)] func %computeMain : Func(Void, Vec(UInt, 3 : Int)) { -block %77( +block %85( [layout(%15)] [nameHint("dispatchThreadID")] [semantic("SV_DispatchThreadID", 0 : Int)] param %dispatchThreadID : Vec(UInt, 3 : Int)): [nameHint("dpa")] let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %78 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %78) + let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) + store(%dpa, %86) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %79 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %80 : DiffPairUserCode(Float, %75) = load(%dpa) - let %81 : Float = GetDifferentialUserCode(%80) - store(%79, %81) + let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %88 : DiffPairUserCode(Float, %75) = load(%dpa) + let %89 : Float = GetDifferentialUserCode(%88) + store(%87, %89) [nameHint("dpa")] let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %82 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %82) + let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) + store(%dpa1, %90) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %83 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %84 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %85 : Float = GetDifferentialUserCode(%84) - store(%83, %85) + let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) + let %93 : Float = GetDifferentialUserCode(%92) + store(%91, %93) return_val(void_constant) } [export("_SV16NullDifferential5dummy")] @@ -7918,9 +7993,9 @@ struct %NullDifferential : Type [nameHint("NullDifferential.dzero")] func %NullDifferentialx5Fdzero : Func(%NullDifferential) { -block %86: - let %87 : %NullDifferential = makeStruct(0 : UInt) - return_val(%87) +block %94: + let %95 : %NullDifferential = makeStruct(0 : UInt) + return_val(%95) } [readNone] [DifferentiableTypeDictionaryDecoration] @@ -7931,31 +8006,31 @@ block %86: [nameHint("NullDifferential.dadd")] func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) { -block %88( +block %96( [nameHint("SLANG_anonymous_8")] param %SLANGx5Fanonymousx5F8_ : %NullDifferential, [nameHint("SLANG_anonymous_9")] param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %89 : %NullDifferential = makeStruct(0 : UInt) - return_val(%89) + let %97 : %NullDifferential = makeStruct(0 : UInt) + return_val(%97) } -generic %90 : Generic +generic %98 : Generic { -block %91( +block %99( [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] [nameHint("NullDifferential.T")] param %NullDifferentialx5FT : type_t, - param %92 : witness_table_t(%x5Fx5FBuiltinRealType)): + param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) } [export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %93 : %90 +generic %101 : %98 { -block %94( +block %102( [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] [nameHint("NullDifferential.T")] param %NullDifferentialx5FT1 : type_t, - param %95 : witness_table_t(%x5Fx5FBuiltinRealType)): + param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): [readNone] [DifferentiableTypeDictionaryDecoration] [ForceInline] @@ -7963,30 +8038,30 @@ block %94( [nameHint("NullDifferential.dmul")] func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) { -block %96( +block %104( [nameHint("SLANG_anonymous_10")] param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), [nameHint("SLANG_anonymous_11")] param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) + let %105 : %NullDifferential = makeStruct(0 : UInt) + return_val(%105) } return_val(%NullDifferentialx5Fdmul) } [keepAlive] [hlslExport] [export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %98 : witness_table_t(%IDifferentiable)(%NullDifferential) +witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) { witness_table_entry(%18,%NullDifferential) - witness_table_entry(%20,%98) + witness_table_entry(%20,%106) witness_table_entry(%22,%NullDifferentialx5Fdzero) witness_table_entry(%24,%NullDifferentialx5Fdadd) - witness_table_entry(%26,%93) + witness_table_entry(%26,%101) } @@ -7998,15 +8073,15 @@ ExistentialTypeSpecializationDictionary [nameHint("s_bwd_test_simple_loop")] func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) { -block %99( - param %100 : InOut(DiffPairUserCode(Float, %75)), - param %101 : Float): - let %102 : DiffPairUserCode(Float, %75) = load(%100) - let %103 : Float = GetPrimalUserCode(%102) - let %104 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %105 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%103, %104) - let %106 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%104) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%100, %101, %106) +block %107( + param %108 : InOut(DiffPairUserCode(Float, %75)), + param %109 : Float): + let %110 : DiffPairUserCode(Float, %75) = load(%108) + let %111 : Float = GetPrimalUserCode(%110) + let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) + let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) return_val(void_constant) } [nameHint("s_primal_ctx_test_simple_loop")] @@ -8015,178 +8090,178 @@ block %99( [backwardDifferentiable] func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) { -block %107( +block %115( [nameHint("dpy")] param %dpy : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - unconditionalBranch(%108) + unconditionalBranch(%116) -block %108: - let %109 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct - store(%x5Fsx5Fdiffx5Fctx, %109) - let %110 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %111) - let %112 : Ptr(Array(Float, 5 : Int)) = var - let %113 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%112, %113) - let %114 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%110, %114) - let %115 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %116) - let %117 : Ptr(Int) = var - store(%117, 0 : Int) - store(%115, 0 : Int) - unconditionalBranch(%118) - -block %118: +block %116: + let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct + store(%x5Fsx5Fdiffx5Fctx, %117) + let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) + let %120 : Ptr(Array(Float, 5 : Int)) = var + let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%120, %121) + let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%118, %122) + let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + let %125 : Ptr(Int) = var + store(%125, 0 : Int) + store(%123, 0 : Int) + unconditionalBranch(%126) + +block %126: [loopMaxIters(4 : Int)] - loop(%119, %120, %119, true, %dpy, 0 : Int, 0 : Int) + loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) -block %119( +block %127( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag : Bool, [primalInstDecoration] [nameHint("t")] - param %t : Float, + param %t1 : Float, [primalInstDecoration] [nameHint("i")] - param %i : Int, + param %i1 : Int, [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] param %x5Fpc : Int): - let %121 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%110, %x5Fpc) - store(%121, %t) - store(%115, %x5Fpc) - ifElse(%x5Fbflag, %122, %123, %122) + let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) + store(%129, %t1) + store(%123, %x5Fpc) + ifElse(%x5Fbflag, %130, %131, %130) -block %123: - unconditionalBranch(%120) +block %131: + unconditionalBranch(%128) -block %120: - return_val(%t) +block %128: + return_val(%t1) -block %122: - unconditionalBranch(%124) +block %130: + unconditionalBranch(%132) -block %124: +block %132: [primalInstDecoration] - let %125 : Bool = cmpLT(%i, 3 : Int) - ifElse(%125, %126, %127, %128) + let %133 : Bool = cmpLT(%i1, 3 : Int) + ifElse(%133, %134, %135, %136) -block %127: - unconditionalBranch(%128, 0 : Int, 0 : Float) +block %135: + unconditionalBranch(%136, 0 : Int, 0 : Float) -block %126: +block %134: [primalInstDecoration] - let %129 : Float = mul(%t, %t) - unconditionalBranch(%128, 1 : Int, %129) + let %137 : Float = mul(%t1, %t1) + unconditionalBranch(%136, 1 : Int, %137) -block %128( +block %136( [primalInstDecoration] - param %130 : Int, + param %138 : Int, [primalInstDecoration] - param %131 : Float): - unconditionalBranch(%132) + param %139 : Float): + unconditionalBranch(%140) -block %132: +block %140: [primalInstDecoration] - let %133 : Bool = cmpNE(%130, 1 : Int) - ifElse(%133, %134, %135, %136) + let %141 : Bool = cmpNE(%138, 1 : Int) + ifElse(%141, %142, %143, %144) -block %135: - unconditionalBranch(%136, %x5Fbflag) +block %143: + unconditionalBranch(%144, %x5Fbflag) -block %134: - unconditionalBranch(%136, false) +block %142: + unconditionalBranch(%144, false) -block %136( +block %144( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag1 : Bool): - unconditionalBranch(%137) + unconditionalBranch(%145) -block %137: - ifElse(%x5Fbflag1, %138, %139, %140) +block %145: + ifElse(%x5Fbflag1, %146, %147, %148) -block %139: - unconditionalBranch(%140, %t, %i) +block %147: + unconditionalBranch(%148, %t1, %i1) -block %138: +block %146: [primalInstDecoration] - let %141 : Int = add(%i, 1 : Int) - unconditionalBranch(%140, %131, %141) + let %149 : Int = add(%i1, 1 : Int) + unconditionalBranch(%148, %139, %149) -block %140( +block %148( [primalInstDecoration] [nameHint("t")] - param %t1 : Float, + param %t2 : Float, [primalInstDecoration] [nameHint("i")] - param %i1 : Int): + param %i2 : Int): [primalInstDecoration] - let %142 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%119, %x5Fbflag1, %t1, %i1, %142) + let %150 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) } -[derivativeMemberDecoration(%143)] -let %111 : _ = key -let %116 : _ = key -struct %144 : Type +[derivativeMemberDecoration(%151)] +let %119 : _ = key +let %124 : _ = key +struct %152 : Type { - field(%143, Array(Float, 5 : Int)) + field(%151, Array(Float, 5 : Int)) } -func %145 : Func(%144) +func %153 : Func(%152) { -block %146: - let %147 : Array(Float, 5 : Int) = call %148() - let %149 : %144 = makeStruct(%147) - return_val(%149) +block %154: + let %155 : Array(Float, 5 : Int) = call %156() + let %157 : %152 = makeStruct(%155) + return_val(%157) } -func %150 : Func(%144) +func %158 : Func(%152) { -block %151( - param %152 : %144, - param %153 : %144): - let %154 : Array(Float, 5 : Int) = get_field(%152, %143) - let %155 : Array(Float, 5 : Int) = get_field(%153, %143) - let %156 : Array(Float, 5 : Int) = call %157(%154, %155) - let %158 : %144 = makeStruct(%156) - return_val(%158) +block %159( + param %160 : %152, + param %161 : %152): + let %162 : Array(Float, 5 : Int) = get_field(%160, %151) + let %163 : Array(Float, 5 : Int) = get_field(%161, %151) + let %164 : Array(Float, 5 : Int) = call %165(%162, %163) + let %166 : %152 = makeStruct(%164) + return_val(%166) } -witness_table %159 : witness_table_t(%IDifferentiable)(%144) +witness_table %167 : witness_table_t(%IDifferentiable)(%152) { - witness_table_entry(%18,%144) + witness_table_entry(%18,%152) - witness_table_entry(%20,%159) + witness_table_entry(%20,%167) - witness_table_entry(%22,%145) + witness_table_entry(%22,%153) - witness_table_entry(%24,%150) + witness_table_entry(%24,%158) } -witness_table %160 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) +witness_table %168 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { - witness_table_entry(%18,%144) + witness_table_entry(%18,%152) - witness_table_entry(%20,%159) + witness_table_entry(%20,%167) - witness_table_entry(%22,%145) + witness_table_entry(%22,%153) - witness_table_entry(%24,%150) + witness_table_entry(%24,%158) } -[derivativeMemberDecoration(%143)] -let %143 : _ = key +[derivativeMemberDecoration(%151)] +let %151 : _ = key +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { - [IntermediateContextFieldDifferentialTypeDecoration(%161)] - field(%111, Array(Float, 5 : Int)) - field(%116, Int) + [IntermediateContextFieldDifferentialTypeDecoration(%169)] + field(%119, Array(Float, 5 : Int)) + field(%124, Int) } [FloatingPointModeOverride(1 : Int)] @@ -8195,355 +8270,355 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type [nameHint("s_bwd_prop_test_simple_loop")] func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { -block %162( +block %170( [nameHint("dpy")] param %dpy1 : InOut(DiffPairUserCode(Float, %75)), [nameHint("_s_dOut")] param %x5Fsx5FdOut : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - unconditionalBranch(%163) - -block %163: - let %164 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %165 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %166 : Ptr(Array(Float, 5 : Int)) = var - store(%166, %165) - store(%166, %164) - let %167 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) - let %168 : Ptr(Int) = var - store(%168, %167) - store(%168, 0 : Int) - let %169 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %170 : Float = GetPrimalUserCode(%169) unconditionalBranch(%171) block %171: + let %172 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %173 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %174 : Ptr(Array(Float, 5 : Int)) = var + store(%174, %173) + store(%174, %172) + let %175 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %176 : Ptr(Int) = var + store(%176, %175) + store(%176, 0 : Int) + let %177 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %178 : Float = GetPrimalUserCode(%177) + unconditionalBranch(%179) + +block %179: [loopMaxIters(4 : Int)] - loop(%172, %173, %172, true, %170, 0 : Int, 0 : Int) + loop(%180, %181, %180, true, %178, 0 : Int, 0 : Int) -block %172( +block %180( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag2 : Bool, [primalInstDecoration] [nameHint("t")] - param %t2 : Float, + param %t3 : Float, [primalInstDecoration] [nameHint("i")] - param %i2 : Int, + param %i3 : Int, [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] param %x5Fpc1 : Int): - let %174 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %175 : Ptr(Array(Float, 5 : Int)) = var - store(%175, %174) - let %176 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%175, %x5Fpc1) - store(%176, %t2) - let %177 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) - let %178 : Ptr(Int) = var - store(%178, %177) - store(%178, %x5Fpc1) - ifElse(%x5Fbflag2, %179, %180, %179) - -block %180: - unconditionalBranch(%173) - -block %173: + let %182 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %183 : Ptr(Array(Float, 5 : Int)) = var + store(%183, %182) + let %184 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%183, %x5Fpc1) + store(%184, %t3) + let %185 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %186 : Ptr(Int) = var + store(%186, %185) + store(%186, %x5Fpc1) + ifElse(%x5Fbflag2, %187, %188, %187) + +block %188: unconditionalBranch(%181) block %181: - unconditionalBranch(%182) + unconditionalBranch(%189) + +block %189: + unconditionalBranch(%190) -block %182: - unconditionalBranch(%183) +block %190: + unconditionalBranch(%191) -block %183: - unconditionalBranch(%184) +block %191: + unconditionalBranch(%192) -block %184: - unconditionalBranch(%185) +block %192: + unconditionalBranch(%193) -block %185: - let %186 : Ptr(Float) = var - store(%186, 0 : Float) - let %187 : Ptr(Float) = var - store(%187, 0 : Float) - let %188 : Float = load(%186) - let %189 : Float = add(%x5Fsx5FdOut, %188) - store(%186, %189) - unconditionalBranch(%190) +block %193: + let %194 : Ptr(Float) = var + store(%194, 0 : Float) + let %195 : Ptr(Float) = var + store(%195, 0 : Float) + let %196 : Float = load(%194) + let %197 : Float = add(%x5Fsx5FdOut, %196) + store(%194, %197) + unconditionalBranch(%198) -block %190: - let %191 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %116) - let %192 : Int = sub(%191, 1 : Int) +block %198: + let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) + let %200 : Int = sub(%199, 1 : Int) [loopMaxIters(4 : Int)] - loop(%193, %194, %195, %192) + loop(%201, %202, %203, %200) -block %193( +block %201( [primalInstDecoration] [nameHint("_dc")] param %x5Fdc : Int): - let %196 : Int = add(%x5Fdc, 0 : Int) - let %197 : Float = load(%186) - store(%186, 0 : Float) - let %198 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%198, %199, %200, %199) + let %204 : Int = add(%x5Fdc, 0 : Int) + let %205 : Float = load(%194) + store(%194, 0 : Float) + let %206 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%206, %207, %208, %207) -block %200: - unconditionalBranch(%194, %197) - -block %194( - param %201 : Float): - let %202 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %203 : Float = GetPrimalUserCode(%202) - let %204 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%203, %201) - store(%dpy1, %204) +block %208: + unconditionalBranch(%202, %205) + +block %202( + param %209 : Float): + let %210 : DiffPairUserCode(Float, %75) = load(%dpy1) + let %211 : Float = GetPrimalUserCode(%210) + let %212 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%211, %209) + store(%dpy1, %212) return_val(void_constant) -block %199: - unconditionalBranch(%205) +block %207: + unconditionalBranch(%213) -block %205: +block %213: [primalInstDecoration] - let %206 : Bool = cmpLT(%196, 3 : Int) - ifElse(%206, %207, %208, %209) + let %214 : Bool = cmpLT(%204, 3 : Int) + ifElse(%214, %215, %216, %217) -block %208: - unconditionalBranch(%209, 0 : Int) +block %216: + unconditionalBranch(%217, 0 : Int) -block %207: - unconditionalBranch(%209, 1 : Int) +block %215: + unconditionalBranch(%217, 1 : Int) -block %209( +block %217( [primalInstDecoration] - param %210 : Int): - unconditionalBranch(%211) + param %218 : Int): + unconditionalBranch(%219) -block %211: +block %219: [primalInstDecoration] - let %212 : Bool = cmpNE(%210, 1 : Int) - ifElse(%212, %213, %214, %215) + let %220 : Bool = cmpNE(%218, 1 : Int) + ifElse(%220, %221, %222, %223) -block %214: - unconditionalBranch(%215, true) +block %222: + unconditionalBranch(%223, true) -block %213: - unconditionalBranch(%215, false) +block %221: + unconditionalBranch(%223, false) -block %215( +block %223( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag3 : Bool): - unconditionalBranch(%216) - -block %216: - ifElse(%x5Fbflag3, %217, %218, %219) - -block %218: - unconditionalBranch(%219) + unconditionalBranch(%224) -block %217: - unconditionalBranch(%219) +block %224: + ifElse(%x5Fbflag3, %225, %226, %227) -block %219: - unconditionalBranch(%220) +block %226: + unconditionalBranch(%227) -block %220: - unconditionalBranch(%221, %197) +block %225: + unconditionalBranch(%227) -block %221( - param %222 : Float): - ifElse(%x5Fbflag3, %223, %224, %225) +block %227: + unconditionalBranch(%228) -block %224: - unconditionalBranch(%226, %222) +block %228: + unconditionalBranch(%229, %205) -block %226( - param %227 : Float): - let %228 : Float = load(%186) - let %229 : Float = add(%227, %228) - store(%186, %229) - unconditionalBranch(%225) +block %229( + param %230 : Float): + ifElse(%x5Fbflag3, %231, %232, %233) -block %223: - unconditionalBranch(%230, %222) +block %232: + unconditionalBranch(%234, %230) -block %230( - param %231 : Float): - let %232 : Float = load(%187) - let %233 : Float = add(%231, %232) - store(%187, %233) - unconditionalBranch(%225) +block %234( + param %235 : Float): + let %236 : Float = load(%194) + let %237 : Float = add(%235, %236) + store(%194, %237) + unconditionalBranch(%233) -block %225: - unconditionalBranch(%234) +block %231: + unconditionalBranch(%238, %230) -block %234: - ifElse(%212, %235, %236, %237) +block %238( + param %239 : Float): + let %240 : Float = load(%195) + let %241 : Float = add(%239, %240) + store(%195, %241) + unconditionalBranch(%233) -block %236: - unconditionalBranch(%237) +block %233: + unconditionalBranch(%242) -block %235: - unconditionalBranch(%237) +block %242: + ifElse(%220, %243, %244, %245) -block %237: - unconditionalBranch(%238) +block %244: + unconditionalBranch(%245) -block %238: - let %239 : Float = load(%187) - store(%187, 0 : Float) - ifElse(%206, %240, %241, %242) +block %243: + unconditionalBranch(%245) -block %241: - unconditionalBranch(%243) +block %245: + unconditionalBranch(%246) -block %243: - unconditionalBranch(%242) +block %246: + let %247 : Float = load(%195) + store(%195, 0 : Float) + ifElse(%214, %248, %249, %250) -block %240: - unconditionalBranch(%244, %239) +block %249: + unconditionalBranch(%251) -block %244( - param %245 : Float): - let %246 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %247 : Ptr(Array(Float, 5 : Int)) = var - store(%247, %246) - let %248 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%247, %x5Fdc) - let %249 : Float = load(%248) - let %250 : Float = mul(%249, %245) - let %251 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %111) - let %252 : Ptr(Array(Float, 5 : Int)) = var - store(%252, %251) - let %253 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%252, %x5Fdc) - let %254 : Float = load(%253) - let %255 : Float = mul(%254, %245) - let %256 : Float = load(%186) - let %257 : Float = add(%250, %255) - let %258 : Float = add(%257, %256) - store(%186, %258) - unconditionalBranch(%242) +block %251: + unconditionalBranch(%250) -block %242: - unconditionalBranch(%195) +block %248: + unconditionalBranch(%252, %247) + +block %252( + param %253 : Float): + let %254 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %255 : Ptr(Array(Float, 5 : Int)) = var + store(%255, %254) + let %256 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%255, %x5Fdc) + let %257 : Float = load(%256) + let %258 : Float = mul(%257, %253) + let %259 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) + let %260 : Ptr(Array(Float, 5 : Int)) = var + store(%260, %259) + let %261 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%260, %x5Fdc) + let %262 : Float = load(%261) + let %263 : Float = mul(%262, %253) + let %264 : Float = load(%194) + let %265 : Float = add(%258, %263) + let %266 : Float = add(%265, %264) + store(%194, %266) + unconditionalBranch(%250) + +block %250: + unconditionalBranch(%203) -block %195: +block %203: [primalInstDecoration] - let %259 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%193, %259) + let %267 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%201, %267) -block %179: - unconditionalBranch(%260) +block %187: + unconditionalBranch(%268) -block %260: +block %268: [primalInstDecoration] - let %261 : Bool = cmpLT(%i2, 3 : Int) - ifElse(%261, %262, %263, %264) + let %269 : Bool = cmpLT(%i3, 3 : Int) + ifElse(%269, %270, %271, %272) -block %263: - unconditionalBranch(%264, 0 : Int, 0 : Float) +block %271: + unconditionalBranch(%272, 0 : Int, 0 : Float) -block %262: +block %270: [primalInstDecoration] - let %265 : Float = mul(%t2, %t2) - unconditionalBranch(%264, 1 : Int, %265) + let %273 : Float = mul(%t3, %t3) + unconditionalBranch(%272, 1 : Int, %273) -block %264( +block %272( [primalInstDecoration] - param %266 : Int, + param %274 : Int, [primalInstDecoration] - param %267 : Float): - unconditionalBranch(%268) + param %275 : Float): + unconditionalBranch(%276) -block %268: +block %276: [primalInstDecoration] - let %269 : Bool = cmpNE(%266, 1 : Int) - ifElse(%269, %270, %271, %272) + let %277 : Bool = cmpNE(%274, 1 : Int) + ifElse(%277, %278, %279, %280) -block %271: - unconditionalBranch(%272, %x5Fbflag2) +block %279: + unconditionalBranch(%280, %x5Fbflag2) -block %270: - unconditionalBranch(%272, false) +block %278: + unconditionalBranch(%280, false) -block %272( +block %280( [primalInstDecoration] [nameHint("_bflag")] param %x5Fbflag4 : Bool): - unconditionalBranch(%273) + unconditionalBranch(%281) -block %273: - ifElse(%x5Fbflag4, %274, %275, %276) +block %281: + ifElse(%x5Fbflag4, %282, %283, %284) -block %275: - unconditionalBranch(%276, %t2, %i2) +block %283: + unconditionalBranch(%284, %t3, %i3) -block %274: +block %282: [primalInstDecoration] - let %277 : Int = add(%i2, 1 : Int) - unconditionalBranch(%276, %267, %277) + let %285 : Int = add(%i3, 1 : Int) + unconditionalBranch(%284, %275, %285) -block %276( +block %284( [primalInstDecoration] [nameHint("t")] - param %t3 : Float, + param %t4 : Float, [primalInstDecoration] [nameHint("i")] - param %i3 : Int): + param %i4 : Int): [primalInstDecoration] - let %278 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%172, %x5Fbflag4, %t3, %i3, %278) + let %286 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%180, %x5Fbflag4, %t4, %i4, %286) } [backwardDifferentiable] -func %157 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) -{ -block %279( - param %280 : Array(Float, 5 : Int), - param %281 : Array(Float, 5 : Int)): - let %282 : Ptr(Array(Float, 5 : Int)) = var - loop(%283, %284, %283, 0 : Int) +func %165 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) +{ +block %287( + param %288 : Array(Float, 5 : Int), + param %289 : Array(Float, 5 : Int)): + let %290 : Ptr(Array(Float, 5 : Int)) = var + loop(%291, %292, %291, 0 : Int) + +block %291( + param %293 : Int): + let %294 : Bool = cmpLT(%293, 5 : Int) + ifElse(%294, %295, %296, %296) + +block %295: + let %297 : Float = getElement(%288, %293) + let %298 : Float = getElement(%289, %293) + let %299 : Float = add(%297, %298) + let %300 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%290, %293) + store(%300, %299) + unconditionalBranch(%301) -block %283( - param %285 : Int): - let %286 : Bool = cmpLT(%285, 5 : Int) - ifElse(%286, %287, %288, %288) - -block %287: - let %289 : Float = getElement(%280, %285) - let %290 : Float = getElement(%281, %285) - let %291 : Float = add(%289, %290) - let %292 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%282, %285) - store(%292, %291) - unconditionalBranch(%293) - -block %288: - unconditionalBranch(%284) +block %296: + unconditionalBranch(%292) -block %284: - let %294 : Array(Float, 5 : Int) = load(%282) - return_val(%294) +block %292: + let %302 : Array(Float, 5 : Int) = load(%290) + return_val(%302) -block %293: - let %295 : Int = add(%285, 1 : Int) - unconditionalBranch(%283, %295) +block %301: + let %303 : Int = add(%293, 1 : Int) + unconditionalBranch(%291, %303) } -func %148 : Func(Array(Float, 5 : Int)) +func %156 : Func(Array(Float, 5 : Int)) { -block %296: - let %297 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) - return_val(%297) +block %304: + let %305 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) + return_val(%305) } -witness_table %161 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) +witness_table %169 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) { witness_table_entry(%18,Array(Float, 5 : Int)) - witness_table_entry(%20,%161) + witness_table_entry(%20,%169) - witness_table_entry(%24,%157) + witness_table_entry(%24,%165) - witness_table_entry(%22,%148) + witness_table_entry(%22,%156) } @@ -8578,16 +8653,47 @@ let %10 : Void = typeLayout [keepAlive] global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") let %13 : _ = key +[readNone] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %17( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%18, %19, %20, %y, 0 : Int) + +block %18( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %21 : Bool = cmpLT(%i, 3 : Int) + ifElse(%21, %22, %19, %22) + +block %19: + return_val(%t) + +block %22: + let %23 : Float = mul(%t, %t) + unconditionalBranch(%20) + +block %20: + let %24 : Int = add(%i, 1 : Int) + unconditionalBranch(%18, %23, %24) +} [export("_ST4core17IBufferDataLayout")] [nameHint("IBufferDataLayout")] let %IBufferDataLayout : Type = interface [export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %17 : witness_table_t(%IBufferDataLayout)(DefaultLayout); +witness_table %25 : witness_table_t(%IBufferDataLayout)(DefaultLayout); [nameHint("outputBuffer")] [export("_SVR15reverse_2Dxloop12outputBuffer")] [layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %17) = global_param +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %25) = global_param [keepAlive] [entryPoint(6 : Int, "computeMain", "reverse-loop")] [numThreads(1 : Int, 1 : Int, 1 : Int)] @@ -8596,29 +8702,29 @@ let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %17) = global_para [layout(%7)] func %computeMain : Func(Void, Vec(UInt, 3 : Int)) { -block %18( +block %26( [layout(%14)] [nameHint("dispatchThreadID")] [semantic("SV_DispatchThreadID", 0 : Int)] param %dispatchThreadID : Vec(UInt, 3 : Int)): [nameHint("dpa")] let %dpa : Ptr(%DiffPairx5Ffloat) = var - let %19 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) - store(%dpa, %19) + let %27 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) + store(%dpa, %27) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %20 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %21 : %DiffPairx5Ffloat = load(%dpa) - let %22 : Float = get_field(%21, %differential) - store(%20, %22) + let %28 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %29 : %DiffPairx5Ffloat = load(%dpa) + let %30 : Float = get_field(%29, %differential) + store(%28, %30) [nameHint("dpa")] let %dpa1 : Ptr(%DiffPairx5Ffloat) = var - let %23 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) - store(%dpa1, %23) + let %31 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) + store(%dpa1, %31) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %24 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %25 : %DiffPairx5Ffloat = load(%dpa1) - let %26 : Float = get_field(%25, %differential) - store(%24, %26) + let %32 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %33 : %DiffPairx5Ffloat = load(%dpa1) + let %34 : Float = get_field(%33, %differential) + store(%32, %34) return_val(void_constant) } [readNone] @@ -8627,15 +8733,15 @@ block %18( [nameHint("s_bwd_test_simple_loop")] func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) { -block %27( - param %28 : InOut(%DiffPairx5Ffloat), - param %29 : Float): - let %30 : %DiffPairx5Ffloat = load(%28) - let %31 : Float = get_field(%30, %primal) - let %32 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %33 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%31, %32) - let %34 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%32) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%28, %29, %34) +block %35( + param %36 : InOut(%DiffPairx5Ffloat), + param %37 : Float): + let %38 : %DiffPairx5Ffloat = load(%36) + let %39 : Float = get_field(%38, %primal) + let %40 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %41 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%39, %40) + let %42 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%40) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%36, %37, %42) return_val(void_constant) } [readNone] @@ -8644,102 +8750,102 @@ block %27( [backwardDifferentiable] func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) { -block %35( +block %43( [nameHint("dpy")] param %dpy : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - let %36 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %37 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%36, 0 : Int) - store(%x5Fsx5Fdiffx5Fctx, %37) - let %38 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %39) - let %40 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%38, %40) - let %41 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %42) - store(%41, 0 : Int) + let %44 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %45 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%44, 0 : Int) + store(%x5Fsx5Fdiffx5Fctx, %45) + let %46 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %47) + let %48 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%46, %48) + let %49 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %50) + store(%49, 0 : Int) [loopMaxIters(4 : Int)] - loop(%43, %44, %43, true, %dpy, 0 : Int, 0 : Int) + loop(%51, %52, %51, true, %dpy, 0 : Int, 0 : Int) -block %43( +block %51( [nameHint("_bflag")] param %x5Fbflag : Bool, [nameHint("t")] - param %t : Float, + param %t1 : Float, [nameHint("i")] - param %i : Int, + param %i1 : Int, [nameHint("_pc")] param %x5Fpc : Int): - let %45 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%38, %x5Fpc) - store(%45, %t) - store(%41, %x5Fpc) - ifElse(%x5Fbflag, %46, %47, %46) - -block %47: - unconditionalBranch(%44) - -block %44: - return_val(%t) - -block %46: - unconditionalBranch(%48) - -block %48: - let %49 : Bool = cmpLT(%i, 3 : Int) - ifElse(%49, %50, %51, %52) + let %53 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%46, %x5Fpc) + store(%53, %t1) + store(%49, %x5Fpc) + ifElse(%x5Fbflag, %54, %55, %54) -block %51: - unconditionalBranch(%52, 0 : Int, 0 : Float) +block %55: + unconditionalBranch(%52) -block %50: - let %53 : Float = mul(%t, %t) - unconditionalBranch(%52, 1 : Int, %53) +block %52: + return_val(%t1) -block %52( - param %54 : Int, - param %55 : Float): +block %54: unconditionalBranch(%56) block %56: - let %57 : Bool = cmpNE(%54, 1 : Int) + let %57 : Bool = cmpLT(%i1, 3 : Int) ifElse(%57, %58, %59, %60) block %59: - unconditionalBranch(%60, %x5Fbflag) + unconditionalBranch(%60, 0 : Int, 0 : Float) block %58: - unconditionalBranch(%60, false) + let %61 : Float = mul(%t1, %t1) + unconditionalBranch(%60, 1 : Int, %61) block %60( + param %62 : Int, + param %63 : Float): + unconditionalBranch(%64) + +block %64: + let %65 : Bool = cmpNE(%62, 1 : Int) + ifElse(%65, %66, %67, %68) + +block %67: + unconditionalBranch(%68, %x5Fbflag) + +block %66: + unconditionalBranch(%68, false) + +block %68( [nameHint("_bflag")] param %x5Fbflag1 : Bool): - unconditionalBranch(%61) + unconditionalBranch(%69) -block %61: - ifElse(%x5Fbflag1, %62, %63, %64) +block %69: + ifElse(%x5Fbflag1, %70, %71, %72) -block %63: - unconditionalBranch(%64, %t, %i) +block %71: + unconditionalBranch(%72, %t1, %i1) -block %62: - let %65 : Int = add(%i, 1 : Int) - unconditionalBranch(%64, %55, %65) +block %70: + let %73 : Int = add(%i1, 1 : Int) + unconditionalBranch(%72, %63, %73) -block %64( +block %72( [nameHint("t")] - param %t1 : Float, + param %t2 : Float, [nameHint("i")] - param %i1 : Int): - let %66 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%43, %x5Fbflag1, %t1, %i1, %66) + param %i2 : Int): + let %74 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%51, %x5Fbflag1, %t2, %i2, %74) } -let %39 : _ = key -let %42 : _ = key +let %47 : _ = key +let %50 : _ = key +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { - field(%39, Array(Float, 5 : Int)) - field(%42, Int) + field(%47, Array(Float, 5 : Int)) + field(%50, Int) } [readNone] @@ -8748,172 +8854,172 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type [nameHint("s_bwd_prop_test_simple_loop")] func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { -block %67( +block %75( [nameHint("dpy")] param %dpy1 : InOut(%DiffPairx5Ffloat), [nameHint("_s_dOut")] param %x5Fsx5FdOut : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - let %68 : %DiffPairx5Ffloat = load(%dpy1) - let %69 : Float = get_field(%68, %primal) + let %76 : %DiffPairx5Ffloat = load(%dpy1) + let %77 : Float = get_field(%76, %primal) [loopMaxIters(4 : Int)] - loop(%70, %71, %70, true, %69, 0 : Int, 0 : Int) + loop(%78, %79, %78, true, %77, 0 : Int, 0 : Int) -block %70( +block %78( [nameHint("_bflag")] param %x5Fbflag2 : Bool, [nameHint("t")] - param %t2 : Float, + param %t3 : Float, [nameHint("i")] - param %i2 : Int, + param %i3 : Int, [nameHint("_pc")] param %x5Fpc1 : Int): - let %72 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) - let %73 : Ptr(Array(Float, 5 : Int)) = var - store(%73, %72) - let %74 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%73, %x5Fpc1) - store(%74, %t2) - ifElse(%x5Fbflag2, %75, %76, %75) - -block %76: - unconditionalBranch(%71) + let %80 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %47) + let %81 : Ptr(Array(Float, 5 : Int)) = var + store(%81, %80) + let %82 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%81, %x5Fpc1) + store(%82, %t3) + ifElse(%x5Fbflag2, %83, %84, %83) + +block %84: + unconditionalBranch(%79) -block %71: - unconditionalBranch(%77) +block %79: + unconditionalBranch(%85) -block %77: - let %78 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %42) - let %79 : Int = sub(%78, 1 : Int) +block %85: + let %86 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %50) + let %87 : Int = sub(%86, 1 : Int) [loopMaxIters(4 : Int)] - loop(%80, %81, %82, %79, %x5Fsx5FdOut) + loop(%88, %89, %90, %87, %x5Fsx5FdOut) -block %80( +block %88( [nameHint("_dc")] param %x5Fdc : Int, - param %83 : Float): - let %84 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%84, %85, %86, %85) + param %91 : Float): + let %92 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%92, %93, %94, %93) -block %86: - unconditionalBranch(%81) +block %94: + unconditionalBranch(%89) -block %81: - let %87 : %DiffPairx5Ffloat = load(%dpy1) - let %88 : Float = get_field(%87, %primal) - let %89 : %DiffPairx5Ffloat = makeStruct(%88, %83) - store(%dpy1, %89) +block %89: + let %95 : %DiffPairx5Ffloat = load(%dpy1) + let %96 : Float = get_field(%95, %primal) + let %97 : %DiffPairx5Ffloat = makeStruct(%96, %91) + store(%dpy1, %97) return_val(void_constant) -block %85: - unconditionalBranch(%90) - -block %90: - let %91 : Bool = cmpLT(%x5Fdc, 3 : Int) - ifElse(%91, %92, %93, %94) - block %93: - unconditionalBranch(%94, 0 : Int) - -block %92: - unconditionalBranch(%94, 1 : Int) + unconditionalBranch(%98) -block %94( - param %95 : Int): - unconditionalBranch(%96) +block %98: + let %99 : Bool = cmpLT(%x5Fdc, 3 : Int) + ifElse(%99, %100, %101, %102) -block %96: - let %97 : Bool = cmpNE(%95, 1 : Int) - let %98 : Bool = not(%97) - ifElse(%98, %99, %100, %101) +block %101: + unconditionalBranch(%102, 0 : Int) block %100: - unconditionalBranch(%101, 0 : Float, %83) - -block %99: - unconditionalBranch(%101, %83, 0 : Float) + unconditionalBranch(%102, 1 : Int) -block %101( - param %102 : Float, - param %103 : Float): +block %102( + param %103 : Int): unconditionalBranch(%104) block %104: - ifElse(%91, %105, %106, %107) + let %105 : Bool = cmpNE(%103, 1 : Int) + let %106 : Bool = not(%105) + ifElse(%106, %107, %108, %109) -block %106: - unconditionalBranch(%107, %103) - -block %105: - let %108 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) - let %109 : Float = getElement(%108, %x5Fdc) - let %110 : Float = mul(%109, %102) - let %111 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) - let %112 : Float = getElement(%111, %x5Fdc) - let %113 : Float = mul(%112, %102) - let %114 : Float = add(%110, %113) - let %115 : Float = add(%114, %103) - unconditionalBranch(%107, %115) - -block %107( - param %116 : Float): - unconditionalBranch(%82) - -block %82: - let %117 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%80, %117, %116) - -block %75: - unconditionalBranch(%118) +block %108: + unconditionalBranch(%109, 0 : Float, %91) -block %118: - let %119 : Bool = cmpLT(%i2, 3 : Int) - ifElse(%119, %120, %121, %122) +block %107: + unconditionalBranch(%109, %91, 0 : Float) + +block %109( + param %110 : Float, + param %111 : Float): + unconditionalBranch(%112) + +block %112: + ifElse(%99, %113, %114, %115) + +block %114: + unconditionalBranch(%115, %111) + +block %113: + let %116 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %47) + let %117 : Float = getElement(%116, %x5Fdc) + let %118 : Float = mul(%117, %110) + let %119 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %47) + let %120 : Float = getElement(%119, %x5Fdc) + let %121 : Float = mul(%120, %110) + let %122 : Float = add(%118, %121) + let %123 : Float = add(%122, %111) + unconditionalBranch(%115, %123) -block %121: - unconditionalBranch(%122, 0 : Int, 0 : Float) +block %115( + param %124 : Float): + unconditionalBranch(%90) -block %120: - let %123 : Float = mul(%t2, %t2) - unconditionalBranch(%122, 1 : Int, %123) +block %90: + let %125 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%88, %125, %124) -block %122( - param %124 : Int, - param %125 : Float): +block %83: unconditionalBranch(%126) block %126: - let %127 : Bool = cmpNE(%124, 1 : Int) + let %127 : Bool = cmpLT(%i3, 3 : Int) ifElse(%127, %128, %129, %130) block %129: - unconditionalBranch(%130, %x5Fbflag2) + unconditionalBranch(%130, 0 : Int, 0 : Float) block %128: - unconditionalBranch(%130, false) + let %131 : Float = mul(%t3, %t3) + unconditionalBranch(%130, 1 : Int, %131) block %130( + param %132 : Int, + param %133 : Float): + unconditionalBranch(%134) + +block %134: + let %135 : Bool = cmpNE(%132, 1 : Int) + ifElse(%135, %136, %137, %138) + +block %137: + unconditionalBranch(%138, %x5Fbflag2) + +block %136: + unconditionalBranch(%138, false) + +block %138( [nameHint("_bflag")] param %x5Fbflag3 : Bool): - unconditionalBranch(%131) + unconditionalBranch(%139) -block %131: - ifElse(%x5Fbflag3, %132, %133, %134) +block %139: + ifElse(%x5Fbflag3, %140, %141, %142) -block %133: - unconditionalBranch(%134, %t2, %i2) +block %141: + unconditionalBranch(%142, %t3, %i3) -block %132: - let %135 : Int = add(%i2, 1 : Int) - unconditionalBranch(%134, %125, %135) +block %140: + let %143 : Int = add(%i3, 1 : Int) + unconditionalBranch(%142, %133, %143) -block %134( +block %142( [nameHint("t")] - param %t3 : Float, + param %t4 : Float, [nameHint("i")] - param %i3 : Int): - let %136 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%70, %x5Fbflag3, %t3, %i3, %136) + param %i4 : Int): + let %144 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%78, %x5Fbflag3, %t4, %i4, %144) } [nameHint("primal")] let %primal : _ = key @@ -8948,9 +9054,40 @@ let %11 : Void = typeLayout [keepAlive] global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") let %14 : _ = key +[readNone] +[backwardDifferentiable] +[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] +[nameHint("test_simple_loop")] +func %testx5Fsimplex5Floop : Func(Float, Float) +{ +block %18( + [nameHint("y")] + param %y : Float): + [loopMaxIters(3 : Int)] + loop(%19, %20, %21, %y, 0 : Int) + +block %19( + [nameHint("t")] + param %t : Float, + [nameHint("i")] + param %i : Int): + let %22 : Bool = cmpLT(%i, 3 : Int) + ifElse(%22, %23, %20, %23) + +block %20: + return_val(%t) + +block %23: + let %24 : Float = mul(%t, %t) + unconditionalBranch(%21) + +block %21: + let %25 : Int = add(%i, 1 : Int) + unconditionalBranch(%19, %24, %25) +} [SequentialIDDecoration(0 : UInt)] [export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %18 : witness_table_t(0 : Int)(DefaultLayout); +witness_table %26 : witness_table_t(0 : Int)(DefaultLayout); [nameHint("outputBuffer")] [export("_SVR15reverse_2Dxloop12outputBuffer")] @@ -8964,29 +9101,29 @@ let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %7) = global_param [layout(%8)] func %computeMain : Func(Void, Vec(UInt, 3 : Int)) { -block %19( +block %27( [layout(%15)] [nameHint("dispatchThreadID")] [semantic("SV_DispatchThreadID", 0 : Int)] param %dispatchThreadID : Vec(UInt, 3 : Int)): [nameHint("dpa")] let %dpa : Ptr(%DiffPairx5Ffloat) = var - let %20 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) - store(%dpa, %20) + let %28 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) + store(%dpa, %28) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %21 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %22 : %DiffPairx5Ffloat = load(%dpa) - let %23 : Float = get_field(%22, %differential) - store(%21, %23) + let %29 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %30 : %DiffPairx5Ffloat = load(%dpa) + let %31 : Float = get_field(%30, %differential) + store(%29, %31) [nameHint("dpa")] let %dpa1 : Ptr(%DiffPairx5Ffloat) = var - let %24 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) - store(%dpa1, %24) + let %32 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) + store(%dpa1, %32) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %25 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %26 : %DiffPairx5Ffloat = load(%dpa1) - let %27 : Float = get_field(%26, %differential) - store(%25, %27) + let %33 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %34 : %DiffPairx5Ffloat = load(%dpa1) + let %35 : Float = get_field(%34, %differential) + store(%33, %35) return_val(void_constant) } [readNone] @@ -8995,15 +9132,15 @@ block %19( [nameHint("s_bwd_test_simple_loop")] func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) { -block %28( - param %29 : InOut(%DiffPairx5Ffloat), - param %30 : Float): - let %31 : %DiffPairx5Ffloat = load(%29) - let %32 : Float = get_field(%31, %primal) - let %33 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %34 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%32, %33) - let %35 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%33) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%29, %30, %35) +block %36( + param %37 : InOut(%DiffPairx5Ffloat), + param %38 : Float): + let %39 : %DiffPairx5Ffloat = load(%37) + let %40 : Float = get_field(%39, %primal) + let %41 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %42 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%40, %41) + let %43 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%41) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%37, %38, %43) return_val(void_constant) } [readNone] @@ -9012,102 +9149,102 @@ block %28( [backwardDifferentiable] func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) { -block %36( +block %44( [nameHint("dpy")] param %dpy : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - let %37 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %38 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%37, 0 : Int) - store(%x5Fsx5Fdiffx5Fctx, %38) - let %39 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %40) - let %41 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%39, %41) - let %42 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %43) - store(%42, 0 : Int) + let %45 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %46 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%45, 0 : Int) + store(%x5Fsx5Fdiffx5Fctx, %46) + let %47 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %48) + let %49 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%47, %49) + let %50 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %51) + store(%50, 0 : Int) [loopMaxIters(4 : Int)] - loop(%44, %45, %44, true, %dpy, 0 : Int, 0 : Int) + loop(%52, %53, %52, true, %dpy, 0 : Int, 0 : Int) -block %44( +block %52( [nameHint("_bflag")] param %x5Fbflag : Bool, [nameHint("t")] - param %t : Float, + param %t1 : Float, [nameHint("i")] - param %i : Int, + param %i1 : Int, [nameHint("_pc")] param %x5Fpc : Int): - let %46 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%39, %x5Fpc) - store(%46, %t) - store(%42, %x5Fpc) - ifElse(%x5Fbflag, %47, %48, %47) + let %54 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%47, %x5Fpc) + store(%54, %t1) + store(%50, %x5Fpc) + ifElse(%x5Fbflag, %55, %56, %55) -block %48: - unconditionalBranch(%45) - -block %45: - return_val(%t) - -block %47: - unconditionalBranch(%49) - -block %49: - let %50 : Bool = cmpLT(%i, 3 : Int) - ifElse(%50, %51, %52, %53) - -block %52: - unconditionalBranch(%53, 0 : Int, 0 : Float) +block %56: + unconditionalBranch(%53) -block %51: - let %54 : Float = mul(%t, %t) - unconditionalBranch(%53, 1 : Int, %54) +block %53: + return_val(%t1) -block %53( - param %55 : Int, - param %56 : Float): +block %55: unconditionalBranch(%57) block %57: - let %58 : Bool = cmpNE(%55, 1 : Int) + let %58 : Bool = cmpLT(%i1, 3 : Int) ifElse(%58, %59, %60, %61) block %60: - unconditionalBranch(%61, %x5Fbflag) + unconditionalBranch(%61, 0 : Int, 0 : Float) block %59: - unconditionalBranch(%61, false) + let %62 : Float = mul(%t1, %t1) + unconditionalBranch(%61, 1 : Int, %62) block %61( + param %63 : Int, + param %64 : Float): + unconditionalBranch(%65) + +block %65: + let %66 : Bool = cmpNE(%63, 1 : Int) + ifElse(%66, %67, %68, %69) + +block %68: + unconditionalBranch(%69, %x5Fbflag) + +block %67: + unconditionalBranch(%69, false) + +block %69( [nameHint("_bflag")] param %x5Fbflag1 : Bool): - unconditionalBranch(%62) + unconditionalBranch(%70) -block %62: - ifElse(%x5Fbflag1, %63, %64, %65) +block %70: + ifElse(%x5Fbflag1, %71, %72, %73) -block %64: - unconditionalBranch(%65, %t, %i) +block %72: + unconditionalBranch(%73, %t1, %i1) -block %63: - let %66 : Int = add(%i, 1 : Int) - unconditionalBranch(%65, %56, %66) +block %71: + let %74 : Int = add(%i1, 1 : Int) + unconditionalBranch(%73, %64, %74) -block %65( +block %73( [nameHint("t")] - param %t1 : Float, + param %t2 : Float, [nameHint("i")] - param %i1 : Int): - let %67 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%44, %x5Fbflag1, %t1, %i1, %67) + param %i2 : Int): + let %75 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%52, %x5Fbflag1, %t2, %i2, %75) } -let %40 : _ = key -let %43 : _ = key +let %48 : _ = key +let %51 : _ = key +[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { - field(%40, Array(Float, 5 : Int)) - field(%43, Int) + field(%48, Array(Float, 5 : Int)) + field(%51, Int) } [readNone] @@ -9116,195 +9253,187 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type [nameHint("s_bwd_prop_test_simple_loop")] func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { -block %68( +block %76( [nameHint("dpy")] param %dpy1 : InOut(%DiffPairx5Ffloat), [nameHint("_s_dOut")] param %x5Fsx5FdOut : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - let %69 : %DiffPairx5Ffloat = load(%dpy1) - let %70 : Float = get_field(%69, %primal) + let %77 : %DiffPairx5Ffloat = load(%dpy1) + let %78 : Float = get_field(%77, %primal) [loopMaxIters(4 : Int)] - loop(%71, %72, %71, true, %70, 0 : Int, 0 : Int) + loop(%79, %80, %79, true, %78, 0 : Int, 0 : Int) -block %71( +block %79( [nameHint("_bflag")] param %x5Fbflag2 : Bool, [nameHint("t")] - param %t2 : Float, + param %t3 : Float, [nameHint("i")] - param %i2 : Int, + param %i3 : Int, [nameHint("_pc")] param %x5Fpc1 : Int): - let %73 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) - let %74 : Ptr(Array(Float, 5 : Int)) = var - store(%74, %73) - let %75 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%74, %x5Fpc1) - store(%75, %t2) - ifElse(%x5Fbflag2, %76, %77, %76) + let %81 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %48) + let %82 : Ptr(Array(Float, 5 : Int)) = var + store(%82, %81) + let %83 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%82, %x5Fpc1) + store(%83, %t3) + ifElse(%x5Fbflag2, %84, %85, %84) -block %77: - unconditionalBranch(%72) +block %85: + unconditionalBranch(%80) -block %72: - unconditionalBranch(%78) +block %80: + unconditionalBranch(%86) -block %78: - let %79 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %43) - let %80 : Int = sub(%79, 1 : Int) +block %86: + let %87 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %51) + let %88 : Int = sub(%87, 1 : Int) [loopMaxIters(4 : Int)] - loop(%81, %82, %83, %80, %x5Fsx5FdOut) + loop(%89, %90, %91, %88, %x5Fsx5FdOut) -block %81( +block %89( [nameHint("_dc")] param %x5Fdc : Int, - param %84 : Float): - let %85 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%85, %86, %87, %86) - -block %87: - unconditionalBranch(%82) - -block %82: - let %88 : %DiffPairx5Ffloat = load(%dpy1) - let %89 : Float = get_field(%88, %primal) - let %90 : %DiffPairx5Ffloat = makeStruct(%89, %84) - store(%dpy1, %90) - return_val(void_constant) + param %92 : Float): + let %93 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%93, %94, %95, %94) -block %86: - unconditionalBranch(%91) +block %95: + unconditionalBranch(%90) -block %91: - let %92 : Bool = cmpLT(%x5Fdc, 3 : Int) - ifElse(%92, %93, %94, %95) +block %90: + let %96 : %DiffPairx5Ffloat = load(%dpy1) + let %97 : Float = get_field(%96, %primal) + let %98 : %DiffPairx5Ffloat = makeStruct(%97, %92) + store(%dpy1, %98) + return_val(void_constant) block %94: - unconditionalBranch(%95, 0 : Int) + unconditionalBranch(%99) -block %93: - unconditionalBranch(%95, 1 : Int) +block %99: + let %100 : Bool = cmpLT(%x5Fdc, 3 : Int) + ifElse(%100, %101, %102, %103) -block %95( - param %96 : Int): - unconditionalBranch(%97) - -block %97: - let %98 : Bool = cmpNE(%96, 1 : Int) - let %99 : Bool = not(%98) - ifElse(%99, %100, %101, %102) +block %102: + unconditionalBranch(%103, 0 : Int) block %101: - unconditionalBranch(%102, 0 : Float, %84) + unconditionalBranch(%103, 1 : Int) -block %100: - unconditionalBranch(%102, %84, 0 : Float) - -block %102( - param %103 : Float, - param %104 : Float): +block %103( + param %104 : Int): unconditionalBranch(%105) block %105: - ifElse(%92, %106, %107, %108) - -block %107: - unconditionalBranch(%108, %104) - -block %106: - let %109 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) - let %110 : Float = getElement(%109, %x5Fdc) - let %111 : Float = mul(%110, %103) - let %112 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) - let %113 : Float = getElement(%112, %x5Fdc) - let %114 : Float = mul(%113, %103) - let %115 : Float = add(%111, %114) - let %116 : Float = add(%115, %104) - unconditionalBranch(%108, %116) - -block %108( - param %117 : Float): - unconditionalBranch(%83) - -block %83: - let %118 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%81, %118, %117) - -block %76: - unconditionalBranch(%119) + let %106 : Bool = cmpNE(%104, 1 : Int) + let %107 : Bool = not(%106) + ifElse(%107, %108, %109, %110) -block %119: - let %120 : Bool = cmpLT(%i2, 3 : Int) - ifElse(%120, %121, %122, %123) +block %109: + unconditionalBranch(%110, 0 : Float, %92) -block %122: - unconditionalBranch(%123, 0 : Int, 0 : Float) +block %108: + unconditionalBranch(%110, %92, 0 : Float) + +block %110( + param %111 : Float, + param %112 : Float): + unconditionalBranch(%113) + +block %113: + ifElse(%100, %114, %115, %116) + +block %115: + unconditionalBranch(%116, %112) + +block %114: + let %117 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %48) + let %118 : Float = getElement(%117, %x5Fdc) + let %119 : Float = mul(%118, %111) + let %120 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %48) + let %121 : Float = getElement(%120, %x5Fdc) + let %122 : Float = mul(%121, %111) + let %123 : Float = add(%119, %122) + let %124 : Float = add(%123, %112) + unconditionalBranch(%116, %124) + +block %116( + param %125 : Float): + unconditionalBranch(%91) -block %121: - let %124 : Float = mul(%t2, %t2) - unconditionalBranch(%123, 1 : Int, %124) +block %91: + let %126 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%89, %126, %125) -block %123( - param %125 : Int, - param %126 : Float): +block %84: unconditionalBranch(%127) block %127: - let %128 : Bool = cmpNE(%125, 1 : Int) + let %128 : Bool = cmpLT(%i3, 3 : Int) ifElse(%128, %129, %130, %131) block %130: - unconditionalBranch(%131, %x5Fbflag2) + unconditionalBranch(%131, 0 : Int, 0 : Float) block %129: - unconditionalBranch(%131, false) + let %132 : Float = mul(%t3, %t3) + unconditionalBranch(%131, 1 : Int, %132) block %131( + param %133 : Int, + param %134 : Float): + unconditionalBranch(%135) + +block %135: + let %136 : Bool = cmpNE(%133, 1 : Int) + ifElse(%136, %137, %138, %139) + +block %138: + unconditionalBranch(%139, %x5Fbflag2) + +block %137: + unconditionalBranch(%139, false) + +block %139( [nameHint("_bflag")] param %x5Fbflag3 : Bool): - unconditionalBranch(%132) + unconditionalBranch(%140) -block %132: - ifElse(%x5Fbflag3, %133, %134, %135) +block %140: + ifElse(%x5Fbflag3, %141, %142, %143) -block %134: - unconditionalBranch(%135, %t2, %i2) +block %142: + unconditionalBranch(%143, %t3, %i3) -block %133: - let %136 : Int = add(%i2, 1 : Int) - unconditionalBranch(%135, %126, %136) +block %141: + let %144 : Int = add(%i3, 1 : Int) + unconditionalBranch(%143, %134, %144) -block %135( +block %143( [nameHint("t")] - param %t3 : Float, + param %t4 : Float, [nameHint("i")] - param %i3 : Int): - let %137 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%71, %x5Fbflag3, %t3, %i3, %137) + param %i4 : Int): + let %145 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%79, %x5Fbflag3, %t4, %i4, %145) } [nameHint("primal")] let %primal : _ = key [nameHint("differential")] let %differential : _ = key ### -checking for checkpointing structures: -checkpoint intermediate struct -sourceLocs: 1514954 (1) -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -[CheckpointIntermediateDecoration] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - field(%1, Array(Float, 5 : Int)) - field(%2, Int) -} +checkpointing context generated for function test_simple_loop + defined at tests/autodiff/reverse-loop.slang:12 + size of context: 24 bytes + 20 bytes used at tests/autodiff/reverse-loop.slang:14 + float t = y; + ^ -tests/autodiff/reverse-loop.slang(12): note: also see pipeline definition -float test_simple_loop(float y) - ^~~~~~~~~~~~~~~~ -size of struct: 24 (4) -fields: sourceLocs: 1514994 (1) - [Offset(0 : Int, 0 : Int)] -field(%1, Array(Float, 5 : Int)) + 4 bytes used at tests/autodiff/reverse-loop.slang:16 + for (int i = 0; i < 3; i++) + ^~~ diff --git a/out.glsl b/out.glsl index f236cc337d..c7362b059f 100644 --- a/out.glsl +++ b/out.glsl @@ -4,6 +4,27 @@ layout(row_major) buffer; layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { float _data[]; } outputBuffer_0; +float test_simple_loop_0(float y_0) +{ + float t_0 = y_0; + int i_0 = 0; + for(;;) + { + if(i_0 < 3) + { + } + else + { + break; + } + float _S1 = t_0 * t_0; + int _S2 = i_0 + 1; + t_0 = _S1; + i_0 = _S2; + } + return t_0; +} + struct DiffPair_float_0 { float primal_0; @@ -12,29 +33,29 @@ struct DiffPair_float_0 struct s_bwd_prop_test_simple_loop_Intermediates_0 { - float _S1[5]; - int _S2; + float _S3[5]; + int _S4; }; float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_0) { - float _S3[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; - _s_diff_ctx_0._S1 = _S3; - _s_diff_ctx_0._S2 = 0; - _s_diff_ctx_0._S1[0] = 0.0; - _s_diff_ctx_0._S1[1] = 0.0; - _s_diff_ctx_0._S1[2] = 0.0; - _s_diff_ctx_0._S1[3] = 0.0; - _s_diff_ctx_0._S1[4] = 0.0; - _s_diff_ctx_0._S2 = 0; + float _S5[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; + _s_diff_ctx_0._S3 = _S5; + _s_diff_ctx_0._S4 = 0; + _s_diff_ctx_0._S3[0] = 0.0; + _s_diff_ctx_0._S3[1] = 0.0; + _s_diff_ctx_0._S3[2] = 0.0; + _s_diff_ctx_0._S3[3] = 0.0; + _s_diff_ctx_0._S3[4] = 0.0; + _s_diff_ctx_0._S4 = 0; bool _bflag_0 = true; - float t_0 = dpy_0; - int i_0 = 0; + float t_1 = dpy_0; + int i_1 = 0; int _pc_0 = 0; for(;;) { - _s_diff_ctx_0._S1[_pc_0] = t_0; - _s_diff_ctx_0._S2 = _pc_0; + _s_diff_ctx_0._S3[_pc_0] = t_1; + _s_diff_ctx_0._S4 = _pc_0; if(_bflag_0) { } @@ -42,38 +63,38 @@ float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_lo { break; } - float _S4; - int _S5; - if(i_0 < 3) + float _S6; + int _S7; + if(i_1 < 3) { - float _S6 = t_0 * t_0; - _S5 = 1; - _S4 = _S6; + float _S8 = t_1 * t_1; + _S7 = 1; + _S6 = _S8; } else { - _S5 = 0; - _S4 = 0.0; + _S7 = 0; + _S6 = 0.0; } - if(_S5 != 1) + if(_S7 != 1) { _bflag_0 = false; } if(_bflag_0) { - int _S7 = i_0 + 1; - t_0 = _S4; - i_0 = _S7; + int _S9 = i_1 + 1; + t_1 = _S6; + i_1 = _S9; } _pc_0 = _pc_0 + 1; } - return t_0; + return t_1; } void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0, s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_1) { - int _dc_0 = _s_diff_ctx_1._S2 - 1; - float _S8 = _s_dOut_0; + int _dc_0 = _s_diff_ctx_1._S4 - 1; + float _S10 = _s_dOut_0; for(;;) { if(_dc_0 >= 0) @@ -83,48 +104,48 @@ void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0 { break; } - bool _S9 = _dc_0 < 3; - int _S10; - if(_S9) + bool _S11 = _dc_0 < 3; + int _S12; + if(_S11) { - _S10 = 1; + _S12 = 1; } else { - _S10 = 0; + _S12 = 0; } - float _S11; - float _S12; - if(!(_S10 != 1)) + float _S13; + float _S14; + if(!(_S12 != 1)) { - _S11 = _S8; - _S12 = 0.0; + _S13 = _S10; + _S14 = 0.0; } else { - _S11 = 0.0; - _S12 = _S8; + _S13 = 0.0; + _S14 = _S10; } - if(_S9) + if(_S11) { - _S8 = _s_diff_ctx_1._S1[_dc_0] * _S11 + _s_diff_ctx_1._S1[_dc_0] * _S11 + _S12; + _S10 = _s_diff_ctx_1._S3[_dc_0] * _S13 + _s_diff_ctx_1._S3[_dc_0] * _S13 + _S14; } else { - _S8 = _S12; + _S10 = _S14; } _dc_0 = _dc_0 - 1; } dpy_1.primal_0 = dpy_1.primal_0; - dpy_1.differential_0 = _S8; + dpy_1.differential_0 = _S10; return; } -void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S13, float _S14) +void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S15, float _S16) { - s_bwd_prop_test_simple_loop_Intermediates_0 _S15; - float _S16 = s_primal_ctx_test_simple_loop_0(_S13.primal_0, _S15); - s_bwd_prop_test_simple_loop_0(_S13, _S14, _S15); + s_bwd_prop_test_simple_loop_Intermediates_0 _S17; + float _S18 = s_primal_ctx_test_simple_loop_0(_S15.primal_0, _S17); + s_bwd_prop_test_simple_loop_0(_S15, _S16, _S17); return; } diff --git a/source/compiler-core/slang-diagnostic-sink.cpp b/source/compiler-core/slang-diagnostic-sink.cpp index 7e3c286eb2..58c143c3f9 100644 --- a/source/compiler-core/slang-diagnostic-sink.cpp +++ b/source/compiler-core/slang-diagnostic-sink.cpp @@ -251,7 +251,7 @@ static void _reduceLength(Index startIndex, const UnownedStringSlice& prefix, St ioBuf = buf; } -static void _sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb) +void _sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb) { SourceFile* sourceFile = sourceView->getSourceFile(); if (!sourceFile) diff --git a/source/compiler-core/slang-diagnostic-sink.h b/source/compiler-core/slang-diagnostic-sink.h index 38a31752f9..aae6c9198a 100644 --- a/source/compiler-core/slang-diagnostic-sink.h +++ b/source/compiler-core/slang-diagnostic-sink.h @@ -360,6 +360,8 @@ class DiagnosticsLookup : public RefObject MemoryArena m_arena; }; +void _sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb); + } #endif diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 25263a6520..9ed1de93f3 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -1532,44 +1532,58 @@ Result linkAndOptimizeIR( #endif validateIRModuleIfEnabled(codeGenContext, irModule); + // Report checkpointing information EndToEndCompileRequest *compileRequest = codeGenContext->isEndToEndCompile(); CompilerOptionSet &optionSet = compileRequest->getOptionSet(); SLANG_ASSERT(compileRequest); - printf("checking for checkpointing structures:\n"); + SourceManager *sourceManager = sink->getSourceManager(); + auto getHumanLoc = [&](const SourceLoc &sourceLoc) { + SourceView *sourceView = sourceManager->findSourceViewRecursively(sourceLoc); + if (sourceView) + return sourceView->getHumaneLoc(sourceLoc); + return HumaneSourceLoc(); + }; + for (auto inst : irModule->getGlobalInsts()) { IRStructType *structType = as(inst); if (!structType) continue; - if (structType->findDecoration()) { - printf("checkpoint intermediate struct\n"); - printf("sourceLocs: %d (%d)\n", - structType->sourceLoc.getRaw(), - structType->sourceLoc.isValid()); - inst->dump(); + auto checkpointDecoration = structType->findDecoration(); + if (checkpointDecoration) { + String nameOrLocation; + + auto func = checkpointDecoration->getSourceFunction(); + if (!func) + nameOrLocation = ""; + else if (auto nameHint = func->findDecoration()) + nameOrLocation = nameHint->getName(); IRSizeAndAlignment sizeInfo; getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); - printf("size of struct: %d (%d)\n", sizeInfo.size, sizeInfo.alignment); - sink->diagnose(structType, Diagnostics::alsoSeePipelineDefinition); + HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); + printf("checkpointing context generated for function %s\n", nameOrLocation.getBuffer()); + printf("\tdefined at %s:%d\n", hloc.pathInfo.foundPath.getBuffer(), hloc.line); + printf("\tsize of context: %d bytes\n\n", sizeInfo.size); - printf("fields:"); for (auto field : structType->getFields()) { - printf("\tsourceLocs: %d (%d)\n", - field->sourceLoc.getRaw(), - field->sourceLoc.isValid()); - printf("\t"); - field->dump(); - IRType *fieldType = field->getFieldType(); - printf("field type: %p\n", fieldType); IRSizeAndAlignment sizeInfo; getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); - printf("\tsize of struct: %d (%d)\n", sizeInfo.size, sizeInfo.alignment); - - sink->diagnose(field, Diagnostics::alsoSeePipelineDefinition); + + HumaneSourceLoc hloc = getHumanLoc(field->sourceLoc); + printf("\t%d bytes used at %s:%d\n", + sizeInfo.size, + hloc.pathInfo.foundPath.getBuffer(), + hloc.line); + + StringBuilder builder; + + SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); + _sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); + printf("%s\n", builder.getBuffer()); } } } diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp index 6cdef473ce..629f37d6e2 100644 --- a/source/slang/slang-ir-autodiff-unzip.cpp +++ b/source/slang/slang-ir-autodiff-unzip.cpp @@ -58,7 +58,6 @@ struct ExtractPrimalFuncContext IRBuilder builder(module); builder.setInsertBefore(func); auto intermediateType = builder.createStructType(); - builder.addDecoration(intermediateType, kIROp_CheckpointIntermediateDecoration); if (auto nameHint = func->findDecoration()) { StringBuilder newName; @@ -76,6 +75,8 @@ struct ExtractPrimalFuncContext builder.setInsertBefore(destFunc); IRFuncType* originalFuncType = nullptr; outIntermediateType = createIntermediateType(destFunc); + + builder.addCheckpointIntermediateDecoration(outIntermediateType, originalFunc); outIntermediateType->sourceLoc = originalFunc->sourceLoc; GenericChildrenMigrationContext migrationContext; @@ -224,12 +225,9 @@ struct ExtractPrimalFuncContext { if (inst->hasUses()) { - printf("adding field to outIntermediatery\n"); - printf("inst: %d (%d)\n", inst->sourceLoc.getRaw(), inst->sourceLoc.isValid()); - inst->dump(); auto field = addIntermediateContextField(cast(inst->getDataType())->getValueType(), outIntermediary); field->sourceLoc = inst->sourceLoc; - field->dump(); + builder.setInsertBefore(inst); auto fieldAddr = builder.emitFieldAddress( inst->getFullType(), outIntermediary, field->getKey()); diff --git a/source/slang/slang-ir-inst-defs.h b/source/slang/slang-ir-inst-defs.h index 934ad0c82b..301a9c789f 100644 --- a/source/slang/slang-ir-inst-defs.h +++ b/source/slang/slang-ir-inst-defs.h @@ -1057,7 +1057,7 @@ INST_RANGE(BindingQuery, GetRegisterIndex, GetRegisterSpace) INST(PreferRecomputeDecoration, PreferRecomputeDecoration, 0, 0) /// Hint that a struct is used for reverse mode checkpointing - INST(CheckpointIntermediateDecoration, CheckpointIntermediateDecoration, 0, 0) + INST(CheckpointIntermediateDecoration, CheckpointIntermediateDecoration, 1, 0) INST_RANGE(CheckpointHintDecoration, PreferCheckpointDecoration, PreferRecomputeDecoration) diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h index cb38627bb1..37f242e55a 100644 --- a/source/slang/slang-ir-insts.h +++ b/source/slang/slang-ir-insts.h @@ -954,6 +954,8 @@ struct IRCheckpointIntermediateDecoration : IRCheckpointHintDecoration kOp = kIROp_CheckpointIntermediateDecoration }; IR_LEAF_ISA(CheckpointIntermediateDecoration) + + IRInst* getSourceFunction() { return getOperand(0); } }; struct IRLoopCounterDecoration : IRDecoration @@ -5160,6 +5162,11 @@ struct IRBuilder { addDecoration(inst, kIROp_MemoryQualifierSetDecoration, getIntValue(getIntType(), flags)); } + + void addCheckpointIntermediateDecoration(IRInst* inst, IRGlobalValueWithCode *func) + { + addDecoration(inst, kIROp_CheckpointIntermediateDecoration, func); + } }; // Helper to establish the source location that will be used From 401185f5b22f9f9254fa500ef9809c90e07d9a51 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 9 Sep 2024 14:21:04 -0700 Subject: [PATCH 06/32] Special behavior for loop counters --- ad-report | 903 +++++++++--------- out.glsl | 121 +-- source/slang/slang-emit.cpp | 123 +-- .../slang/slang-ir-autodiff-primal-hoist.cpp | 2 + source/slang/slang-ir-autodiff-unzip.cpp | 7 + source/slang/slang-ir-autodiff.cpp | 1 + 6 files changed, 562 insertions(+), 595 deletions(-) diff --git a/ad-report b/ad-report index 77ad2fbaef..fefa272a78 100644 --- a/ad-report +++ b/ad-report @@ -3539,7 +3539,7 @@ use with usedVal: let %t : Float = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D622580 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2685A0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param @@ -3551,7 +3551,7 @@ use with usedVal: let %t : Float = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D622580 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2685A0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param @@ -3577,13 +3577,13 @@ let %1 : Int = param use with usedVal: 0 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7A2E3BC0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE245AD0 to storeSet 0 inst with location: 0 (0) use with usedVal: 1 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7A2E3790 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2456A0 to storeSet 1 inst with location: 0 (0) use with usedVal: @@ -3599,7 +3599,7 @@ let %x5Fbflag : Bool = param use with usedVal: -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D617730 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2817E0 to storeSet inst with location: 0 (0) use with usedVal: @@ -3617,7 +3617,7 @@ use with usedVal: let %x5Fpc : Int = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 0000013A7D62D8C8 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2778F8 to storeSet [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] @@ -3649,6 +3649,7 @@ let %x5Fpc : Int = param >> LOOP COUNTER! % localVar: +[loopCounterDecoration] let %1 : Ptr(Int) = var ensureInstAvailable, worklist element: @@ -3682,6 +3683,7 @@ let %1 : Bool = cmpLT(%2, 3 : Int) >> NO OUT OF SCOPE USES ****** (after legalization) # of elements in the store set for hoistInfo: 2 source loc recorded: 1515420 (1) +[loopCounterDecoration] let %1 : Ptr(Int) = var tests/autodiff/reverse-loop.slang(16): note: also see pipeline definition @@ -3700,6 +3702,19 @@ createIntermediate type: struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type; +ADDING FIELD: +let %1 : Ptr(Array(Float, 5 : Int)) = var + +[IntermediateContextFieldDifferentialTypeDecoration(%1)] +field(%2, Array(Float, 5 : Int)) + +ADDING FIELD: +[loopCounterDecoration] +let %1 : Ptr(Int) = var + +[loopCounterDecoration] +field(%1, Int) + ### AFTER-AUTODIFF: undefined let %1 : Void = varLayout(%2, %3) @@ -4117,6 +4132,7 @@ block %116: let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) store(%118, %122) let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + [loopCounterDecoration] let %125 : Ptr(Int) = var store(%125, 0 : Int) store(%123, 0 : Int) @@ -4351,6 +4367,7 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%193)] field(%119, Array(Float, 5 : Int)) + [loopCounterDecoration] field(%124, Int) } @@ -5135,6 +5152,7 @@ block %116: let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) store(%118, %122) let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + [loopCounterDecoration] let %125 : Ptr(Int) = var store(%125, 0 : Int) store(%123, 0 : Int) @@ -5369,6 +5387,7 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%193)] field(%119, Array(Float, 5 : Int)) + [loopCounterDecoration] field(%124, Int) } @@ -6152,6 +6171,7 @@ block %116: let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) store(%118, %122) let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + [loopCounterDecoration] let %125 : Ptr(Int) = var store(%125, 0 : Int) store(%123, 0 : Int) @@ -6386,6 +6406,7 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%193)] field(%119, Array(Float, 5 : Int)) + [loopCounterDecoration] field(%124, Int) } @@ -7172,6 +7193,7 @@ block %116: let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) store(%118, %122) let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + [loopCounterDecoration] let %125 : Ptr(Int) = var store(%125, 0 : Int) store(%123, 0 : Int) @@ -7326,6 +7348,7 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%169)] field(%119, Array(Float, 5 : Int)) + [loopCounterDecoration] field(%124, Int) } @@ -8107,6 +8130,7 @@ block %116: let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) store(%118, %122) let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) + [loopCounterDecoration] let %125 : Ptr(Int) = var store(%125, 0 : Int) store(%123, 0 : Int) @@ -8261,6 +8285,7 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { [IntermediateContextFieldDifferentialTypeDecoration(%169)] field(%119, Array(Float, 5 : Int)) + [loopCounterDecoration] field(%124, Int) } @@ -8626,6 +8651,18 @@ GenericSpecializationDictionary ExistentialFuncSpecializationDictionary ExistentialTypeSpecializationDictionary ### +checkpointing context generated for function test_simple_loop + defined at tests/autodiff/reverse-loop.slang:12 + size of context: 24 bytes + + 20 bytes used for the variable defined at tests/autodiff/reverse-loop.slang:14 + float t = y; + ^ + + 4 bytes used for a loop counter at tests/autodiff/reverse-loop.slang:16 + for (int i = 0; i < 3; i++) + ^~~ + ### BEFORE-LOWER-GENERICS: undefined let %1 : Void = varLayout(%2, %3) @@ -8653,47 +8690,16 @@ let %10 : Void = typeLayout [keepAlive] global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") let %13 : _ = key -[readNone] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %17( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%18, %19, %20, %y, 0 : Int) - -block %18( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %21 : Bool = cmpLT(%i, 3 : Int) - ifElse(%21, %22, %19, %22) - -block %19: - return_val(%t) - -block %22: - let %23 : Float = mul(%t, %t) - unconditionalBranch(%20) - -block %20: - let %24 : Int = add(%i, 1 : Int) - unconditionalBranch(%18, %23, %24) -} [export("_ST4core17IBufferDataLayout")] [nameHint("IBufferDataLayout")] let %IBufferDataLayout : Type = interface [export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %25 : witness_table_t(%IBufferDataLayout)(DefaultLayout); +witness_table %17 : witness_table_t(%IBufferDataLayout)(DefaultLayout); [nameHint("outputBuffer")] [export("_SVR15reverse_2Dxloop12outputBuffer")] [layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %25) = global_param +let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %17) = global_param [keepAlive] [entryPoint(6 : Int, "computeMain", "reverse-loop")] [numThreads(1 : Int, 1 : Int, 1 : Int)] @@ -8702,29 +8708,29 @@ let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %25) = global_para [layout(%7)] func %computeMain : Func(Void, Vec(UInt, 3 : Int)) { -block %26( +block %18( [layout(%14)] [nameHint("dispatchThreadID")] [semantic("SV_DispatchThreadID", 0 : Int)] param %dispatchThreadID : Vec(UInt, 3 : Int)): [nameHint("dpa")] let %dpa : Ptr(%DiffPairx5Ffloat) = var - let %27 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) - store(%dpa, %27) + let %19 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) + store(%dpa, %19) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %28 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %29 : %DiffPairx5Ffloat = load(%dpa) - let %30 : Float = get_field(%29, %differential) - store(%28, %30) + let %20 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %21 : %DiffPairx5Ffloat = load(%dpa) + let %22 : Float = get_field(%21, %differential) + store(%20, %22) [nameHint("dpa")] let %dpa1 : Ptr(%DiffPairx5Ffloat) = var - let %31 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) - store(%dpa1, %31) + let %23 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) + store(%dpa1, %23) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %32 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %33 : %DiffPairx5Ffloat = load(%dpa1) - let %34 : Float = get_field(%33, %differential) - store(%32, %34) + let %24 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %25 : %DiffPairx5Ffloat = load(%dpa1) + let %26 : Float = get_field(%25, %differential) + store(%24, %26) return_val(void_constant) } [readNone] @@ -8733,15 +8739,15 @@ block %26( [nameHint("s_bwd_test_simple_loop")] func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) { -block %35( - param %36 : InOut(%DiffPairx5Ffloat), - param %37 : Float): - let %38 : %DiffPairx5Ffloat = load(%36) - let %39 : Float = get_field(%38, %primal) - let %40 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %41 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%39, %40) - let %42 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%40) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%36, %37, %42) +block %27( + param %28 : InOut(%DiffPairx5Ffloat), + param %29 : Float): + let %30 : %DiffPairx5Ffloat = load(%28) + let %31 : Float = get_field(%30, %primal) + let %32 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %33 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%31, %32) + let %34 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%32) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%28, %29, %34) return_val(void_constant) } [readNone] @@ -8750,102 +8756,104 @@ block %35( [backwardDifferentiable] func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) { -block %43( +block %35( [nameHint("dpy")] param %dpy : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - let %44 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %45 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%44, 0 : Int) - store(%x5Fsx5Fdiffx5Fctx, %45) - let %46 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %47) - let %48 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%46, %48) - let %49 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %50) - store(%49, 0 : Int) + let %36 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %37 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%36, 0 : Int) + store(%x5Fsx5Fdiffx5Fctx, %37) + let %38 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %39) + let %40 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%38, %40) + let %41 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %42) + store(%41, 0 : Int) [loopMaxIters(4 : Int)] - loop(%51, %52, %51, true, %dpy, 0 : Int, 0 : Int) + loop(%43, %44, %43, true, %dpy, 0 : Int, 0 : Int) -block %51( +block %43( [nameHint("_bflag")] param %x5Fbflag : Bool, [nameHint("t")] - param %t1 : Float, + param %t : Float, [nameHint("i")] - param %i1 : Int, + param %i : Int, [nameHint("_pc")] param %x5Fpc : Int): - let %53 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%46, %x5Fpc) - store(%53, %t1) - store(%49, %x5Fpc) - ifElse(%x5Fbflag, %54, %55, %54) + let %45 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%38, %x5Fpc) + store(%45, %t) + store(%41, %x5Fpc) + ifElse(%x5Fbflag, %46, %47, %46) -block %55: - unconditionalBranch(%52) +block %47: + unconditionalBranch(%44) -block %52: - return_val(%t1) +block %44: + return_val(%t) + +block %46: + unconditionalBranch(%48) + +block %48: + let %49 : Bool = cmpLT(%i, 3 : Int) + ifElse(%49, %50, %51, %52) + +block %51: + unconditionalBranch(%52, 0 : Int, 0 : Float) -block %54: +block %50: + let %53 : Float = mul(%t, %t) + unconditionalBranch(%52, 1 : Int, %53) + +block %52( + param %54 : Int, + param %55 : Float): unconditionalBranch(%56) block %56: - let %57 : Bool = cmpLT(%i1, 3 : Int) + let %57 : Bool = cmpNE(%54, 1 : Int) ifElse(%57, %58, %59, %60) block %59: - unconditionalBranch(%60, 0 : Int, 0 : Float) + unconditionalBranch(%60, %x5Fbflag) block %58: - let %61 : Float = mul(%t1, %t1) - unconditionalBranch(%60, 1 : Int, %61) + unconditionalBranch(%60, false) block %60( - param %62 : Int, - param %63 : Float): - unconditionalBranch(%64) - -block %64: - let %65 : Bool = cmpNE(%62, 1 : Int) - ifElse(%65, %66, %67, %68) - -block %67: - unconditionalBranch(%68, %x5Fbflag) - -block %66: - unconditionalBranch(%68, false) - -block %68( [nameHint("_bflag")] param %x5Fbflag1 : Bool): - unconditionalBranch(%69) + unconditionalBranch(%61) -block %69: - ifElse(%x5Fbflag1, %70, %71, %72) +block %61: + ifElse(%x5Fbflag1, %62, %63, %64) -block %71: - unconditionalBranch(%72, %t1, %i1) +block %63: + unconditionalBranch(%64, %t, %i) -block %70: - let %73 : Int = add(%i1, 1 : Int) - unconditionalBranch(%72, %63, %73) +block %62: + let %65 : Int = add(%i, 1 : Int) + unconditionalBranch(%64, %55, %65) -block %72( +block %64( [nameHint("t")] - param %t2 : Float, + param %t1 : Float, [nameHint("i")] - param %i2 : Int): - let %74 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%51, %x5Fbflag1, %t2, %i2, %74) + param %i1 : Int): + let %66 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%43, %x5Fbflag1, %t1, %i1, %66) } -let %47 : _ = key -let %50 : _ = key -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] +let %39 : _ = key +let %42 : _ = key +[SizeAndAlignment(0 : Int, 24 : Int64, 4 : Int)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { - field(%47, Array(Float, 5 : Int)) - field(%50, Int) + [Offset(0 : Int, 0 : Int)] + field(%39, Array(Float, 5 : Int)) + [Offset(0 : Int, 20 : Int)] + field(%42, Int) } [readNone] @@ -8854,172 +8862,172 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type [nameHint("s_bwd_prop_test_simple_loop")] func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { -block %75( +block %67( [nameHint("dpy")] param %dpy1 : InOut(%DiffPairx5Ffloat), [nameHint("_s_dOut")] param %x5Fsx5FdOut : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - let %76 : %DiffPairx5Ffloat = load(%dpy1) - let %77 : Float = get_field(%76, %primal) + let %68 : %DiffPairx5Ffloat = load(%dpy1) + let %69 : Float = get_field(%68, %primal) [loopMaxIters(4 : Int)] - loop(%78, %79, %78, true, %77, 0 : Int, 0 : Int) + loop(%70, %71, %70, true, %69, 0 : Int, 0 : Int) -block %78( +block %70( [nameHint("_bflag")] param %x5Fbflag2 : Bool, [nameHint("t")] - param %t3 : Float, + param %t2 : Float, [nameHint("i")] - param %i3 : Int, + param %i2 : Int, [nameHint("_pc")] param %x5Fpc1 : Int): - let %80 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %47) - let %81 : Ptr(Array(Float, 5 : Int)) = var - store(%81, %80) - let %82 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%81, %x5Fpc1) - store(%82, %t3) - ifElse(%x5Fbflag2, %83, %84, %83) - -block %84: - unconditionalBranch(%79) + let %72 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) + let %73 : Ptr(Array(Float, 5 : Int)) = var + store(%73, %72) + let %74 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%73, %x5Fpc1) + store(%74, %t2) + ifElse(%x5Fbflag2, %75, %76, %75) -block %79: - unconditionalBranch(%85) +block %76: + unconditionalBranch(%71) -block %85: - let %86 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %50) - let %87 : Int = sub(%86, 1 : Int) +block %71: + unconditionalBranch(%77) + +block %77: + let %78 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %42) + let %79 : Int = sub(%78, 1 : Int) [loopMaxIters(4 : Int)] - loop(%88, %89, %90, %87, %x5Fsx5FdOut) + loop(%80, %81, %82, %79, %x5Fsx5FdOut) -block %88( +block %80( [nameHint("_dc")] param %x5Fdc : Int, - param %91 : Float): - let %92 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%92, %93, %94, %93) + param %83 : Float): + let %84 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%84, %85, %86, %85) -block %94: - unconditionalBranch(%89) +block %86: + unconditionalBranch(%81) -block %89: - let %95 : %DiffPairx5Ffloat = load(%dpy1) - let %96 : Float = get_field(%95, %primal) - let %97 : %DiffPairx5Ffloat = makeStruct(%96, %91) - store(%dpy1, %97) +block %81: + let %87 : %DiffPairx5Ffloat = load(%dpy1) + let %88 : Float = get_field(%87, %primal) + let %89 : %DiffPairx5Ffloat = makeStruct(%88, %83) + store(%dpy1, %89) return_val(void_constant) +block %85: + unconditionalBranch(%90) + +block %90: + let %91 : Bool = cmpLT(%x5Fdc, 3 : Int) + ifElse(%91, %92, %93, %94) + block %93: - unconditionalBranch(%98) + unconditionalBranch(%94, 0 : Int) -block %98: - let %99 : Bool = cmpLT(%x5Fdc, 3 : Int) - ifElse(%99, %100, %101, %102) +block %92: + unconditionalBranch(%94, 1 : Int) -block %101: - unconditionalBranch(%102, 0 : Int) +block %94( + param %95 : Int): + unconditionalBranch(%96) + +block %96: + let %97 : Bool = cmpNE(%95, 1 : Int) + let %98 : Bool = not(%97) + ifElse(%98, %99, %100, %101) block %100: - unconditionalBranch(%102, 1 : Int) + unconditionalBranch(%101, 0 : Float, %83) -block %102( - param %103 : Int): +block %99: + unconditionalBranch(%101, %83, 0 : Float) + +block %101( + param %102 : Float, + param %103 : Float): unconditionalBranch(%104) block %104: - let %105 : Bool = cmpNE(%103, 1 : Int) - let %106 : Bool = not(%105) - ifElse(%106, %107, %108, %109) + ifElse(%91, %105, %106, %107) -block %108: - unconditionalBranch(%109, 0 : Float, %91) +block %106: + unconditionalBranch(%107, %103) -block %107: - unconditionalBranch(%109, %91, 0 : Float) - -block %109( - param %110 : Float, - param %111 : Float): - unconditionalBranch(%112) - -block %112: - ifElse(%99, %113, %114, %115) - -block %114: - unconditionalBranch(%115, %111) - -block %113: - let %116 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %47) - let %117 : Float = getElement(%116, %x5Fdc) - let %118 : Float = mul(%117, %110) - let %119 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %47) - let %120 : Float = getElement(%119, %x5Fdc) - let %121 : Float = mul(%120, %110) - let %122 : Float = add(%118, %121) - let %123 : Float = add(%122, %111) - unconditionalBranch(%115, %123) +block %105: + let %108 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) + let %109 : Float = getElement(%108, %x5Fdc) + let %110 : Float = mul(%109, %102) + let %111 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) + let %112 : Float = getElement(%111, %x5Fdc) + let %113 : Float = mul(%112, %102) + let %114 : Float = add(%110, %113) + let %115 : Float = add(%114, %103) + unconditionalBranch(%107, %115) -block %115( - param %124 : Float): - unconditionalBranch(%90) +block %107( + param %116 : Float): + unconditionalBranch(%82) -block %90: - let %125 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%88, %125, %124) +block %82: + let %117 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%80, %117, %116) -block %83: +block %75: + unconditionalBranch(%118) + +block %118: + let %119 : Bool = cmpLT(%i2, 3 : Int) + ifElse(%119, %120, %121, %122) + +block %121: + unconditionalBranch(%122, 0 : Int, 0 : Float) + +block %120: + let %123 : Float = mul(%t2, %t2) + unconditionalBranch(%122, 1 : Int, %123) + +block %122( + param %124 : Int, + param %125 : Float): unconditionalBranch(%126) block %126: - let %127 : Bool = cmpLT(%i3, 3 : Int) + let %127 : Bool = cmpNE(%124, 1 : Int) ifElse(%127, %128, %129, %130) block %129: - unconditionalBranch(%130, 0 : Int, 0 : Float) + unconditionalBranch(%130, %x5Fbflag2) block %128: - let %131 : Float = mul(%t3, %t3) - unconditionalBranch(%130, 1 : Int, %131) + unconditionalBranch(%130, false) block %130( - param %132 : Int, - param %133 : Float): - unconditionalBranch(%134) - -block %134: - let %135 : Bool = cmpNE(%132, 1 : Int) - ifElse(%135, %136, %137, %138) - -block %137: - unconditionalBranch(%138, %x5Fbflag2) - -block %136: - unconditionalBranch(%138, false) - -block %138( [nameHint("_bflag")] param %x5Fbflag3 : Bool): - unconditionalBranch(%139) + unconditionalBranch(%131) -block %139: - ifElse(%x5Fbflag3, %140, %141, %142) +block %131: + ifElse(%x5Fbflag3, %132, %133, %134) -block %141: - unconditionalBranch(%142, %t3, %i3) +block %133: + unconditionalBranch(%134, %t2, %i2) -block %140: - let %143 : Int = add(%i3, 1 : Int) - unconditionalBranch(%142, %133, %143) +block %132: + let %135 : Int = add(%i2, 1 : Int) + unconditionalBranch(%134, %125, %135) -block %142( +block %134( [nameHint("t")] - param %t4 : Float, + param %t3 : Float, [nameHint("i")] - param %i4 : Int): - let %144 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%78, %x5Fbflag3, %t4, %i4, %144) + param %i3 : Int): + let %136 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%70, %x5Fbflag3, %t3, %i3, %136) } [nameHint("primal")] let %primal : _ = key @@ -9054,40 +9062,9 @@ let %11 : Void = typeLayout [keepAlive] global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") let %14 : _ = key -[readNone] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %18( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%19, %20, %21, %y, 0 : Int) - -block %19( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %22 : Bool = cmpLT(%i, 3 : Int) - ifElse(%22, %23, %20, %23) - -block %20: - return_val(%t) - -block %23: - let %24 : Float = mul(%t, %t) - unconditionalBranch(%21) - -block %21: - let %25 : Int = add(%i, 1 : Int) - unconditionalBranch(%19, %24, %25) -} [SequentialIDDecoration(0 : UInt)] [export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %26 : witness_table_t(0 : Int)(DefaultLayout); +witness_table %18 : witness_table_t(0 : Int)(DefaultLayout); [nameHint("outputBuffer")] [export("_SVR15reverse_2Dxloop12outputBuffer")] @@ -9101,29 +9078,29 @@ let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %7) = global_param [layout(%8)] func %computeMain : Func(Void, Vec(UInt, 3 : Int)) { -block %27( +block %19( [layout(%15)] [nameHint("dispatchThreadID")] [semantic("SV_DispatchThreadID", 0 : Int)] param %dispatchThreadID : Vec(UInt, 3 : Int)): [nameHint("dpa")] let %dpa : Ptr(%DiffPairx5Ffloat) = var - let %28 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) - store(%dpa, %28) + let %20 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) + store(%dpa, %20) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %29 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %30 : %DiffPairx5Ffloat = load(%dpa) - let %31 : Float = get_field(%30, %differential) - store(%29, %31) + let %21 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) + let %22 : %DiffPairx5Ffloat = load(%dpa) + let %23 : Float = get_field(%22, %differential) + store(%21, %23) [nameHint("dpa")] let %dpa1 : Ptr(%DiffPairx5Ffloat) = var - let %32 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) - store(%dpa1, %32) + let %24 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) + store(%dpa1, %24) call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %33 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %34 : %DiffPairx5Ffloat = load(%dpa1) - let %35 : Float = get_field(%34, %differential) - store(%33, %35) + let %25 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) + let %26 : %DiffPairx5Ffloat = load(%dpa1) + let %27 : Float = get_field(%26, %differential) + store(%25, %27) return_val(void_constant) } [readNone] @@ -9132,15 +9109,15 @@ block %27( [nameHint("s_bwd_test_simple_loop")] func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) { -block %36( - param %37 : InOut(%DiffPairx5Ffloat), - param %38 : Float): - let %39 : %DiffPairx5Ffloat = load(%37) - let %40 : Float = get_field(%39, %primal) - let %41 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %42 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%40, %41) - let %43 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%41) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%37, %38, %43) +block %28( + param %29 : InOut(%DiffPairx5Ffloat), + param %30 : Float): + let %31 : %DiffPairx5Ffloat = load(%29) + let %32 : Float = get_field(%31, %primal) + let %33 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var + let %34 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%32, %33) + let %35 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%33) + call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%29, %30, %35) return_val(void_constant) } [readNone] @@ -9149,102 +9126,104 @@ block %36( [backwardDifferentiable] func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) { -block %44( +block %36( [nameHint("dpy")] param %dpy : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - let %45 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %46 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%45, 0 : Int) - store(%x5Fsx5Fdiffx5Fctx, %46) - let %47 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %48) - let %49 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%47, %49) - let %50 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %51) - store(%50, 0 : Int) + let %37 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + let %38 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%37, 0 : Int) + store(%x5Fsx5Fdiffx5Fctx, %38) + let %39 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %40) + let %41 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) + store(%39, %41) + let %42 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %43) + store(%42, 0 : Int) [loopMaxIters(4 : Int)] - loop(%52, %53, %52, true, %dpy, 0 : Int, 0 : Int) + loop(%44, %45, %44, true, %dpy, 0 : Int, 0 : Int) -block %52( +block %44( [nameHint("_bflag")] param %x5Fbflag : Bool, [nameHint("t")] - param %t1 : Float, + param %t : Float, [nameHint("i")] - param %i1 : Int, + param %i : Int, [nameHint("_pc")] param %x5Fpc : Int): - let %54 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%47, %x5Fpc) - store(%54, %t1) - store(%50, %x5Fpc) - ifElse(%x5Fbflag, %55, %56, %55) + let %46 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%39, %x5Fpc) + store(%46, %t) + store(%42, %x5Fpc) + ifElse(%x5Fbflag, %47, %48, %47) -block %56: - unconditionalBranch(%53) +block %48: + unconditionalBranch(%45) -block %53: - return_val(%t1) +block %45: + return_val(%t) + +block %47: + unconditionalBranch(%49) + +block %49: + let %50 : Bool = cmpLT(%i, 3 : Int) + ifElse(%50, %51, %52, %53) + +block %52: + unconditionalBranch(%53, 0 : Int, 0 : Float) + +block %51: + let %54 : Float = mul(%t, %t) + unconditionalBranch(%53, 1 : Int, %54) -block %55: +block %53( + param %55 : Int, + param %56 : Float): unconditionalBranch(%57) block %57: - let %58 : Bool = cmpLT(%i1, 3 : Int) + let %58 : Bool = cmpNE(%55, 1 : Int) ifElse(%58, %59, %60, %61) block %60: - unconditionalBranch(%61, 0 : Int, 0 : Float) + unconditionalBranch(%61, %x5Fbflag) block %59: - let %62 : Float = mul(%t1, %t1) - unconditionalBranch(%61, 1 : Int, %62) + unconditionalBranch(%61, false) block %61( - param %63 : Int, - param %64 : Float): - unconditionalBranch(%65) - -block %65: - let %66 : Bool = cmpNE(%63, 1 : Int) - ifElse(%66, %67, %68, %69) - -block %68: - unconditionalBranch(%69, %x5Fbflag) - -block %67: - unconditionalBranch(%69, false) - -block %69( [nameHint("_bflag")] param %x5Fbflag1 : Bool): - unconditionalBranch(%70) + unconditionalBranch(%62) -block %70: - ifElse(%x5Fbflag1, %71, %72, %73) +block %62: + ifElse(%x5Fbflag1, %63, %64, %65) -block %72: - unconditionalBranch(%73, %t1, %i1) +block %64: + unconditionalBranch(%65, %t, %i) -block %71: - let %74 : Int = add(%i1, 1 : Int) - unconditionalBranch(%73, %64, %74) +block %63: + let %66 : Int = add(%i, 1 : Int) + unconditionalBranch(%65, %56, %66) -block %73( +block %65( [nameHint("t")] - param %t2 : Float, + param %t1 : Float, [nameHint("i")] - param %i2 : Int): - let %75 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%52, %x5Fbflag1, %t2, %i2, %75) + param %i1 : Int): + let %67 : Int = add(%x5Fpc, 1 : Int) + unconditionalBranch(%44, %x5Fbflag1, %t1, %i1, %67) } -let %48 : _ = key -let %51 : _ = key -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] +let %40 : _ = key +let %43 : _ = key +[SizeAndAlignment(0 : Int, 24 : Int64, 4 : Int)] [nameHint("s_bwd_prop_test_simple_loop_Intermediates")] struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type { - field(%48, Array(Float, 5 : Int)) - field(%51, Int) + [Offset(0 : Int, 0 : Int)] + field(%40, Array(Float, 5 : Int)) + [Offset(0 : Int, 20 : Int)] + field(%43, Int) } [readNone] @@ -9253,187 +9232,175 @@ struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type [nameHint("s_bwd_prop_test_simple_loop")] func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) { -block %76( +block %68( [nameHint("dpy")] param %dpy1 : InOut(%DiffPairx5Ffloat), [nameHint("_s_dOut")] param %x5Fsx5FdOut : Float, [nameHint("_s_diff_ctx")] param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - let %77 : %DiffPairx5Ffloat = load(%dpy1) - let %78 : Float = get_field(%77, %primal) + let %69 : %DiffPairx5Ffloat = load(%dpy1) + let %70 : Float = get_field(%69, %primal) [loopMaxIters(4 : Int)] - loop(%79, %80, %79, true, %78, 0 : Int, 0 : Int) + loop(%71, %72, %71, true, %70, 0 : Int, 0 : Int) -block %79( +block %71( [nameHint("_bflag")] param %x5Fbflag2 : Bool, [nameHint("t")] - param %t3 : Float, + param %t2 : Float, [nameHint("i")] - param %i3 : Int, + param %i2 : Int, [nameHint("_pc")] param %x5Fpc1 : Int): - let %81 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %48) - let %82 : Ptr(Array(Float, 5 : Int)) = var - store(%82, %81) - let %83 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%82, %x5Fpc1) - store(%83, %t3) - ifElse(%x5Fbflag2, %84, %85, %84) + let %73 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) + let %74 : Ptr(Array(Float, 5 : Int)) = var + store(%74, %73) + let %75 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%74, %x5Fpc1) + store(%75, %t2) + ifElse(%x5Fbflag2, %76, %77, %76) -block %85: - unconditionalBranch(%80) +block %77: + unconditionalBranch(%72) -block %80: - unconditionalBranch(%86) +block %72: + unconditionalBranch(%78) -block %86: - let %87 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %51) - let %88 : Int = sub(%87, 1 : Int) +block %78: + let %79 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %43) + let %80 : Int = sub(%79, 1 : Int) [loopMaxIters(4 : Int)] - loop(%89, %90, %91, %88, %x5Fsx5FdOut) + loop(%81, %82, %83, %80, %x5Fsx5FdOut) -block %89( +block %81( [nameHint("_dc")] param %x5Fdc : Int, - param %92 : Float): - let %93 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%93, %94, %95, %94) + param %84 : Float): + let %85 : Bool = cmpGE(%x5Fdc, 0 : Int) + ifElse(%85, %86, %87, %86) + +block %87: + unconditionalBranch(%82) + +block %82: + let %88 : %DiffPairx5Ffloat = load(%dpy1) + let %89 : Float = get_field(%88, %primal) + let %90 : %DiffPairx5Ffloat = makeStruct(%89, %84) + store(%dpy1, %90) + return_val(void_constant) -block %95: - unconditionalBranch(%90) +block %86: + unconditionalBranch(%91) -block %90: - let %96 : %DiffPairx5Ffloat = load(%dpy1) - let %97 : Float = get_field(%96, %primal) - let %98 : %DiffPairx5Ffloat = makeStruct(%97, %92) - store(%dpy1, %98) - return_val(void_constant) +block %91: + let %92 : Bool = cmpLT(%x5Fdc, 3 : Int) + ifElse(%92, %93, %94, %95) block %94: - unconditionalBranch(%99) + unconditionalBranch(%95, 0 : Int) -block %99: - let %100 : Bool = cmpLT(%x5Fdc, 3 : Int) - ifElse(%100, %101, %102, %103) +block %93: + unconditionalBranch(%95, 1 : Int) + +block %95( + param %96 : Int): + unconditionalBranch(%97) -block %102: - unconditionalBranch(%103, 0 : Int) +block %97: + let %98 : Bool = cmpNE(%96, 1 : Int) + let %99 : Bool = not(%98) + ifElse(%99, %100, %101, %102) block %101: - unconditionalBranch(%103, 1 : Int) + unconditionalBranch(%102, 0 : Float, %84) -block %103( - param %104 : Int): +block %100: + unconditionalBranch(%102, %84, 0 : Float) + +block %102( + param %103 : Float, + param %104 : Float): unconditionalBranch(%105) block %105: - let %106 : Bool = cmpNE(%104, 1 : Int) - let %107 : Bool = not(%106) - ifElse(%107, %108, %109, %110) - -block %109: - unconditionalBranch(%110, 0 : Float, %92) - -block %108: - unconditionalBranch(%110, %92, 0 : Float) - -block %110( - param %111 : Float, - param %112 : Float): - unconditionalBranch(%113) - -block %113: - ifElse(%100, %114, %115, %116) - -block %115: - unconditionalBranch(%116, %112) - -block %114: - let %117 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %48) - let %118 : Float = getElement(%117, %x5Fdc) - let %119 : Float = mul(%118, %111) - let %120 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %48) - let %121 : Float = getElement(%120, %x5Fdc) - let %122 : Float = mul(%121, %111) - let %123 : Float = add(%119, %122) - let %124 : Float = add(%123, %112) - unconditionalBranch(%116, %124) - -block %116( - param %125 : Float): - unconditionalBranch(%91) + ifElse(%92, %106, %107, %108) -block %91: - let %126 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%89, %126, %125) +block %107: + unconditionalBranch(%108, %104) + +block %106: + let %109 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) + let %110 : Float = getElement(%109, %x5Fdc) + let %111 : Float = mul(%110, %103) + let %112 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) + let %113 : Float = getElement(%112, %x5Fdc) + let %114 : Float = mul(%113, %103) + let %115 : Float = add(%111, %114) + let %116 : Float = add(%115, %104) + unconditionalBranch(%108, %116) + +block %108( + param %117 : Float): + unconditionalBranch(%83) + +block %83: + let %118 : Int = sub(%x5Fdc, 1 : Int) + unconditionalBranch(%81, %118, %117) + +block %76: + unconditionalBranch(%119) -block %84: +block %119: + let %120 : Bool = cmpLT(%i2, 3 : Int) + ifElse(%120, %121, %122, %123) + +block %122: + unconditionalBranch(%123, 0 : Int, 0 : Float) + +block %121: + let %124 : Float = mul(%t2, %t2) + unconditionalBranch(%123, 1 : Int, %124) + +block %123( + param %125 : Int, + param %126 : Float): unconditionalBranch(%127) block %127: - let %128 : Bool = cmpLT(%i3, 3 : Int) + let %128 : Bool = cmpNE(%125, 1 : Int) ifElse(%128, %129, %130, %131) block %130: - unconditionalBranch(%131, 0 : Int, 0 : Float) + unconditionalBranch(%131, %x5Fbflag2) block %129: - let %132 : Float = mul(%t3, %t3) - unconditionalBranch(%131, 1 : Int, %132) + unconditionalBranch(%131, false) block %131( - param %133 : Int, - param %134 : Float): - unconditionalBranch(%135) - -block %135: - let %136 : Bool = cmpNE(%133, 1 : Int) - ifElse(%136, %137, %138, %139) - -block %138: - unconditionalBranch(%139, %x5Fbflag2) - -block %137: - unconditionalBranch(%139, false) - -block %139( [nameHint("_bflag")] param %x5Fbflag3 : Bool): - unconditionalBranch(%140) + unconditionalBranch(%132) -block %140: - ifElse(%x5Fbflag3, %141, %142, %143) +block %132: + ifElse(%x5Fbflag3, %133, %134, %135) -block %142: - unconditionalBranch(%143, %t3, %i3) +block %134: + unconditionalBranch(%135, %t2, %i2) -block %141: - let %144 : Int = add(%i3, 1 : Int) - unconditionalBranch(%143, %134, %144) +block %133: + let %136 : Int = add(%i2, 1 : Int) + unconditionalBranch(%135, %126, %136) -block %143( +block %135( [nameHint("t")] - param %t4 : Float, + param %t3 : Float, [nameHint("i")] - param %i4 : Int): - let %145 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%79, %x5Fbflag3, %t4, %i4, %145) + param %i3 : Int): + let %137 : Int = add(%x5Fpc1, 1 : Int) + unconditionalBranch(%71, %x5Fbflag3, %t3, %i3, %137) } [nameHint("primal")] let %primal : _ = key [nameHint("differential")] let %differential : _ = key ### -checkpointing context generated for function test_simple_loop - defined at tests/autodiff/reverse-loop.slang:12 - size of context: 24 bytes - - 20 bytes used at tests/autodiff/reverse-loop.slang:14 - float t = y; - ^ - - 4 bytes used at tests/autodiff/reverse-loop.slang:16 - for (int i = 0; i < 3; i++) - ^~~ - diff --git a/out.glsl b/out.glsl index c7362b059f..f236cc337d 100644 --- a/out.glsl +++ b/out.glsl @@ -4,27 +4,6 @@ layout(row_major) buffer; layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { float _data[]; } outputBuffer_0; -float test_simple_loop_0(float y_0) -{ - float t_0 = y_0; - int i_0 = 0; - for(;;) - { - if(i_0 < 3) - { - } - else - { - break; - } - float _S1 = t_0 * t_0; - int _S2 = i_0 + 1; - t_0 = _S1; - i_0 = _S2; - } - return t_0; -} - struct DiffPair_float_0 { float primal_0; @@ -33,29 +12,29 @@ struct DiffPair_float_0 struct s_bwd_prop_test_simple_loop_Intermediates_0 { - float _S3[5]; - int _S4; + float _S1[5]; + int _S2; }; float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_0) { - float _S5[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; - _s_diff_ctx_0._S3 = _S5; - _s_diff_ctx_0._S4 = 0; - _s_diff_ctx_0._S3[0] = 0.0; - _s_diff_ctx_0._S3[1] = 0.0; - _s_diff_ctx_0._S3[2] = 0.0; - _s_diff_ctx_0._S3[3] = 0.0; - _s_diff_ctx_0._S3[4] = 0.0; - _s_diff_ctx_0._S4 = 0; + float _S3[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; + _s_diff_ctx_0._S1 = _S3; + _s_diff_ctx_0._S2 = 0; + _s_diff_ctx_0._S1[0] = 0.0; + _s_diff_ctx_0._S1[1] = 0.0; + _s_diff_ctx_0._S1[2] = 0.0; + _s_diff_ctx_0._S1[3] = 0.0; + _s_diff_ctx_0._S1[4] = 0.0; + _s_diff_ctx_0._S2 = 0; bool _bflag_0 = true; - float t_1 = dpy_0; - int i_1 = 0; + float t_0 = dpy_0; + int i_0 = 0; int _pc_0 = 0; for(;;) { - _s_diff_ctx_0._S3[_pc_0] = t_1; - _s_diff_ctx_0._S4 = _pc_0; + _s_diff_ctx_0._S1[_pc_0] = t_0; + _s_diff_ctx_0._S2 = _pc_0; if(_bflag_0) { } @@ -63,38 +42,38 @@ float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_lo { break; } - float _S6; - int _S7; - if(i_1 < 3) + float _S4; + int _S5; + if(i_0 < 3) { - float _S8 = t_1 * t_1; - _S7 = 1; - _S6 = _S8; + float _S6 = t_0 * t_0; + _S5 = 1; + _S4 = _S6; } else { - _S7 = 0; - _S6 = 0.0; + _S5 = 0; + _S4 = 0.0; } - if(_S7 != 1) + if(_S5 != 1) { _bflag_0 = false; } if(_bflag_0) { - int _S9 = i_1 + 1; - t_1 = _S6; - i_1 = _S9; + int _S7 = i_0 + 1; + t_0 = _S4; + i_0 = _S7; } _pc_0 = _pc_0 + 1; } - return t_1; + return t_0; } void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0, s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_1) { - int _dc_0 = _s_diff_ctx_1._S4 - 1; - float _S10 = _s_dOut_0; + int _dc_0 = _s_diff_ctx_1._S2 - 1; + float _S8 = _s_dOut_0; for(;;) { if(_dc_0 >= 0) @@ -104,48 +83,48 @@ void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0 { break; } - bool _S11 = _dc_0 < 3; - int _S12; - if(_S11) + bool _S9 = _dc_0 < 3; + int _S10; + if(_S9) { - _S12 = 1; + _S10 = 1; } else { - _S12 = 0; + _S10 = 0; } - float _S13; - float _S14; - if(!(_S12 != 1)) + float _S11; + float _S12; + if(!(_S10 != 1)) { - _S13 = _S10; - _S14 = 0.0; + _S11 = _S8; + _S12 = 0.0; } else { - _S13 = 0.0; - _S14 = _S10; + _S11 = 0.0; + _S12 = _S8; } - if(_S11) + if(_S9) { - _S10 = _s_diff_ctx_1._S3[_dc_0] * _S13 + _s_diff_ctx_1._S3[_dc_0] * _S13 + _S14; + _S8 = _s_diff_ctx_1._S1[_dc_0] * _S11 + _s_diff_ctx_1._S1[_dc_0] * _S11 + _S12; } else { - _S10 = _S14; + _S8 = _S12; } _dc_0 = _dc_0 - 1; } dpy_1.primal_0 = dpy_1.primal_0; - dpy_1.differential_0 = _S10; + dpy_1.differential_0 = _S8; return; } -void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S15, float _S16) +void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S13, float _S14) { - s_bwd_prop_test_simple_loop_Intermediates_0 _S17; - float _S18 = s_primal_ctx_test_simple_loop_0(_S15.primal_0, _S17); - s_bwd_prop_test_simple_loop_0(_S15, _S16, _S17); + s_bwd_prop_test_simple_loop_Intermediates_0 _S15; + float _S16 = s_primal_ctx_test_simple_loop_0(_S13.primal_0, _S15); + s_bwd_prop_test_simple_loop_0(_S13, _S14, _S15); return; } diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 9ed1de93f3..f4158d720e 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -796,11 +796,78 @@ Result linkAndOptimizeIR( break; } + // Report checkpointing information + EndToEndCompileRequest *compileRequest = codeGenContext->isEndToEndCompile(); + CompilerOptionSet &optionSet = compileRequest->getOptionSet(); + SLANG_ASSERT(compileRequest); + + SourceManager *sourceManager = sink->getSourceManager(); + auto getHumanLoc = [&](const SourceLoc &sourceLoc) { + SourceView *sourceView = sourceManager->findSourceViewRecursively(sourceLoc); + if (sourceView) + return sourceView->getHumaneLoc(sourceLoc); + return HumaneSourceLoc(); + }; + + for (auto inst : irModule->getGlobalInsts()) { + IRStructType *structType = as(inst); + if (!structType) + continue; + + auto checkpointDecoration = structType->findDecoration(); + if (checkpointDecoration) { + String nameOrLocation; + + auto func = checkpointDecoration->getSourceFunction(); + if (!func) + nameOrLocation = "(?)"; + else if (auto nameHint = func->findDecoration()) + nameOrLocation = nameHint->getName(); + + IRSizeAndAlignment sizeInfo; + getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); + + HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); + printf("checkpointing context generated for function %s\n", nameOrLocation.getBuffer()); + printf("\tdefined at %s:%d\n", hloc.pathInfo.foundPath.getBuffer(), hloc.line); + printf("\tsize of context: %d bytes\n\n", sizeInfo.size); + + for (auto field : structType->getFields()) { + IRType *fieldType = field->getFieldType(); + IRSizeAndAlignment sizeInfo; + getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); + + HumaneSourceLoc hloc = getHumanLoc(field->sourceLoc); + + if (field->findDecoration()) { + printf("\t%d bytes used for a loop counter at %s:%d\n", + sizeInfo.size, + hloc.pathInfo.foundPath.getBuffer(), + hloc.line); + } else { + printf("\t%d bytes used for the variable defined at %s:%d\n", + sizeInfo.size, + hloc.pathInfo.foundPath.getBuffer(), + hloc.line); + } + + StringBuilder builder; + + SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); + _sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); + printf("%s\n", builder.getBuffer()); + } + } + + fflush(stdout); + } + if (requiredLoweringPassSet.autodiff) finalizeAutoDiffPass(targetProgram, irModule); // Remove auto-diff related decorations. // We may have an autodiff decoration regardless of if autodiff is being used. + // TODO: strip checkpoint decorations stripAutoDiffDecorations(irModule); finalizeSpecialization(irModule); @@ -1532,62 +1599,6 @@ Result linkAndOptimizeIR( #endif validateIRModuleIfEnabled(codeGenContext, irModule); - // Report checkpointing information - EndToEndCompileRequest *compileRequest = codeGenContext->isEndToEndCompile(); - CompilerOptionSet &optionSet = compileRequest->getOptionSet(); - SLANG_ASSERT(compileRequest); - - SourceManager *sourceManager = sink->getSourceManager(); - auto getHumanLoc = [&](const SourceLoc &sourceLoc) { - SourceView *sourceView = sourceManager->findSourceViewRecursively(sourceLoc); - if (sourceView) - return sourceView->getHumaneLoc(sourceLoc); - return HumaneSourceLoc(); - }; - - for (auto inst : irModule->getGlobalInsts()) { - IRStructType *structType = as(inst); - if (!structType) - continue; - - auto checkpointDecoration = structType->findDecoration(); - if (checkpointDecoration) { - String nameOrLocation; - - auto func = checkpointDecoration->getSourceFunction(); - if (!func) - nameOrLocation = ""; - else if (auto nameHint = func->findDecoration()) - nameOrLocation = nameHint->getName(); - - IRSizeAndAlignment sizeInfo; - getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); - - HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); - printf("checkpointing context generated for function %s\n", nameOrLocation.getBuffer()); - printf("\tdefined at %s:%d\n", hloc.pathInfo.foundPath.getBuffer(), hloc.line); - printf("\tsize of context: %d bytes\n\n", sizeInfo.size); - - for (auto field : structType->getFields()) { - IRType *fieldType = field->getFieldType(); - IRSizeAndAlignment sizeInfo; - getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); - - HumaneSourceLoc hloc = getHumanLoc(field->sourceLoc); - printf("\t%d bytes used at %s:%d\n", - sizeInfo.size, - hloc.pathInfo.foundPath.getBuffer(), - hloc.line); - - StringBuilder builder; - - SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); - _sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); - printf("%s\n", builder.getBuffer()); - } - } - } - if ( (target != CodeGenTarget::SPIRV) && (target != CodeGenTarget::SPIRVAssembly) ) { // We need to perform a final pass to ensure that all the diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index a5f2ec5264..e607e928fa 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -1679,6 +1679,8 @@ RefPtr ensurePrimalAvailability( setInsertAfterOrdinaryInst(&builder, instToStore); auto localVar = storeIndexedValue(&builder, varBlock, instToStore, defBlockIndices); localVar->sourceLoc = instToStore->sourceLoc; + if (isLoopCounter) + builder.addLoopCounterDecoration(localVar); for (auto use : outOfScopeUses) { diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp index 629f37d6e2..4c4fafa868 100644 --- a/source/slang/slang-ir-autodiff-unzip.cpp +++ b/source/slang/slang-ir-autodiff-unzip.cpp @@ -228,6 +228,13 @@ struct ExtractPrimalFuncContext auto field = addIntermediateContextField(cast(inst->getDataType())->getValueType(), outIntermediary); field->sourceLoc = inst->sourceLoc; + if (inst->findDecoration()) + builder.addLoopCounterDecoration(field); + + printf("ADDING FIELD:\n"); + inst->dump(); + field->dump(); + builder.setInsertBefore(inst); auto fieldAddr = builder.emitFieldAddress( inst->getFullType(), outIntermediary, field->getKey()); diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp index 02498ee10e..5bd6467237 100644 --- a/source/slang/slang-ir-autodiff.cpp +++ b/source/slang/slang-ir-autodiff.cpp @@ -1203,6 +1203,7 @@ void stripAutoDiffDecorationsFromChildren(IRInst* parent) case kIROp_AutoDiffOriginalValueDecoration: case kIROp_UserDefinedBackwardDerivativeDecoration: case kIROp_IntermediateContextFieldDifferentialTypeDecoration: + case kIROp_CheckpointIntermediateDecoration: decor->removeAndDeallocate(); break; case kIROp_AutoDiffBuiltinDecoration: From d7577d98f1173201c704298eba3c2bbf684c8759 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 9 Sep 2024 14:44:55 -0700 Subject: [PATCH 07/32] Writing report to file --- ad-report | 24 +-- checkpoint-report.txt | 10 ++ .../compiler-core/slang-diagnostic-sink.cpp | 4 +- source/compiler-core/slang-diagnostic-sink.h | 3 +- source/slang/slang-emit.cpp | 161 ++++++++---------- 5 files changed, 89 insertions(+), 113 deletions(-) create mode 100644 checkpoint-report.txt diff --git a/ad-report b/ad-report index fefa272a78..d35b7281dc 100644 --- a/ad-report +++ b/ad-report @@ -3539,7 +3539,7 @@ use with usedVal: let %t : Float = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2685A0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E59785E0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param @@ -3551,7 +3551,7 @@ use with usedVal: let %t : Float = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2685A0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E59785E0 to storeSet [primalInstDecoration] [nameHint("t")] let %t : Float = param @@ -3577,13 +3577,13 @@ let %1 : Int = param use with usedVal: 0 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE245AD0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5969B60 to storeSet 0 inst with location: 0 (0) use with usedVal: 1 -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2456A0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5969730 to storeSet 1 inst with location: 0 (0) use with usedVal: @@ -3599,7 +3599,7 @@ let %x5Fbflag : Bool = param use with usedVal: -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2817E0 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5955730 to storeSet inst with location: 0 (0) use with usedVal: @@ -3617,7 +3617,7 @@ use with usedVal: let %x5Fpc : Int = param -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000223FE2778F8 to storeSet +[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5983928 to storeSet [primalInstDecoration] [nameHint("_pc")] [loopCounterDecoration] @@ -8651,18 +8651,6 @@ GenericSpecializationDictionary ExistentialFuncSpecializationDictionary ExistentialTypeSpecializationDictionary ### -checkpointing context generated for function test_simple_loop - defined at tests/autodiff/reverse-loop.slang:12 - size of context: 24 bytes - - 20 bytes used for the variable defined at tests/autodiff/reverse-loop.slang:14 - float t = y; - ^ - - 4 bytes used for a loop counter at tests/autodiff/reverse-loop.slang:16 - for (int i = 0; i < 3; i++) - ^~~ - ### BEFORE-LOWER-GENERICS: undefined let %1 : Void = varLayout(%2, %3) diff --git a/checkpoint-report.txt b/checkpoint-report.txt new file mode 100644 index 0000000000..fb9330546c --- /dev/null +++ b/checkpoint-report.txt @@ -0,0 +1,10 @@ +checkpointing context generated for function: test_simple_loop + defined at tests/autodiff/reverse-loop.slang:12 + size of context: 24 bytes + + 20 bytes used for variable defined at tests/autodiff/reverse-loop.slang:14 + float t = y; + ^ + 4 bytes used for loop counter created for loop at tests/autodiff/reverse-loop.slang:16 + for (int i = 0; i < 3; i++) + ^~~ diff --git a/source/compiler-core/slang-diagnostic-sink.cpp b/source/compiler-core/slang-diagnostic-sink.cpp index 58c143c3f9..be1618ac09 100644 --- a/source/compiler-core/slang-diagnostic-sink.cpp +++ b/source/compiler-core/slang-diagnostic-sink.cpp @@ -251,7 +251,7 @@ static void _reduceLength(Index startIndex, const UnownedStringSlice& prefix, St ioBuf = buf; } -void _sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb) +void sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb) { SourceFile* sourceFile = sourceView->getSourceFile(); if (!sourceFile) @@ -461,7 +461,7 @@ static void formatDiagnostic( if (sourceView && sink->isFlagSet(DiagnosticSink::Flag::SourceLocationLine) && diagnostic.loc.isValid()) { - _sourceLocationNoteDiagnostic(sink, sourceView, sourceLoc, sb); + sourceLocationNoteDiagnostic(sink, sourceView, sourceLoc, sb); } if (sourceView && sink->isFlagSet(DiagnosticSink::Flag::VerbosePath)) diff --git a/source/compiler-core/slang-diagnostic-sink.h b/source/compiler-core/slang-diagnostic-sink.h index aae6c9198a..ec6d43d9c9 100644 --- a/source/compiler-core/slang-diagnostic-sink.h +++ b/source/compiler-core/slang-diagnostic-sink.h @@ -360,7 +360,8 @@ class DiagnosticsLookup : public RefObject MemoryArena m_arena; }; -void _sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb); +// Display source location +void sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb); } diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index f4158d720e..6e761420cb 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -215,6 +215,74 @@ static void dumpIRIfEnabled( } } +static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, DiagnosticSink* sink, IRModule* irModule) +{ + // Report checkpointing information + EndToEndCompileRequest *compileRequest = codeGenContext->isEndToEndCompile(); + CompilerOptionSet &optionSet = compileRequest->getOptionSet(); + SLANG_ASSERT(compileRequest); + + SourceManager* sourceManager = sink->getSourceManager(); + auto getHumanLoc = [&](const SourceLoc &sourceLoc) + { + SourceView *sourceView = sourceManager->findSourceViewRecursively(sourceLoc); + if (sourceView) + return sourceView->getHumaneLoc(sourceLoc); + return HumaneSourceLoc(); + }; + + StringBuilder builder; + for (auto inst : irModule->getGlobalInsts()) { + IRStructType *structType = as(inst); + if (!structType) + continue; + + auto checkpointDecoration = structType->findDecoration(); + if (checkpointDecoration) { + builder << "checkpointing context generated for function: "; + + auto func = checkpointDecoration->getSourceFunction(); + if (!func) + builder << "(?)"; + else if (auto nameHint = func->findDecoration()) + builder << nameHint->getName(); + + IRSizeAndAlignment sizeInfo; + getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); + + HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); + + builder << "\n"; + builder << "\tdefined at " << hloc.pathInfo.foundPath << ":" << hloc.line << "\n"; + builder << "\tsize of context: " << sizeInfo.size << " bytes\n"; + builder << "\n"; + + for (auto field : structType->getFields()) { + IRType *fieldType = field->getFieldType(); + IRSizeAndAlignment sizeInfo; + getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); + + HumaneSourceLoc hloc = getHumanLoc(field->sourceLoc); + + builder << "\t" << sizeInfo.size << " bytes used for "; + if (field->findDecoration()) + builder << "loop counter created for loop at "; + else + builder << "variable defined at "; + builder << hloc.pathInfo.foundPath << ":" << hloc.line << "\n"; + + SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); + sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); + } + } + } + + SourceWriter writer(sourceManager, LineDirectiveMode::None, nullptr); + writer.emit(builder); + + File::writeAllText("checkpoint-report.txt", writer.getContent()); +} + struct LinkingAndOptimizationOptions { bool shouldLegalizeExistentialAndResourceTypes = true; @@ -758,34 +826,6 @@ Result linkAndOptimizeIR( if (requiredLoweringPassSet.autodiff) { dumpIRIfEnabled(codeGenContext, irModule, "BEFORE-AUTODIFF"); - - //printf("Module (bwd diff functions) before autodiff pass:\n"); - ////irModule->getModuleInst()->dump(); - //IRModuleInst* module = irModule->getModuleInst(); - //for (auto inst : module->getGlobalInsts()) { - // auto func = as(inst); - // if (!func) - // continue; - - // if (!isBackwardDifferentiableFunc(func)) - // continue; - - // printf("=============================================\n"); - // func->dump(); - - // for (auto block : func->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - // inst->dump(); - - // if (inst->sourceLoc.isValid()) - // sink->diagnose(inst->sourceLoc, Diagnostics::seeDeclarationOf, inst); - // } - // } - //} - enableIRValidationAtInsert(); changed |= processAutodiffCalls(targetProgram, irModule, sink); disableIRValidationAtInsert(); @@ -797,70 +837,7 @@ Result linkAndOptimizeIR( } // Report checkpointing information - EndToEndCompileRequest *compileRequest = codeGenContext->isEndToEndCompile(); - CompilerOptionSet &optionSet = compileRequest->getOptionSet(); - SLANG_ASSERT(compileRequest); - - SourceManager *sourceManager = sink->getSourceManager(); - auto getHumanLoc = [&](const SourceLoc &sourceLoc) { - SourceView *sourceView = sourceManager->findSourceViewRecursively(sourceLoc); - if (sourceView) - return sourceView->getHumaneLoc(sourceLoc); - return HumaneSourceLoc(); - }; - - for (auto inst : irModule->getGlobalInsts()) { - IRStructType *structType = as(inst); - if (!structType) - continue; - - auto checkpointDecoration = structType->findDecoration(); - if (checkpointDecoration) { - String nameOrLocation; - - auto func = checkpointDecoration->getSourceFunction(); - if (!func) - nameOrLocation = "(?)"; - else if (auto nameHint = func->findDecoration()) - nameOrLocation = nameHint->getName(); - - IRSizeAndAlignment sizeInfo; - getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); - - HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); - printf("checkpointing context generated for function %s\n", nameOrLocation.getBuffer()); - printf("\tdefined at %s:%d\n", hloc.pathInfo.foundPath.getBuffer(), hloc.line); - printf("\tsize of context: %d bytes\n\n", sizeInfo.size); - - for (auto field : structType->getFields()) { - IRType *fieldType = field->getFieldType(); - IRSizeAndAlignment sizeInfo; - getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); - - HumaneSourceLoc hloc = getHumanLoc(field->sourceLoc); - - if (field->findDecoration()) { - printf("\t%d bytes used for a loop counter at %s:%d\n", - sizeInfo.size, - hloc.pathInfo.foundPath.getBuffer(), - hloc.line); - } else { - printf("\t%d bytes used for the variable defined at %s:%d\n", - sizeInfo.size, - hloc.pathInfo.foundPath.getBuffer(), - hloc.line); - } - - StringBuilder builder; - - SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); - _sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); - printf("%s\n", builder.getBuffer()); - } - } - - fflush(stdout); - } + reportCheckpointIntermediates(codeGenContext, sink, irModule); if (requiredLoweringPassSet.autodiff) finalizeAutoDiffPass(targetProgram, irModule); From 25c3fd416ed4ffed322770a3533b23515514fd97 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 9 Sep 2024 14:57:11 -0700 Subject: [PATCH 08/32] Add slangc option to enable checkpoint reports --- ad-report | 9394 ----------------- checkpoint-report.txt | 10 - include/slang.h | 1 + out.glsl | 146 - .../slang-record-replay/util/emum-to-string.h | 1 + source/slang/slang-compiler.cpp | 6 +- source/slang/slang-compiler.h | 1 + source/slang/slang-emit.cpp | 3 +- source/slang/slang-options.cpp | 2 + 9 files changed, 12 insertions(+), 9552 deletions(-) delete mode 100644 ad-report delete mode 100644 checkpoint-report.txt delete mode 100644 out.glsl diff --git a/ad-report b/ad-report deleted file mode 100644 index d35b7281dc..0000000000 --- a/ad-report +++ /dev/null @@ -1,9394 +0,0 @@ -### LOWER-TO-IR: -undefined -let %1 : Void = no_diff -let %2 : witness_table_t(%IDifferentiable) = lookupWitness(%3, %4) -let %3 : witness_table_t(%IFloat) = lookupWitness(%5, %6) -let %7 : CapabilitySet = capabilityDisjunction(%8, %9, %10, %11, %12, %13, %14, %15, %16, %17, %18, %19, %20, %21, %22, %23, %24, %25, %26, %27, %28, %29, %30, %31, %32, %33, %34, %35, %36, %37, %38, %39, %40, %41, %42, %43, %44, %45, %46, %47, %48, %49, %50, %51, %52, %53, %54, %55, %56, %57, %58, %59, %60, %61, %62, %63, %64, %65, %66, %67, %68, %69, %70, %71, %72, %73, %74, %75, %76, %77, %78, %79, %80, %81, %82, %83, %84, %85, %86, %87, %88, %89, %90, %91, %92, %93, %94, %95, %96, %97, %98, %99, %100, %101, %102, %103, %104, %105, %106, %107, %108, %109, %110, %111, %112, %113, %114, %115, %116, %117, %118, %119) -let %119 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 75 : Int) -let %118 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 74 : Int) -let %117 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 73 : Int) -let %116 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 72 : Int) -let %115 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 71 : Int) -let %114 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 70 : Int) -let %113 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 69 : Int) -let %112 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 68 : Int) -let %111 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 67 : Int) -let %110 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 66 : Int) -let %109 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 65 : Int) -let %108 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 64 : Int) -let %107 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 63 : Int) -let %106 : CapabilitySet = capabilityConjunction(1 : Int, 9 : Int, 62 : Int) -let %105 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 75 : Int) -let %104 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 74 : Int) -let %103 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 73 : Int) -let %102 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 72 : Int) -let %101 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 71 : Int) -let %100 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 70 : Int) -let %99 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 69 : Int) -let %98 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 68 : Int) -let %97 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 67 : Int) -let %96 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 66 : Int) -let %95 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 65 : Int) -let %94 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 64 : Int) -let %93 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 63 : Int) -let %92 : CapabilitySet = capabilityConjunction(1 : Int, 8 : Int, 62 : Int) -let %91 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 75 : Int) -let %90 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 74 : Int) -let %89 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 73 : Int) -let %88 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 72 : Int) -let %87 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 71 : Int) -let %86 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 70 : Int) -let %85 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 69 : Int) -let %84 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 68 : Int) -let %83 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 67 : Int) -let %82 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 66 : Int) -let %81 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 65 : Int) -let %80 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 64 : Int) -let %79 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 63 : Int) -let %78 : CapabilitySet = capabilityConjunction(1 : Int, 7 : Int, 62 : Int) -let %77 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 75 : Int) -let %76 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 74 : Int) -let %75 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 73 : Int) -let %74 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 72 : Int) -let %73 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 71 : Int) -let %72 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 70 : Int) -let %71 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 69 : Int) -let %70 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 68 : Int) -let %69 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 67 : Int) -let %68 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 66 : Int) -let %67 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 65 : Int) -let %66 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 64 : Int) -let %65 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 63 : Int) -let %64 : CapabilitySet = capabilityConjunction(1 : Int, 6 : Int, 62 : Int) -let %63 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 75 : Int) -let %62 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 74 : Int) -let %61 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 73 : Int) -let %60 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 72 : Int) -let %59 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 71 : Int) -let %58 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 70 : Int) -let %57 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 69 : Int) -let %56 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 68 : Int) -let %55 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 67 : Int) -let %54 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 66 : Int) -let %53 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 65 : Int) -let %52 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 64 : Int) -let %51 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 63 : Int) -let %50 : CapabilitySet = capabilityConjunction(1 : Int, 5 : Int, 62 : Int) -let %49 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 75 : Int) -let %48 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 74 : Int) -let %47 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 73 : Int) -let %46 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 72 : Int) -let %45 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 71 : Int) -let %44 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 70 : Int) -let %43 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 69 : Int) -let %42 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 68 : Int) -let %41 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 67 : Int) -let %40 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 66 : Int) -let %39 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 65 : Int) -let %38 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 64 : Int) -let %37 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 63 : Int) -let %36 : CapabilitySet = capabilityConjunction(1 : Int, 4 : Int, 62 : Int) -let %35 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 75 : Int) -let %34 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 74 : Int) -let %33 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 73 : Int) -let %32 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 72 : Int) -let %31 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 71 : Int) -let %30 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 70 : Int) -let %29 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 69 : Int) -let %28 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 68 : Int) -let %27 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 67 : Int) -let %26 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 66 : Int) -let %25 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 65 : Int) -let %24 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 64 : Int) -let %23 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 63 : Int) -let %22 : CapabilitySet = capabilityConjunction(1 : Int, 3 : Int, 62 : Int) -let %21 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 75 : Int) -let %20 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 74 : Int) -let %19 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 73 : Int) -let %18 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 72 : Int) -let %17 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 71 : Int) -let %16 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 70 : Int) -let %15 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 69 : Int) -let %14 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 68 : Int) -let %13 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 67 : Int) -let %12 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 66 : Int) -let %11 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 65 : Int) -let %10 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 64 : Int) -let %9 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 63 : Int) -let %8 : CapabilitySet = capabilityConjunction(1 : Int, 2 : Int, 62 : Int) -let %5 : witness_table_t(%x5Fx5FBuiltinFloatingPointType) = thisTypeWitness -let %120 : _ = interface_req_entry(%121, witness_table_t(%x5Fx5FBuiltinRealType)) -let %122 : _ = interface_req_entry(%6, witness_table_t(%IFloat)) -let %123 : _ = interface_req_entry(%124, Func(this_type(%x5Fx5FBuiltinFloatingPointType))) -let %125 : _ = interface_req_entry(%126, Func(DiffPairUserCode(this_type(%x5Fx5FBuiltinFloatingPointType), %2))) -let %127 : _ = interface_req_entry(%128, Func(Void, associated_type(%IDifferentiable))) -[treatAsDifferentiableDecoration] -[BuiltinDecoration] -[import("_ST4core26__BuiltinFloatingPointType")] -[nameHint("__BuiltinFloatingPointType")] -let %x5Fx5FBuiltinFloatingPointType : Type = interface(%120, %122, %123, %125, %127) -[import("_S4core26__BuiltinFloatingPointTypeI4core17__BuiltinRealType")] -let %121 : _ = key -let %129 : _ = interface_req_entry(%130, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[import("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%129) -[import("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %130 : _ = key -let %131 : _ = interface_req_entry(%132, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[import("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%131) -[import("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %132 : _ = key -let %133 : _ = interface_req_entry(%134, witness_table_t(%x5Fx5FBuiltinType)) -let %135 : _ = interface_req_entry(%136, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[import("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%133, %135) -[import("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %134 : _ = key -[BuiltinDecoration] -[import("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -[import("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %136 : _ = key -let %137 : _ = interface_req_entry(%138, witness_table_t(%IComparable)) -let %139 : _ = interface_req_entry(%140, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %141 : _ = interface_req_entry(%142, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %143 : _ = interface_req_entry(%144, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %145 : _ = interface_req_entry(%146, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %147 : _ = interface_req_entry(%148, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -let %149 : _ = interface_req_entry(%150, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -let %151 : _ = interface_req_entry(%152, Func(this_type(%IArithmetic), Int)) -let %153 : _ = interface_req_entry(%154, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[import("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%137, %139, %141, %143, %145, %147, %149, %151, %153) -[import("_S4core11IArithmeticI4core11IComparable")] -let %138 : _ = key -let %155 : _ = interface_req_entry(%156, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -let %157 : _ = interface_req_entry(%158, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -let %159 : _ = interface_req_entry(%160, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[import("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%155, %157, %159) -[import("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %156 : _ = key -[import("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %158 : _ = key -[import("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %160 : _ = key -[import("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %140 : _ = key -[import("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %142 : _ = key -[import("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %144 : _ = key -[import("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %146 : _ = key -[import("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %148 : _ = key -[import("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %150 : _ = key -[import("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %152 : _ = key -[import("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %154 : _ = key -[import("_S4core26__BuiltinFloatingPointTypeI4core6IFloat")] -let %6 : _ = key -let %161 : _ = interface_req_entry(%162, witness_table_t(%IArithmetic)) -let %163 : _ = interface_req_entry(%4, witness_table_t(%IDifferentiable)) -let %164 : _ = interface_req_entry(%165, Func(this_type(%IFloat), Float)) -let %166 : _ = interface_req_entry(%167, Func(Float, this_type(%IFloat))) -let %168 : _ = interface_req_entry(%169, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %170 : _ = interface_req_entry(%171, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %172 : _ = interface_req_entry(%173, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %174 : _ = interface_req_entry(%175, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %176 : _ = interface_req_entry(%177, Func(this_type(%IFloat), this_type(%IFloat), this_type(%IFloat))) -let %178 : _ = interface_req_entry(%179, Func(this_type(%IFloat), this_type(%IFloat))) -let %180 : _ = interface_req_entry(%181, Func(this_type(%IFloat), this_type(%IFloat))) -let %182 : _ = interface_req_entry(%183, %184) -[import("_ST4core6IFloat")] -[nameHint("IFloat")] -let %IFloat : Type = interface(%161, %163, %164, %166, %168, %170, %172, %174, %176, %178, %180, %182) -[import("_S4core6IFloatI4core11IArithmetic")] -let %162 : _ = key -[import("_S4core6IFloatI4core15IDifferentiable")] -let %4 : _ = key -let %185 : _ = interface_req_entry(%186, associated_type(%IDifferentiable)) -let %187 : _ = interface_req_entry(%188, witness_table_t(%IDifferentiable)) -let %189 : _ = interface_req_entry(%190, Func(associated_type(%IDifferentiable))) -let %191 : _ = interface_req_entry(%192, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -let %193 : _ = interface_req_entry(%194, %195) -[import("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%185, %187, %189, %191, %193) -[import("_ST4core15IDifferentiable12Differential")] -let %186 : _ = key -[import("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %188 : _ = key -[StaticRequirementDecoration] -[import("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %190 : _ = key -[StaticRequirementDecoration] -[import("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %192 : _ = key -[StaticRequirementDecoration] -[import("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %194 : _ = key -generic %195 : Generic -{ -block %196( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %197 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -[import("_S4core6IFloatR8_24xinitp1pi_f")] -let %165 : _ = key -[import("_S4core6IFloat7toFloatp0pf")] -let %167 : _ = key -[import("_S4core6IFloat3addp1pi_4core6IFloat4This4core6IFloat4This")] -let %169 : _ = key -[import("_S4core6IFloat3subp1pi_4core6IFloat4This4core6IFloat4This")] -let %171 : _ = key -[import("_S4core6IFloat3mulp1pi_4core6IFloat4This4core6IFloat4This")] -let %173 : _ = key -[import("_S4core6IFloat3divp1pi_4core6IFloat4This4core6IFloat4This")] -let %175 : _ = key -[import("_S4core6IFloat3modp1pi_4core6IFloat4This4core6IFloat4This")] -let %177 : _ = key -[import("_S4core6IFloat3negp0p4core6IFloat4This")] -let %179 : _ = key -[import("_S4core6IFloatR8_24xinitp1pi_4core6IFloat4This")] -let %181 : _ = key -[import("_S4core6IFloat5scaleg2TC4core6IFloat1T4core26__BuiltinFloatingPointTypep1pi_4core6IFloat1T4core6IFloat4This")] -let %183 : _ = key -generic %184 : Generic -{ -block %198( - [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] - [nameHint("IFloat.T")] - param %IFloatx5FT : type_t, - param %199 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): - return_val(Func(this_type(%IFloat), this_type(%IFloat), %IFloatx5FT)) -} -[backwardDiffReference(%128)] -[fwdDerivative(%126)] -[StaticRequirementDecoration] -[import("_S4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] -let %124 : _ = key -[StaticRequirementDecoration] -[import("_SFwdReq_4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] -let %126 : _ = key -[StaticRequirementDecoration] -[import("_SBwdReq_4core26__BuiltinFloatingPointType5getPip0p4core26__BuiltinFloatingPointType4Thisb")] -let %128 : _ = key -[export("_SWf4core13__BuiltinType")] -witness_table %200 : witness_table_t(%x5Fx5FBuiltinType)(Float); - -[intrinsicOp(272 : Int)] -[method] -[import("_S4core5float6equalsp1pi_fb")] -[nameHint("float.equals")] -func %floatx5Fequals : Func(Bool, Float, Float); - -[intrinsicOp(275 : Int)] -[method] -[import("_S4core5float8lessThanp1pi_fb")] -[nameHint("float.lessThan")] -func %floatx5FlessThan : Func(Bool, Float, Float); - -[intrinsicOp(277 : Int)] -[method] -[import("_S4core5float16lessThanOrEqualsp1pi_fb")] -[nameHint("float.lessThanOrEquals")] -func %floatx5FlessThanOrEquals : Func(Bool, Float, Float); - -[export("_SWf4core11IComparable")] -witness_table %201 : witness_table_t(%IComparable)(Float) -{ - witness_table_entry(%156,%floatx5Fequals) - - witness_table_entry(%158,%floatx5FlessThan) - - witness_table_entry(%160,%floatx5FlessThanOrEquals) - -} - -[intrinsicOp(264 : Int)] -[method] -[import("_S4core5float3addp1pi_ff")] -[nameHint("float.add")] -func %floatx5Fadd : Func(Float, Float, Float); - -[intrinsicOp(265 : Int)] -[method] -[import("_S4core5float3subp1pi_ff")] -[nameHint("float.sub")] -func %floatx5Fsub : Func(Float, Float, Float); - -[intrinsicOp(266 : Int)] -[method] -[import("_S4core5float3mulp1pi_ff")] -[nameHint("float.mul")] -func %floatx5Fmul : Func(Float, Float, Float); - -[intrinsicOp(267 : Int)] -[method] -[import("_S4core5float3divp1pi_ff")] -[nameHint("float.div")] -func %floatx5Fdiv : Func(Float, Float, Float); - -[intrinsicOp(269 : Int)] -[method] -[import("_S4core5float3modp1pi_ff")] -[nameHint("float.mod")] -func %floatx5Fmod : Func(Float, Float, Float); - -[intrinsicOp(283 : Int)] -[method] -[import("_S4core5float3negp0pf")] -[nameHint("float.neg")] -func %floatx5Fneg : Func(Float, Float); - -[intrinsicOp(500 : Int)] -[method] -[import("_S4core5floatR8_24xinitp1pi_i")] -[nameHint("float.$init")] -func %floatx5Fx24init : Func(Float, Int); - -[intrinsicOp(0 : Int)] -[treatAsDifferentiableDecoration] -[method] -[import("_S4core5floatR8_24xinitp1pi_f")] -[nameHint("float.$init")] -func %floatx5Fx24init1 : Func(Float, Float); - -[export("_SWf4core11IArithmetic")] -witness_table %202 : witness_table_t(%IArithmetic)(Float) -{ - witness_table_entry(%138,%201) - - witness_table_entry(%140,%floatx5Fadd) - - witness_table_entry(%142,%floatx5Fsub) - - witness_table_entry(%144,%floatx5Fmul) - - witness_table_entry(%146,%floatx5Fdiv) - - witness_table_entry(%148,%floatx5Fmod) - - witness_table_entry(%150,%floatx5Fneg) - - witness_table_entry(%152,%floatx5Fx24init) - - witness_table_entry(%154,%floatx5Fx24init1) - -} - -[export("_SWf4core23__BuiltinArithmeticType")] -witness_table %203 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Float) -{ - witness_table_entry(%134,%200) - - witness_table_entry(%136,%202) - -} - -[export("_SWf4core29__BuiltinSignedArithmeticType")] -witness_table %204 : witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)(Float) -{ - witness_table_entry(%132,%203) - -} - -[export("_SWf4core17__BuiltinRealType")] -witness_table %205 : witness_table_t(%x5Fx5FBuiltinRealType)(Float) -{ - witness_table_entry(%130,%204) - -} - -[export("_SWf4core11IComparable")] -witness_table %206 : witness_table_t(%IComparable)(Float) -{ - witness_table_entry(%156,%floatx5Fequals) - - witness_table_entry(%158,%floatx5FlessThan) - - witness_table_entry(%160,%floatx5FlessThanOrEquals) - -} - -[export("_SWf4core11IArithmetic")] -witness_table %207 : witness_table_t(%IArithmetic)(Float) -{ - witness_table_entry(%138,%206) - - witness_table_entry(%140,%floatx5Fadd) - - witness_table_entry(%142,%floatx5Fsub) - - witness_table_entry(%144,%floatx5Fmul) - - witness_table_entry(%146,%floatx5Fdiv) - - witness_table_entry(%148,%floatx5Fmod) - - witness_table_entry(%150,%floatx5Fneg) - - witness_table_entry(%152,%floatx5Fx24init) - - witness_table_entry(%154,%floatx5Fx24init1) - -} - -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[import("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %208: - return_val(0 : Float) -} -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[import("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %209( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %210 : Float = add(%a, %b) - return_val(%210) -} -generic %211 : Generic -{ -block %212( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %213 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %1), Float)) -} -[import("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %214 : %211 -{ -block %215( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %216 : witness_table_t(%x5Fx5FBuiltinRealType)): - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %1), Float) - { -block %217( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %1), - [nameHint("b")] - param %b1 : Float): - let %218 : Float = floatCast(%a1) - let %219 : Float = mul(%218, %b1) - return_val(%219) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %220 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%186,Float) - - witness_table_entry(%188,%220) - - witness_table_entry(%190,%floatx5Fdzero) - - witness_table_entry(%192,%floatx5Fdadd) - - witness_table_entry(%194,%214) - -} - -[intrinsicOp(499 : Int)] -[method] -[import("_S4core5float7toFloatp0pf")] -[nameHint("float.toFloat")] -func %floatx5FtoFloat : Func(Float, Float); - -generic %221 : Generic -{ -block %222( - [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] - [nameHint("float.T")] - param %floatx5FT : type_t, - param %223 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): - return_val(Func(Float, Float, %floatx5FT)) -} -[import("_S4core5float5scaleg2TC4core5float1T4core26__BuiltinFloatingPointTypep1pi_4core5float1Tf")] -generic %224 : %221 -{ -block %225( - [TypeConstraintDecoration(%x5Fx5FBuiltinFloatingPointType)] - [nameHint("float.T")] - param %floatx5FT1 : type_t, - param %226 : witness_table_t(%x5Fx5FBuiltinFloatingPointType)): - [intrinsicOp(266 : Int)] - [nameHint("float.scale")] - func %floatx5Fscale : Func(Float, Float, %floatx5FT1); - - return_val(%floatx5Fscale) -} -[export("_SWf4core6IFloat")] -witness_table %227 : witness_table_t(%IFloat)(Float) -{ - witness_table_entry(%162,%207) - - witness_table_entry(%4,%220) - - witness_table_entry(%165,%floatx5Fx24init1) - - witness_table_entry(%167,%floatx5FtoFloat) - - witness_table_entry(%169,%floatx5Fadd) - - witness_table_entry(%171,%floatx5Fsub) - - witness_table_entry(%173,%floatx5Fmul) - - witness_table_entry(%175,%floatx5Fdiv) - - witness_table_entry(%177,%floatx5Fmod) - - witness_table_entry(%179,%floatx5Fneg) - - witness_table_entry(%181,%floatx5Fx24init1) - - witness_table_entry(%183,%224) - -} - -[export("_SWi4core13__BuiltinType")] -witness_table %228 : witness_table_t(%x5Fx5FBuiltinType)(Int); - -[intrinsicOp(272 : Int)] -[method] -[import("_S4core3int6equalsp1pi_ib")] -[nameHint("int.equals")] -func %intx5Fequals : Func(Bool, Int, Int); - -[intrinsicOp(275 : Int)] -[method] -[import("_S4core3int8lessThanp1pi_ib")] -[nameHint("int.lessThan")] -func %intx5FlessThan : Func(Bool, Int, Int); - -[intrinsicOp(277 : Int)] -[method] -[import("_S4core3int16lessThanOrEqualsp1pi_ib")] -[nameHint("int.lessThanOrEquals")] -func %intx5FlessThanOrEquals : Func(Bool, Int, Int); - -[export("_SWi4core11IComparable")] -witness_table %229 : witness_table_t(%IComparable)(Int) -{ - witness_table_entry(%156,%intx5Fequals) - - witness_table_entry(%158,%intx5FlessThan) - - witness_table_entry(%160,%intx5FlessThanOrEquals) - -} - -[intrinsicOp(264 : Int)] -[method] -[import("_S4core3int3addp1pi_ii")] -[nameHint("int.add")] -func %intx5Fadd : Func(Int, Int, Int); - -[intrinsicOp(265 : Int)] -[method] -[import("_S4core3int3subp1pi_ii")] -[nameHint("int.sub")] -func %intx5Fsub : Func(Int, Int, Int); - -[intrinsicOp(266 : Int)] -[method] -[import("_S4core3int3mulp1pi_ii")] -[nameHint("int.mul")] -func %intx5Fmul : Func(Int, Int, Int); - -[intrinsicOp(267 : Int)] -[method] -[import("_S4core3int3divp1pi_ii")] -[nameHint("int.div")] -func %intx5Fdiv : Func(Int, Int, Int); - -[intrinsicOp(268 : Int)] -[method] -[import("_S4core3int3modp1pi_ii")] -[nameHint("int.mod")] -func %intx5Fmod : Func(Int, Int, Int); - -[intrinsicOp(283 : Int)] -[method] -[import("_S4core3int3negp0pi")] -[nameHint("int.neg")] -func %intx5Fneg : Func(Int, Int); - -[intrinsicOp(0 : Int)] -[method] -[import("_S4core3intR8_24xinitp1pi_i")] -[nameHint("int.$init")] -func %intx5Fx24init : Func(Int, Int); - -[export("_SWi4core11IArithmetic")] -witness_table %230 : witness_table_t(%IArithmetic)(Int) -{ - witness_table_entry(%138,%229) - - witness_table_entry(%140,%intx5Fadd) - - witness_table_entry(%142,%intx5Fsub) - - witness_table_entry(%144,%intx5Fmul) - - witness_table_entry(%146,%intx5Fdiv) - - witness_table_entry(%148,%intx5Fmod) - - witness_table_entry(%150,%intx5Fneg) - - witness_table_entry(%152,%intx5Fx24init) - - witness_table_entry(%154,%intx5Fx24init) - -} - -[export("_SWi4core23__BuiltinArithmeticType")] -witness_table %231 : witness_table_t(%x5Fx5FBuiltinArithmeticType)(Int) -{ - witness_table_entry(%134,%228) - - witness_table_entry(%136,%230) - -} - -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %232( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%233, %234, %235, %y, 0 : Int) - -block %233( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %236 : Bool = cmpLT(%i, 3 : Int) - ifElse(%236, %237, %234, %237) - -block %237: - let %238 : Float = mul(%t, %t) - unconditionalBranch(%235) - -block %235: - let %239 : Int = add(%i, 1 : Int) - unconditionalBranch(%233, %238, %239) - -block %234: - return_val(%t) -} -[import("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[import("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %240 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %240) = global_param -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %241( - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %220)) = var - let %242 : DiffPairUserCode(Float, %220) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %242) - let %243 : Func(Void, InOut(DiffPairUserCode(Float, %220)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %243(%dpa, 1 : Float) - let %244 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %245 : DiffPairUserCode(Float, %220) = load(%dpa) - let %246 : Float = GetDifferentialUserCode(%245) - store(%244, %246) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %220)) = var - let %247 : DiffPairUserCode(Float, %220) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %247) - let %248 : Func(Void, InOut(DiffPairUserCode(Float, %220)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %248(%dpa1, 1 : Float) - let %249 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %250 : DiffPairUserCode(Float, %220) = load(%dpa1) - let %251 : Float = GetDifferentialUserCode(%250) - store(%249, %251) - return_val(void_constant) -} -### -### POST IR VALIDATION: -varLayout(%1) -let %1 : Void = structTypeLayout(%2) -let %2 : Void = fieldLayout(%outputBuffer, %3) -let %3 : Void = varLayout(%4, %5) -let %5 : Void = offset(9 : Int, 0 : Int) -let %4 : Void = structuredBufferTypeLayout(%6, %7) -let %7 : Void = size(9 : Int, 1 : Int) -let %6 : Void = typeLayout(%8) -let %8 : Void = size(8 : Int, 4 : Int) -let %9 : Void = no_diff -let %10 : Void = EntryPointLayout(%11, %12) -let %12 : Void = varLayout(%13) -let %11 : Void = varLayout(%14) -let %14 : Void = structTypeLayout(%15) -let %15 : Void = fieldLayout(%16, %17) -let %17 : Void = varLayout(%13, %18, %19) -let %19 : Void = stage(6 : Int) -let %18 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %13 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %16 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -let %27 : _ = interface_req_entry(%26, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %28 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %29 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %30 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %31 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %32 : _ = interface_req_entry(%31, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %33 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %34 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %39 : _ = key -let %40 : _ = interface_req_entry(%39, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%36, %38, %40) -let %41 : _ = interface_req_entry(%34, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %56 : _ = key -let %57 : _ = interface_req_entry(%56, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%41, %43, %45, %47, %49, %51, %53, %55, %57) -let %58 : _ = interface_req_entry(%33, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%32, %58) -let %59 : _ = interface_req_entry(%30, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%59) -let %60 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%60) -generic %61 : Generic -{ -block %62( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %63 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %64 : _ = interface_req_entry(%28, %61) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%21, %23, %25, %27, %64) -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %65: - return_val(0 : Float) -} -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %66( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %67 : Float = add(%a, %b) - return_val(%67) -} -generic %68 : Generic -{ -block %69( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %70 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %9), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %71 : %68 -{ -block %72( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %73 : witness_table_t(%x5Fx5FBuiltinRealType)): - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %9), Float) - { -block %74( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %9), - [nameHint("b")] - param %b1 : Float): - let %75 : Float = floatCast(%a1) - let %76 : Float = mul(%75, %b1) - return_val(%76) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %77 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%20,Float) - - witness_table_entry(%22,%77) - - witness_table_entry(%24,%floatx5Fdzero) - - witness_table_entry(%26,%floatx5Fdadd) - - witness_table_entry(%28,%71) - -} - -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %78( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%79, %80, %81, %y, 0 : Int) - -block %79( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %82 : Bool = cmpLT(%i, 3 : Int) - ifElse(%82, %83, %80, %83) - -block %83: - let %84 : Float = mul(%t, %t) - unconditionalBranch(%81) - -block %81: - let %85 : Int = add(%i, 1 : Int) - unconditionalBranch(%79, %84, %85) - -block %80: - return_val(%t) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %86 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%3)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %86) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%10)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %87( - [layout(%17)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %77)) = var - let %88 : DiffPairUserCode(Float, %77) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %88) - let %89 : Func(Void, InOut(DiffPairUserCode(Float, %77)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %89(%dpa, 1 : Float) - let %90 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %91 : DiffPairUserCode(Float, %77) = load(%dpa) - let %92 : Float = GetDifferentialUserCode(%91) - store(%90, %92) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %77)) = var - let %93 : DiffPairUserCode(Float, %77) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %93) - let %94 : Func(Void, InOut(DiffPairUserCode(Float, %77)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %94(%dpa1, 1 : Float) - let %95 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %96 : DiffPairUserCode(Float, %77) = load(%dpa1) - let %97 : Float = GetDifferentialUserCode(%96) - store(%95, %97) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %98: - let %99 : %NullDifferential = makeStruct(0 : UInt) - return_val(%99) -} -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %100( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %101 : %NullDifferential = makeStruct(0 : UInt) - return_val(%101) -} -generic %102 : Generic -{ -block %103( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %104 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %9), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %105 : %102 -{ -block %106( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %107 : witness_table_t(%x5Fx5FBuiltinRealType)): - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %9), %NullDifferential) - { -block %108( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %9), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %109 : %NullDifferential = makeStruct(0 : UInt) - return_val(%109) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %110 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%20,%NullDifferential) - - witness_table_entry(%22,%110) - - witness_table_entry(%24,%NullDifferentialx5Fdzero) - - witness_table_entry(%26,%NullDifferentialx5Fdadd) - - witness_table_entry(%28,%105) - -} - -### -### BEFORE-SPECIALIZE: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) - -block %78: - return_val(%t) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - let %87 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %87(%dpa, 1 : Float) - let %88 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %89 : DiffPairUserCode(Float, %75) = load(%dpa) - let %90 : Float = GetDifferentialUserCode(%89) - store(%88, %90) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %91 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %91) - let %92 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %92(%dpa1, 1 : Float) - let %93 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %94 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %95 : Float = GetDifferentialUserCode(%94) - store(%93, %95) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %96: - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %98( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %99 : %NullDifferential = makeStruct(0 : UInt) - return_val(%99) -} -generic %100 : Generic -{ -block %101( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %102 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %103 : %100 -{ -block %104( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %105 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %106( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %107 : %NullDifferential = makeStruct(0 : UInt) - return_val(%107) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %108 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%108) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%103) - -} - -### -### AFTER-SPECIALIZE: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) - -block %78: - return_val(%t) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - let %87 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %87(%dpa, 1 : Float) - let %88 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %89 : DiffPairUserCode(Float, %75) = load(%dpa) - let %90 : Float = GetDifferentialUserCode(%89) - store(%88, %90) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %91 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %91) - let %92 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %92(%dpa1, 1 : Float) - let %93 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %94 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %95 : Float = GetDifferentialUserCode(%94) - store(%93, %95) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %96: - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %98( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %99 : %NullDifferential = makeStruct(0 : UInt) - return_val(%99) -} -generic %100 : Generic -{ -block %101( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %102 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %103 : %100 -{ -block %104( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %105 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %106( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %107 : %NullDifferential = makeStruct(0 : UInt) - return_val(%107) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %108 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%108) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%103) - -} - -GenericSpecializationDictionary -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -### -### BEFORE-AUTODIFF: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) - -block %78: - return_val(%t) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - let %87 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %87(%dpa, 1 : Float) - let %88 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %89 : DiffPairUserCode(Float, %75) = load(%dpa) - let %90 : Float = GetDifferentialUserCode(%89) - store(%88, %90) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %91 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %91) - let %92 : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) = BackwardDifferentiate(%testx5Fsimplex5Floop) - call %92(%dpa1, 1 : Float) - let %93 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %94 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %95 : Float = GetDifferentialUserCode(%94) - store(%93, %95) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %96: - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %98( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %99 : %NullDifferential = makeStruct(0 : UInt) - return_val(%99) -} -generic %100 : Generic -{ -block %101( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %102 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %103 : %100 -{ -block %104( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %105 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %106( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %107 : %NullDifferential = makeStruct(0 : UInt) - return_val(%107) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %108 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%108) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%103) - -} - -GenericSpecializationDictionary -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -### -BACKWARD DIFFERENTIATE -BACKWARD DIFFERENTIATE -BACKWARD DIFFERENTIATE PRIMAL -BACKWARD DIFFERENTIATE PROPOGATE -(result before eliminating phis)=============================== -inst with location: 1515366 (1) -[nameHint("y")] -let %y : Float = param - -inst with location: 1515420 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, %y, 0 : Int) - -inst with location: 1515406 (1) -[nameHint("t")] -let %t : Float = param - -inst with location: 1515429 (1) -[nameHint("i")] -let %i : Int = param - -inst with location: 1515420 (1) -loop(%1, %2, %1) - -inst with location: 1515438 (1) -let %1 : Bool = cmpLT(%i, 3 : Int) - -inst with location: 1515420 (1) -ifElse(%1, %2, %3, %2) - -inst with location: 1515420 (1) -unconditionalBranch(%1) - -inst with location: 1515470 (1) -let %1 : Float = mul(%t, %t) - -inst with location: 1515420 (1) -unconditionalBranch(%1) - -inst with location: 1515420 (1) -unconditionalBranch(%1) - -inst with location: 1515444 (1) -let %1 : Int = add(%i, 1 : Int) - -inst with location: 1515420 (1) -unconditionalBranch(%1, %2, %3) - -inst with location: 1515489 (1) -return_val(%t) - -(fwdDiffFunc from generateNewForwardDerivative)=============================== -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[forwardDifferentiable] -[nameHint("s_fwd_test_simple_loop")] -func %sx5Ffwdx5Ftestx5Fsimplex5Floop : Func(DiffPair(Float, %1), DiffPair(Float, %1)) -{ -block %2( - [nameHint("dpy")] - param %dpy : DiffPair(Float, %1)): - [diffInstDecoration(Float)] - let %3 : Float = GetDifferential(%dpy) - [primalInstDecoration] - let %4 : Float = GetPrimal(%dpy) - [mixedDiffInstDecoration()] - [loopMaxIters(4 : Int)] - loop(%5, %6, %5, true, %4, %3, 0 : Int) - -block %5( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t : Float, - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft : Float, - [primalInstDecoration] - [nameHint("i")] - param %i : Int): - [mixedDiffInstDecoration()] - ifElse(%x5Fbflag, %7, %8, %7) - -block %8: - [mixedDiffInstDecoration()] - unconditionalBranch(%6) - -block %6: - [mixedDiffInstDecoration(DiffPair(Float, %1))] - let %9 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - [mixedDiffInstDecoration(DiffPair(Float, %1))] - return_val(%9) - -block %7: - [mixedDiffInstDecoration()] - unconditionalBranch(%10) - -block %10: - [primalInstDecoration] - let %11 : Bool = cmpLT(%i, 3 : Int) - [mixedDiffInstDecoration()] - ifElse(%11, %12, %13, %14) - -block %13: - [diffInstDecoration(Float)] - let %15 : Float = call %floatx5Fdzero() - [mixedDiffInstDecoration()] - unconditionalBranch(%14, 0 : Int, 0 : Float, %15) - -block %12: - [primalInstDecoration] - let %16 : Float = mul(%t, %t) - [diffInstDecoration(Float)] - let %17 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %18 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %19 : Float = add(%17, %18) - [mixedDiffInstDecoration()] - unconditionalBranch(%14, 1 : Int, %16, %19) - -block %14( - [primalInstDecoration] - param %20 : Int, - [primalInstDecoration] - param %21 : Float, - [diffInstDecoration(Float)] - param %22 : Float): - [mixedDiffInstDecoration()] - unconditionalBranch(%23) - -block %23: - [primalInstDecoration] - let %24 : Bool = cmpNE(%20, 1 : Int) - [mixedDiffInstDecoration()] - ifElse(%24, %25, %26, %27) - -block %26: - [mixedDiffInstDecoration()] - unconditionalBranch(%27, %x5Fbflag) - -block %25: - [mixedDiffInstDecoration()] - unconditionalBranch(%27, false) - -block %27( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - [mixedDiffInstDecoration()] - unconditionalBranch(%28) - -block %28: - [mixedDiffInstDecoration()] - ifElse(%x5Fbflag1, %29, %30, %31) - -block %30: - [mixedDiffInstDecoration()] - unconditionalBranch(%31, %t, %sx5Fdiffx5Ft, %i) - -block %29: - [primalInstDecoration] - let %32 : Int = add(%i, 1 : Int) - [mixedDiffInstDecoration()] - unconditionalBranch(%31, %21, %22, %32) - -block %31( - [primalInstDecoration] - [nameHint("t")] - param %t1 : Float, - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft1 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i1 : Int): - [mixedDiffInstDecoration()] - unconditionalBranch(%5, %x5Fbflag1, %t1, %sx5Fdiffx5Ft1, %i1) -} - -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : DiffPair(Float, %1) = param - -inst with location: 1515366 (1) -[diffInstDecoration(Float)] -let %1 : Float = GetDifferential(%dpy) - -inst with location: 1515366 (1) -[primalInstDecoration] -let %1 : Float = GetPrimal(%dpy) - -inst with location: 1515420 (1) -[mixedDiffInstDecoration()] -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, %4, 0 : Int) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515406 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%x5Fbflag, %1, %2, %1) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) - -inst with location: 0 (0) -[mixedDiffInstDecoration(DiffPair(Float, %1))] -let %2 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - -inst with location: 1515489 (1) -[mixedDiffInstDecoration(DiffPair(Float, %1))] -return_val(%2) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) - -inst with location: 1515438 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, 0 : Int, 0 : Float, %2) - -inst with location: 1515470 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 1515470 (1) -[diffInstDecoration(Float)] -let %1 : Float = add(%2, %3) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, 1 : Int, %2, %3) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = param - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, false) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %t, %sx5Fdiffx5Ft, %i) - -inst with location: 1515444 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %2, %3, %4) - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515406 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -[mixedDiffInstDecoration()] -unconditionalBranch(%1, %x5Fbflag, %t, %sx5Fdiffx5Ft, %i) - -(diffPropagateFunc after unzipping)=============================== -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)); - - -(unzipDiffInsts)=============================== -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : DiffPair(Float, %1) = param - -inst with location: 0 (0) -let %1 : Float = PrimalParamRef(%dpy) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = DiffParamRef(%dpy) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 1515420 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, 0 : Int) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[BackwardDerivativePrimalReturnDecoration(%t)] -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 1515438 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1, 0 : Int, 0 : Float) - -inst with location: 1515470 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) - -inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int, %2) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag) - -inst with location: 0 (0) -unconditionalBranch(%1, false) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %t, %i) - -inst with location: 1515444 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) - -inst with location: 0 (0) -unconditionalBranch(%1, %2, %3) - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag, %t, %i) - -inst with location: 1515420 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, %3) - -inst with location: 1515406 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -return_val(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 1515470 (1) -[diffInstDecoration(Float)] -let %1 : Float = add(%2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 1515406 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) - -(diffPropagateFunc moving blocks)=============================== -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPair(Float, %1)), Float, BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop)) -{ -block %2( - [nameHint("dpy")] - param %dpy : DiffPair(Float, %1)): - let %3 : Float = PrimalParamRef(%dpy) - [diffInstDecoration(Float)] - let %4 : Float = DiffParamRef(%dpy) - unconditionalBranch(%5) - -block %5: - [loopMaxIters(4 : Int)] - loop(%6, %7, %6, true, %3, 0 : Int) - -block %6( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t : Float, - [primalInstDecoration] - [nameHint("i")] - param %i : Int): - ifElse(%x5Fbflag, %8, %9, %8) - -block %9: - unconditionalBranch(%7) - -block %7: - [BackwardDerivativePrimalReturnDecoration(%t)] - unconditionalBranch(%10) - -block %8: - unconditionalBranch(%11) - -block %11: - [primalInstDecoration] - let %12 : Bool = cmpLT(%i, 3 : Int) - ifElse(%12, %13, %14, %15) - -block %14: - unconditionalBranch(%15, 0 : Int, 0 : Float) - -block %13: - [primalInstDecoration] - let %16 : Float = mul(%t, %t) - unconditionalBranch(%15, 1 : Int, %16) - -block %15( - [primalInstDecoration] - param %17 : Int, - [primalInstDecoration] - param %18 : Float): - unconditionalBranch(%19) - -block %19: - [primalInstDecoration] - let %20 : Bool = cmpNE(%17, 1 : Int) - ifElse(%20, %21, %22, %23) - -block %22: - unconditionalBranch(%23, %x5Fbflag) - -block %21: - unconditionalBranch(%23, false) - -block %23( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%24) - -block %24: - ifElse(%x5Fbflag1, %25, %26, %27) - -block %26: - unconditionalBranch(%27, %t, %i) - -block %25: - [primalInstDecoration] - let %28 : Int = add(%i, 1 : Int) - unconditionalBranch(%27, %18, %28) - -block %27( - [primalInstDecoration] - [nameHint("t")] - param %t1 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i1 : Int): - unconditionalBranch(%6, %x5Fbflag1, %t1, %i1) - -block %10: - [loopMaxIters(4 : Int)] - loop(%29, %30, %29, %4) - -block %29( - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft : Float): - ifElse(%x5Fbflag, %31, %32, %31) - -block %32: - unconditionalBranch(%30) - -block %30: - [diffInstDecoration(Float)] - let %33 : DiffPair(Float, %1) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - [diffInstDecoration(Float)] - return_val(%33) - -block %31: - unconditionalBranch(%34) - -block %34: - ifElse(%12, %35, %36, %37) - -block %36: - [diffInstDecoration(Float)] - let %38 : Float = call %floatx5Fdzero() - unconditionalBranch(%37, %38) - -block %35: - [diffInstDecoration(Float)] - let %39 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %40 : Float = mul(%sx5Fdiffx5Ft, %t) - [diffInstDecoration(Float)] - let %41 : Float = add(%39, %40) - unconditionalBranch(%37, %41) - -block %37( - [diffInstDecoration(Float)] - param %42 : Float): - unconditionalBranch(%43) - -block %43: - ifElse(%20, %44, %45, %46) - -block %45: - unconditionalBranch(%46) - -block %44: - unconditionalBranch(%46) - -block %46: - unconditionalBranch(%47) - -block %47: - ifElse(%x5Fbflag1, %48, %49, %50) - -block %49: - unconditionalBranch(%50, %sx5Fdiffx5Ft) - -block %48: - unconditionalBranch(%50, %42) - -block %50( - [diffInstDecoration(Float)] - [nameHint("s_diff_t")] - param %sx5Fdiffx5Ft1 : Float): - unconditionalBranch(%29, %sx5Fdiffx5Ft1) -} - -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : DiffPair(Float, %1) = param - -inst with location: 0 (0) -let %1 : Float = PrimalParamRef(%dpy) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = DiffParamRef(%dpy) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 1515420 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, true, %3, 0 : Int) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[BackwardDerivativePrimalReturnDecoration(%t)] -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 1515438 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1, 0 : Int, 0 : Float) - -inst with location: 1515470 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) - -inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int, %2) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag) - -inst with location: 0 (0) -unconditionalBranch(%1, false) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %t, %i) - -inst with location: 1515444 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) - -inst with location: 0 (0) -unconditionalBranch(%1, %2, %3) - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag, %t, %i) - -inst with location: 1515420 (1) -[loopMaxIters(4 : Int)] -loop(%1, %2, %1, %3) - -inst with location: 1515406 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : DiffPair(Float, %2) = MakeDiffPair(%t, %sx5Fdiffx5Ft) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -return_val(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = mul(%sx5Fdiffx5Ft, %t) - -inst with location: 1515470 (1) -[diffInstDecoration(Float)] -let %1 : Float = add(%2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -[diffInstDecoration(Float)] -let %1 : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 1515406 (1) -[diffInstDecoration(Float)] -[nameHint("s_diff_t")] -let %sx5Fdiffx5Ft : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1, %sx5Fdiffx5Ft) - -(applyCheckpointPolicy) =============================== -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : Float = param - -inst with location: 0 (0) -[nameHint("dpy")] -let %dpy : InOut(DiffPair(Float, %1)) = param - -inst with location: 0 (0) -[nameHint("_s_dOut")] -let %x5Fsx5FdOut : Float = param - -inst with location: 0 (0) -[nameHint("_s_diff_ctx")] -let %x5Fsx5Fdiffx5Fctx : BwdDiffIntermediateCtxType(%testx5Fsimplex5Floop) = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : DiffPair(Float, %2) = load(%dpy) - -inst with location: 0 (0) -[keepAlive] -let %1 : Float = GetPrimal(%2) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 1515420 (1) -[loopMaxIters(4 : Int)] -let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[BackwardDerivativePrimalReturnDecoration(%t)] -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -let %1 : Ptr(Float) = var - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -let %1 : Ptr(Float) = var - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -let %1 : Float = load(%2) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %2) - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[diffInstDecoration(Void, %1)] -[loopMaxIters(4 : Int)] -loop(%2, %3, %4) - -inst with location: 0 (0) -let %1 : Float = load(%2) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %1) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -let %1 : Float = param - -inst with location: 0 (0) -let %1 : DiffPair(Float, %2) = load(%dpy) - -inst with location: 0 (0) -let %1 : Float = GetPrimal(%2) - -inst with location: 0 (0) -let %1 : DiffPair(Float, %2) = MakeDiffPair(%3, %4) - -inst with location: 0 (0) -store(%dpy, %1) - -inst with location: 0 (0) -return_val(void_constant) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -let %1 : Float = param - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -let %1 : Float = param - -inst with location: 0 (0) -let %1 : Float = load(%2) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -let %1 : Float = param - -inst with location: 0 (0) -let %1 : Float = load(%2) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -let %1 : Float = load(%2) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdzero() - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -let %1 : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1, %2) - -inst with location: 0 (0) -let %1 : Float = param - -inst with location: 0 (0) -let %1 : Float = mul(%t, %2) - -inst with location: 0 (0) -let %1 : Float = mul(%t, %2) - -inst with location: 0 (0) -let %1 : Float = load(%2) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) - -inst with location: 0 (0) -let %1 : Float = call %floatx5Fdadd(%2, %3) - -inst with location: 0 (0) -store(%1, %2) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 1515438 (1) -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1, 0 : Int, 0 : Float) - -inst with location: 1515470 (1) -[primalInstDecoration] -let %1 : Float = mul(%t, %t) - -inst with location: 0 (0) -unconditionalBranch(%1, 1 : Int, %2) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Int = param - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Float = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) - -inst with location: 0 (0) -ifElse(%1, %2, %3, %4) - -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag) - -inst with location: 0 (0) -unconditionalBranch(%1, false) - -inst with location: 0 (0) -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -inst with location: 0 (0) -unconditionalBranch(%1) - -inst with location: 0 (0) -ifElse(%x5Fbflag, %1, %2, %3) - -inst with location: 0 (0) -unconditionalBranch(%1, %t, %i) - -inst with location: 1515444 (1) -[primalInstDecoration] -let %1 : Int = add(%i, 1 : Int) - -inst with location: 0 (0) -unconditionalBranch(%1, %2, %3) - -inst with location: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515429 (1) -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -inst with location: 0 (0) -unconditionalBranch(%1, %x5Fbflag, %t, %i) - -Adding counter for primalLoop: -[loopMaxIters(4 : Int)] -let %1 : _ = loop(%2, %3, %2, true, %dpy, 0 : Int) - - > sourceLoc: 1515420 (1) ->> Counter for primalLoop: -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param - - > sourceLoc: 1515420 (1) -### Slang::AutodiffCheckpointPolicyBase::processFunc -processing workList -use with usedVal: -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - - -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E59785E0 to storeSet -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515406 (1) -use with usedVal: -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - - -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E59785E0 to storeSet -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -inst with location: 1515406 (1) -use with usedVal: -[primalInstDecoration] -let %1 : Bool = cmpLT(%i, 3 : Int) - -use with usedVal: -[primalInstDecoration] -[nameHint("i")] -let %i : Int = param - -use with usedVal: -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) - -use with usedVal: -[primalInstDecoration] -let %1 : Int = param - -use with usedVal: -0 - -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5969B60 to storeSet -0 -inst with location: 0 (0) -use with usedVal: -1 - -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5969730 to storeSet -1 -inst with location: 0 (0) -use with usedVal: -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -use with usedVal: -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - -use with usedVal: - - -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5955730 to storeSet - -inst with location: 0 (0) -use with usedVal: -[nameHint("dpy")] -let %dpy : InOut(DiffPair(Float, %1)) = param - -use with usedVal: -[nameHint("dpy")] -let %dpy : InOut(DiffPair(Float, %1)) = param - -use with usedVal: -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param - - -[#] Slang::AutodiffCheckpointPolicyBase::processFunc, adding 00000244E5983928 to storeSet -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param - -inst with location: 1515420 (1) -use with usedVal: -[nameHint("_s_dOut")] -let %x5Fsx5FdOut : Float = param - -****** (before legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 1515406 (1) -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -source loc recorded: 1515420 (1) -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param - -****** ensureInstAvailable -ensureInstAvailable, worklist element: -[primalInstDecoration] -[nameHint("_pc")] -[loopCounterDecoration] -let %x5Fpc : Int = param - ->> LOOP COUNTER! -% localVar: -[loopCounterDecoration] -let %1 : Ptr(Int) = var - -ensureInstAvailable, worklist element: -[primalInstDecoration] -[nameHint("t")] -let %t : Float = param - -% localVar: -let %1 : Ptr(Array(Float, 5 : Int)) = var - -ensureInstAvailable, worklist element: -[primalInstDecoration] -[nameHint("_bflag")] -let %x5Fbflag : Bool = param - ->> NO OUT OF SCOPE USES -ensureInstAvailable, worklist element: -[primalInstDecoration] -let %1 : Bool = cmpNE(%2, 1 : Int) - ->> NO OUT OF SCOPE USES -ensureInstAvailable, worklist element: -[primalInstDecoration] -let %1 : Int = param - ->> NO OUT OF SCOPE USES -ensureInstAvailable, worklist element: -[primalInstDecoration] -let %1 : Bool = cmpLT(%2, 3 : Int) - ->> NO OUT OF SCOPE USES -****** (after legalization) # of elements in the store set for hoistInfo: 2 -source loc recorded: 1515420 (1) -[loopCounterDecoration] -let %1 : Ptr(Int) = var - -tests/autodiff/reverse-loop.slang(16): note: also see pipeline definition - for (int i = 0; i < 3; i++) - ^~~ -source loc recorded: 1515406 (1) -let %1 : Ptr(Array(Float, 5 : Int)) = var - -tests/autodiff/reverse-loop.slang(14): note: also see pipeline definition - float t = y; - ^ -in unzipping function: -createIntermediate type: -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type; - - -ADDING FIELD: -let %1 : Ptr(Array(Float, 5 : Int)) = var - -[IntermediateContextFieldDifferentialTypeDecoration(%1)] -field(%2, Array(Float, 5 : Int)) - -ADDING FIELD: -[loopCounterDecoration] -let %1 : Ptr(Int) = var - -[loopCounterDecoration] -field(%1, Int) - -### AFTER-AUTODIFF: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] -[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] -[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] -[primalInstDecoration] -[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %78: - return_val(%t) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %88 : DiffPairUserCode(Float, %75) = load(%dpa) - let %89 : Float = GetDifferentialUserCode(%88) - store(%87, %89) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %90) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %93 : Float = GetDifferentialUserCode(%92) - store(%91, %93) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %94: - let %95 : %NullDifferential = makeStruct(0 : UInt) - return_val(%95) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %96( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -generic %98 : Generic -{ -block %99( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %101 : %98 -{ -block %102( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %104( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %105 : %NullDifferential = makeStruct(0 : UInt) - return_val(%105) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%106) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%101) - -} - -GenericSpecializationDictionary -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_test_simple_loop")] -func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) -{ -block %107( - param %108 : InOut(DiffPairUserCode(Float, %75)), - param %109 : Float): - let %110 : DiffPairUserCode(Float, %75) = load(%108) - let %111 : Float = GetPrimalUserCode(%110) - let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) - let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) - return_val(void_constant) -} -[nameHint("s_primal_ctx_test_simple_loop")] -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) -{ -block %115( - [nameHint("dpy")] - param %dpy : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - unconditionalBranch(%116) - -block %116: - let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct - store(%x5Fsx5Fdiffx5Fctx, %117) - let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) - let %120 : Ptr(Array(Float, 5 : Int)) = var - let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%120, %121) - let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%118, %122) - let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) - [loopCounterDecoration] - let %125 : Ptr(Int) = var - store(%125, 0 : Int) - store(%123, 0 : Int) - unconditionalBranch(%126) - -block %126: - [loopMaxIters(4 : Int)] - loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) - -block %127( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t1 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i1 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc : Int): - let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) - store(%129, %t1) - store(%123, %x5Fpc) - ifElse(%x5Fbflag, %130, %131, %130) - -block %131: - unconditionalBranch(%128) - -block %128: - return_val(%t1) - -block %130: - unconditionalBranch(%132) - -block %132: - [primalInstDecoration] - let %133 : Bool = cmpLT(%i1, 3 : Int) - ifElse(%133, %134, %135, %136) - -block %135: - unconditionalBranch(%136, 0 : Int, 0 : Float) - -block %134: - [primalInstDecoration] - let %137 : Float = mul(%t1, %t1) - unconditionalBranch(%136, 1 : Int, %137) - -block %136( - [primalInstDecoration] - param %138 : Int, - [primalInstDecoration] - param %139 : Float): - unconditionalBranch(%140) - -block %140: - [primalInstDecoration] - let %141 : Bool = cmpNE(%138, 1 : Int) - ifElse(%141, %142, %143, %144) - -block %143: - unconditionalBranch(%144, %x5Fbflag) - -block %142: - unconditionalBranch(%144, false) - -block %144( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%145) - -block %145: - ifElse(%x5Fbflag1, %146, %147, %148) - -block %147: - unconditionalBranch(%148, %t1, %i1) - -block %146: - [primalInstDecoration] - let %149 : Int = add(%i1, 1 : Int) - unconditionalBranch(%148, %139, %149) - -block %148( - [primalInstDecoration] - [nameHint("t")] - param %t2 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i2 : Int): - [primalInstDecoration] - let %150 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) -} -[fwdDerivative(%151)] -[primalInstDecoration] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop1 : Func(Float, Float) -{ -block %152( - [nameHint("y")] - param %y1 : Float): - [loopMaxIters(4 : Int)] - loop(%153, %154, %153, true, %y1, 0 : Int) - -block %153( - [nameHint("_bflag")] - param %x5Fbflag2 : Bool, - [nameHint("t")] - param %t3 : Float, - [nameHint("i")] - param %i3 : Int): - ifElse(%x5Fbflag2, %155, %156, %155) - -block %156: - unconditionalBranch(%154) - -block %154: - return_val(%t3) - -block %155: - unconditionalBranch(%157) - -block %157: - let %158 : Bool = cmpLT(%i3, 3 : Int) - ifElse(%158, %159, %160, %161) - -block %160: - unconditionalBranch(%161, 0 : Int, 0 : Float) - -block %159: - let %162 : Float = mul(%t3, %t3) - unconditionalBranch(%161, 1 : Int, %162) - -block %161( - param %163 : Int, - param %164 : Float): - unconditionalBranch(%165) - -block %165: - let %166 : Bool = cmpNE(%163, 1 : Int) - ifElse(%166, %167, %168, %169) - -block %168: - unconditionalBranch(%169, %x5Fbflag2) - -block %167: - unconditionalBranch(%169, false) - -block %169( - [nameHint("_bflag")] - param %x5Fbflag3 : Bool): - unconditionalBranch(%170) - -block %170: - ifElse(%x5Fbflag3, %171, %172, %173) - -block %172: - unconditionalBranch(%173, %t3, %i3) - -block %171: - let %174 : Int = add(%i3, 1 : Int) - unconditionalBranch(%173, %164, %174) - -block %173( - [nameHint("t")] - param %t4 : Float, - [nameHint("i")] - param %i4 : Int): - unconditionalBranch(%153, %x5Fbflag3, %t4, %i4) -} -[derivativeMemberDecoration(%175)] -let %119 : _ = key -let %124 : _ = key -struct %176 : Type -{ - field(%175, Array(Float, 5 : Int)) -} - -func %177 : Func(%176) -{ -block %178: - let %179 : Array(Float, 5 : Int) = call %180() - let %181 : %176 = makeStruct(%179) - return_val(%181) -} -func %182 : Func(%176) -{ -block %183( - param %184 : %176, - param %185 : %176): - let %186 : Array(Float, 5 : Int) = get_field(%184, %175) - let %187 : Array(Float, 5 : Int) = get_field(%185, %175) - let %188 : Array(Float, 5 : Int) = call %189(%186, %187) - let %190 : %176 = makeStruct(%188) - return_val(%190) -} -witness_table %191 : witness_table_t(%IDifferentiable)(%176) -{ - witness_table_entry(%18,%176) - - witness_table_entry(%20,%191) - - witness_table_entry(%22,%177) - - witness_table_entry(%24,%182) - -} - -witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ - witness_table_entry(%18,%176) - - witness_table_entry(%20,%191) - - witness_table_entry(%22,%177) - - witness_table_entry(%24,%182) - -} - -[derivativeMemberDecoration(%175)] -let %175 : _ = key -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - [IntermediateContextFieldDifferentialTypeDecoration(%193)] - field(%119, Array(Float, 5 : Int)) - [loopCounterDecoration] - field(%124, Int) -} - -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ -block %194( - [nameHint("dpy")] - param %dpy1 : InOut(DiffPairUserCode(Float, %75)), - [nameHint("_s_dOut")] - param %x5Fsx5FdOut : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - unconditionalBranch(%195) - -block %195: - let %196 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %197 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %198 : Ptr(Array(Float, 5 : Int)) = var - store(%198, %197) - store(%198, %196) - let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %200 : Ptr(Int) = var - store(%200, %199) - store(%200, 0 : Int) - let %201 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %202 : Float = GetPrimalUserCode(%201) - unconditionalBranch(%203) - -block %203: - [loopMaxIters(4 : Int)] - loop(%204, %205, %204, true, %202, 0 : Int, 0 : Int) - -block %204( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag4 : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t5 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i5 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc1 : Int): - let %206 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %207 : Ptr(Array(Float, 5 : Int)) = var - store(%207, %206) - let %208 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%207, %x5Fpc1) - store(%208, %t5) - let %209 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %210 : Ptr(Int) = var - store(%210, %209) - store(%210, %x5Fpc1) - ifElse(%x5Fbflag4, %211, %212, %211) - -block %212: - unconditionalBranch(%205) - -block %205: - unconditionalBranch(%213) - -block %213: - unconditionalBranch(%214) - -block %214: - unconditionalBranch(%215) - -block %215: - unconditionalBranch(%216) - -block %216: - unconditionalBranch(%217) - -block %217: - let %218 : Float = call %floatx5Fdzero() - let %219 : Ptr(Float) = var - store(%219, %218) - let %220 : Float = call %floatx5Fdzero() - let %221 : Ptr(Float) = var - store(%221, %220) - let %222 : Float = load(%219) - let %223 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %222) - store(%219, %223) - unconditionalBranch(%224) - -block %224: - let %225 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %226 : Int = sub(%225, 1 : Int) - [loopMaxIters(4 : Int)] - loop(%227, %228, %229, %226) - -block %227( - [primalInstDecoration] - [nameHint("_dc")] - param %x5Fdc : Int): - let %230 : Int = add(%x5Fdc, 0 : Int) - let %231 : Float = load(%219) - let %232 : Float = call %floatx5Fdzero() - store(%219, %232) - let %233 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%233, %234, %235, %234) - -block %235: - unconditionalBranch(%228, %231) - -block %228( - param %236 : Float): - let %237 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %238 : Float = GetPrimalUserCode(%237) - let %239 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%238, %236) - store(%dpy1, %239) - return_val(void_constant) - -block %234: - unconditionalBranch(%240) - -block %240: - [primalInstDecoration] - let %241 : Bool = cmpLT(%230, 3 : Int) - ifElse(%241, %242, %243, %244) - -block %243: - unconditionalBranch(%244, 0 : Int) - -block %242: - unconditionalBranch(%244, 1 : Int) - -block %244( - [primalInstDecoration] - param %245 : Int): - unconditionalBranch(%246) - -block %246: - [primalInstDecoration] - let %247 : Bool = cmpNE(%245, 1 : Int) - ifElse(%247, %248, %249, %250) - -block %249: - unconditionalBranch(%250, true) - -block %248: - unconditionalBranch(%250, false) - -block %250( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag5 : Bool): - unconditionalBranch(%251) - -block %251: - ifElse(%x5Fbflag5, %252, %253, %254) - -block %253: - unconditionalBranch(%254) - -block %252: - unconditionalBranch(%254) - -block %254: - unconditionalBranch(%255) - -block %255: - unconditionalBranch(%256, %231) - -block %256( - param %257 : Float): - ifElse(%x5Fbflag5, %258, %259, %260) - -block %259: - unconditionalBranch(%261, %257) - -block %261( - param %262 : Float): - let %263 : Float = load(%219) - let %264 : Float = call %floatx5Fdadd(%262, %263) - store(%219, %264) - unconditionalBranch(%260) - -block %258: - unconditionalBranch(%265, %257) - -block %265( - param %266 : Float): - let %267 : Float = load(%221) - let %268 : Float = call %floatx5Fdadd(%266, %267) - store(%221, %268) - unconditionalBranch(%260) - -block %260: - unconditionalBranch(%269) - -block %269: - ifElse(%247, %270, %271, %272) - -block %271: - unconditionalBranch(%272) - -block %270: - unconditionalBranch(%272) - -block %272: - unconditionalBranch(%273) - -block %273: - let %274 : Float = load(%221) - let %275 : Float = call %floatx5Fdzero() - store(%221, %275) - ifElse(%241, %276, %277, %278) - -block %277: - unconditionalBranch(%279) - -block %279: - unconditionalBranch(%278) - -block %276: - unconditionalBranch(%280, %274) - -block %280( - param %281 : Float): - let %282 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %283 : Ptr(Array(Float, 5 : Int)) = var - store(%283, %282) - let %284 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%283, %x5Fdc) - let %285 : Float = load(%284) - let %286 : Float = mul(%285, %281) - let %287 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %288 : Ptr(Array(Float, 5 : Int)) = var - store(%288, %287) - let %289 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%288, %x5Fdc) - let %290 : Float = load(%289) - let %291 : Float = mul(%290, %281) - let %292 : Float = load(%219) - let %293 : Float = call %floatx5Fdadd(%286, %291) - let %294 : Float = call %floatx5Fdadd(%293, %292) - store(%219, %294) - unconditionalBranch(%278) - -block %278: - unconditionalBranch(%229) - -block %229: - [primalInstDecoration] - let %295 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%227, %295) - -block %211: - unconditionalBranch(%296) - -block %296: - [primalInstDecoration] - let %297 : Bool = cmpLT(%i5, 3 : Int) - ifElse(%297, %298, %299, %300) - -block %299: - unconditionalBranch(%300, 0 : Int, 0 : Float) - -block %298: - [primalInstDecoration] - let %301 : Float = mul(%t5, %t5) - unconditionalBranch(%300, 1 : Int, %301) - -block %300( - [primalInstDecoration] - param %302 : Int, - [primalInstDecoration] - param %303 : Float): - unconditionalBranch(%304) - -block %304: - [primalInstDecoration] - let %305 : Bool = cmpNE(%302, 1 : Int) - ifElse(%305, %306, %307, %308) - -block %307: - unconditionalBranch(%308, %x5Fbflag4) - -block %306: - unconditionalBranch(%308, false) - -block %308( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag6 : Bool): - unconditionalBranch(%309) - -block %309: - ifElse(%x5Fbflag6, %310, %311, %312) - -block %311: - unconditionalBranch(%312, %t5, %i5) - -block %310: - [primalInstDecoration] - let %313 : Int = add(%i5, 1 : Int) - unconditionalBranch(%312, %303, %313) - -block %312( - [primalInstDecoration] - [nameHint("t")] - param %t6 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i6 : Int): - [primalInstDecoration] - let %314 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%204, %x5Fbflag6, %t6, %i6, %314) -} -[backwardDifferentiable] -func %189 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) -{ -block %315( - param %316 : Array(Float, 5 : Int), - param %317 : Array(Float, 5 : Int)): - let %318 : Ptr(Array(Float, 5 : Int)) = var - loop(%319, %320, %319, 0 : Int) - -block %319( - param %321 : Int): - let %322 : Bool = cmpLT(%321, 5 : Int) - ifElse(%322, %323, %324, %324) - -block %323: - let %325 : Float = getElement(%316, %321) - let %326 : Float = getElement(%317, %321) - let %327 : Float = call %floatx5Fdadd(%325, %326) - let %328 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%318, %321) - store(%328, %327) - unconditionalBranch(%329) - -block %324: - unconditionalBranch(%320) - -block %320: - let %330 : Array(Float, 5 : Int) = load(%318) - return_val(%330) - -block %329: - let %331 : Int = add(%321, 1 : Int) - unconditionalBranch(%319, %331) -} -func %180 : Func(Array(Float, 5 : Int)) -{ -block %332: - let %333 : Float = call %floatx5Fdzero() - let %334 : Array(Float, 5 : Int) = makeArrayFromElement(%333) - return_val(%334) -} -witness_table %193 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) -{ - witness_table_entry(%18,Array(Float, 5 : Int)) - - witness_table_entry(%20,%193) - - witness_table_entry(%24,%189) - - witness_table_entry(%22,%180) - -} - -### -### BEFORE-SPECIALIZE: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] -[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] -[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] -[primalInstDecoration] -[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %78: - return_val(%t) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %88 : DiffPairUserCode(Float, %75) = load(%dpa) - let %89 : Float = GetDifferentialUserCode(%88) - store(%87, %89) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %90) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %93 : Float = GetDifferentialUserCode(%92) - store(%91, %93) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %94: - let %95 : %NullDifferential = makeStruct(0 : UInt) - return_val(%95) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %96( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -generic %98 : Generic -{ -block %99( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %101 : %98 -{ -block %102( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %104( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %105 : %NullDifferential = makeStruct(0 : UInt) - return_val(%105) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%106) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%101) - -} - -GenericSpecializationDictionary -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_test_simple_loop")] -func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) -{ -block %107( - param %108 : InOut(DiffPairUserCode(Float, %75)), - param %109 : Float): - let %110 : DiffPairUserCode(Float, %75) = load(%108) - let %111 : Float = GetPrimalUserCode(%110) - let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) - let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) - return_val(void_constant) -} -[nameHint("s_primal_ctx_test_simple_loop")] -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) -{ -block %115( - [nameHint("dpy")] - param %dpy : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - unconditionalBranch(%116) - -block %116: - let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct - store(%x5Fsx5Fdiffx5Fctx, %117) - let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) - let %120 : Ptr(Array(Float, 5 : Int)) = var - let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%120, %121) - let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%118, %122) - let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) - [loopCounterDecoration] - let %125 : Ptr(Int) = var - store(%125, 0 : Int) - store(%123, 0 : Int) - unconditionalBranch(%126) - -block %126: - [loopMaxIters(4 : Int)] - loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) - -block %127( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t1 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i1 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc : Int): - let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) - store(%129, %t1) - store(%123, %x5Fpc) - ifElse(%x5Fbflag, %130, %131, %130) - -block %131: - unconditionalBranch(%128) - -block %128: - return_val(%t1) - -block %130: - unconditionalBranch(%132) - -block %132: - [primalInstDecoration] - let %133 : Bool = cmpLT(%i1, 3 : Int) - ifElse(%133, %134, %135, %136) - -block %135: - unconditionalBranch(%136, 0 : Int, 0 : Float) - -block %134: - [primalInstDecoration] - let %137 : Float = mul(%t1, %t1) - unconditionalBranch(%136, 1 : Int, %137) - -block %136( - [primalInstDecoration] - param %138 : Int, - [primalInstDecoration] - param %139 : Float): - unconditionalBranch(%140) - -block %140: - [primalInstDecoration] - let %141 : Bool = cmpNE(%138, 1 : Int) - ifElse(%141, %142, %143, %144) - -block %143: - unconditionalBranch(%144, %x5Fbflag) - -block %142: - unconditionalBranch(%144, false) - -block %144( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%145) - -block %145: - ifElse(%x5Fbflag1, %146, %147, %148) - -block %147: - unconditionalBranch(%148, %t1, %i1) - -block %146: - [primalInstDecoration] - let %149 : Int = add(%i1, 1 : Int) - unconditionalBranch(%148, %139, %149) - -block %148( - [primalInstDecoration] - [nameHint("t")] - param %t2 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i2 : Int): - [primalInstDecoration] - let %150 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) -} -[fwdDerivative(%151)] -[primalInstDecoration] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop1 : Func(Float, Float) -{ -block %152( - [nameHint("y")] - param %y1 : Float): - [loopMaxIters(4 : Int)] - loop(%153, %154, %153, true, %y1, 0 : Int) - -block %153( - [nameHint("_bflag")] - param %x5Fbflag2 : Bool, - [nameHint("t")] - param %t3 : Float, - [nameHint("i")] - param %i3 : Int): - ifElse(%x5Fbflag2, %155, %156, %155) - -block %156: - unconditionalBranch(%154) - -block %154: - return_val(%t3) - -block %155: - unconditionalBranch(%157) - -block %157: - let %158 : Bool = cmpLT(%i3, 3 : Int) - ifElse(%158, %159, %160, %161) - -block %160: - unconditionalBranch(%161, 0 : Int, 0 : Float) - -block %159: - let %162 : Float = mul(%t3, %t3) - unconditionalBranch(%161, 1 : Int, %162) - -block %161( - param %163 : Int, - param %164 : Float): - unconditionalBranch(%165) - -block %165: - let %166 : Bool = cmpNE(%163, 1 : Int) - ifElse(%166, %167, %168, %169) - -block %168: - unconditionalBranch(%169, %x5Fbflag2) - -block %167: - unconditionalBranch(%169, false) - -block %169( - [nameHint("_bflag")] - param %x5Fbflag3 : Bool): - unconditionalBranch(%170) - -block %170: - ifElse(%x5Fbflag3, %171, %172, %173) - -block %172: - unconditionalBranch(%173, %t3, %i3) - -block %171: - let %174 : Int = add(%i3, 1 : Int) - unconditionalBranch(%173, %164, %174) - -block %173( - [nameHint("t")] - param %t4 : Float, - [nameHint("i")] - param %i4 : Int): - unconditionalBranch(%153, %x5Fbflag3, %t4, %i4) -} -[derivativeMemberDecoration(%175)] -let %119 : _ = key -let %124 : _ = key -struct %176 : Type -{ - field(%175, Array(Float, 5 : Int)) -} - -func %177 : Func(%176) -{ -block %178: - let %179 : Array(Float, 5 : Int) = call %180() - let %181 : %176 = makeStruct(%179) - return_val(%181) -} -func %182 : Func(%176) -{ -block %183( - param %184 : %176, - param %185 : %176): - let %186 : Array(Float, 5 : Int) = get_field(%184, %175) - let %187 : Array(Float, 5 : Int) = get_field(%185, %175) - let %188 : Array(Float, 5 : Int) = call %189(%186, %187) - let %190 : %176 = makeStruct(%188) - return_val(%190) -} -witness_table %191 : witness_table_t(%IDifferentiable)(%176) -{ - witness_table_entry(%18,%176) - - witness_table_entry(%20,%191) - - witness_table_entry(%22,%177) - - witness_table_entry(%24,%182) - -} - -witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ - witness_table_entry(%18,%176) - - witness_table_entry(%20,%191) - - witness_table_entry(%22,%177) - - witness_table_entry(%24,%182) - -} - -[derivativeMemberDecoration(%175)] -let %175 : _ = key -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - [IntermediateContextFieldDifferentialTypeDecoration(%193)] - field(%119, Array(Float, 5 : Int)) - [loopCounterDecoration] - field(%124, Int) -} - -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ -block %194( - [nameHint("dpy")] - param %dpy1 : InOut(DiffPairUserCode(Float, %75)), - [nameHint("_s_dOut")] - param %x5Fsx5FdOut : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - unconditionalBranch(%195) - -block %195: - let %196 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %197 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %198 : Ptr(Array(Float, 5 : Int)) = var - store(%198, %197) - store(%198, %196) - let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %200 : Ptr(Int) = var - store(%200, %199) - store(%200, 0 : Int) - let %201 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %202 : Float = GetPrimalUserCode(%201) - unconditionalBranch(%203) - -block %203: - [loopMaxIters(4 : Int)] - loop(%204, %205, %204, true, %202, 0 : Int, 0 : Int) - -block %204( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag4 : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t5 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i5 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc1 : Int): - let %206 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %207 : Ptr(Array(Float, 5 : Int)) = var - store(%207, %206) - let %208 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%207, %x5Fpc1) - store(%208, %t5) - let %209 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %210 : Ptr(Int) = var - store(%210, %209) - store(%210, %x5Fpc1) - ifElse(%x5Fbflag4, %211, %212, %211) - -block %212: - unconditionalBranch(%205) - -block %205: - unconditionalBranch(%213) - -block %213: - unconditionalBranch(%214) - -block %214: - unconditionalBranch(%215) - -block %215: - unconditionalBranch(%216) - -block %216: - unconditionalBranch(%217) - -block %217: - let %218 : Float = call %floatx5Fdzero() - let %219 : Ptr(Float) = var - store(%219, %218) - let %220 : Float = call %floatx5Fdzero() - let %221 : Ptr(Float) = var - store(%221, %220) - let %222 : Float = load(%219) - let %223 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %222) - store(%219, %223) - unconditionalBranch(%224) - -block %224: - let %225 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %226 : Int = sub(%225, 1 : Int) - [loopMaxIters(4 : Int)] - loop(%227, %228, %229, %226) - -block %227( - [primalInstDecoration] - [nameHint("_dc")] - param %x5Fdc : Int): - let %230 : Int = add(%x5Fdc, 0 : Int) - let %231 : Float = load(%219) - let %232 : Float = call %floatx5Fdzero() - store(%219, %232) - let %233 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%233, %234, %235, %234) - -block %235: - unconditionalBranch(%228, %231) - -block %228( - param %236 : Float): - let %237 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %238 : Float = GetPrimalUserCode(%237) - let %239 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%238, %236) - store(%dpy1, %239) - return_val(void_constant) - -block %234: - unconditionalBranch(%240) - -block %240: - [primalInstDecoration] - let %241 : Bool = cmpLT(%230, 3 : Int) - ifElse(%241, %242, %243, %244) - -block %243: - unconditionalBranch(%244, 0 : Int) - -block %242: - unconditionalBranch(%244, 1 : Int) - -block %244( - [primalInstDecoration] - param %245 : Int): - unconditionalBranch(%246) - -block %246: - [primalInstDecoration] - let %247 : Bool = cmpNE(%245, 1 : Int) - ifElse(%247, %248, %249, %250) - -block %249: - unconditionalBranch(%250, true) - -block %248: - unconditionalBranch(%250, false) - -block %250( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag5 : Bool): - unconditionalBranch(%251) - -block %251: - ifElse(%x5Fbflag5, %252, %253, %254) - -block %253: - unconditionalBranch(%254) - -block %252: - unconditionalBranch(%254) - -block %254: - unconditionalBranch(%255) - -block %255: - unconditionalBranch(%256, %231) - -block %256( - param %257 : Float): - ifElse(%x5Fbflag5, %258, %259, %260) - -block %259: - unconditionalBranch(%261, %257) - -block %261( - param %262 : Float): - let %263 : Float = load(%219) - let %264 : Float = call %floatx5Fdadd(%262, %263) - store(%219, %264) - unconditionalBranch(%260) - -block %258: - unconditionalBranch(%265, %257) - -block %265( - param %266 : Float): - let %267 : Float = load(%221) - let %268 : Float = call %floatx5Fdadd(%266, %267) - store(%221, %268) - unconditionalBranch(%260) - -block %260: - unconditionalBranch(%269) - -block %269: - ifElse(%247, %270, %271, %272) - -block %271: - unconditionalBranch(%272) - -block %270: - unconditionalBranch(%272) - -block %272: - unconditionalBranch(%273) - -block %273: - let %274 : Float = load(%221) - let %275 : Float = call %floatx5Fdzero() - store(%221, %275) - ifElse(%241, %276, %277, %278) - -block %277: - unconditionalBranch(%279) - -block %279: - unconditionalBranch(%278) - -block %276: - unconditionalBranch(%280, %274) - -block %280( - param %281 : Float): - let %282 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %283 : Ptr(Array(Float, 5 : Int)) = var - store(%283, %282) - let %284 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%283, %x5Fdc) - let %285 : Float = load(%284) - let %286 : Float = mul(%285, %281) - let %287 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %288 : Ptr(Array(Float, 5 : Int)) = var - store(%288, %287) - let %289 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%288, %x5Fdc) - let %290 : Float = load(%289) - let %291 : Float = mul(%290, %281) - let %292 : Float = load(%219) - let %293 : Float = call %floatx5Fdadd(%286, %291) - let %294 : Float = call %floatx5Fdadd(%293, %292) - store(%219, %294) - unconditionalBranch(%278) - -block %278: - unconditionalBranch(%229) - -block %229: - [primalInstDecoration] - let %295 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%227, %295) - -block %211: - unconditionalBranch(%296) - -block %296: - [primalInstDecoration] - let %297 : Bool = cmpLT(%i5, 3 : Int) - ifElse(%297, %298, %299, %300) - -block %299: - unconditionalBranch(%300, 0 : Int, 0 : Float) - -block %298: - [primalInstDecoration] - let %301 : Float = mul(%t5, %t5) - unconditionalBranch(%300, 1 : Int, %301) - -block %300( - [primalInstDecoration] - param %302 : Int, - [primalInstDecoration] - param %303 : Float): - unconditionalBranch(%304) - -block %304: - [primalInstDecoration] - let %305 : Bool = cmpNE(%302, 1 : Int) - ifElse(%305, %306, %307, %308) - -block %307: - unconditionalBranch(%308, %x5Fbflag4) - -block %306: - unconditionalBranch(%308, false) - -block %308( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag6 : Bool): - unconditionalBranch(%309) - -block %309: - ifElse(%x5Fbflag6, %310, %311, %312) - -block %311: - unconditionalBranch(%312, %t5, %i5) - -block %310: - [primalInstDecoration] - let %313 : Int = add(%i5, 1 : Int) - unconditionalBranch(%312, %303, %313) - -block %312( - [primalInstDecoration] - [nameHint("t")] - param %t6 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i6 : Int): - [primalInstDecoration] - let %314 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%204, %x5Fbflag6, %t6, %i6, %314) -} -[backwardDifferentiable] -func %189 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) -{ -block %315( - param %316 : Array(Float, 5 : Int), - param %317 : Array(Float, 5 : Int)): - let %318 : Ptr(Array(Float, 5 : Int)) = var - loop(%319, %320, %319, 0 : Int) - -block %319( - param %321 : Int): - let %322 : Bool = cmpLT(%321, 5 : Int) - ifElse(%322, %323, %324, %324) - -block %323: - let %325 : Float = getElement(%316, %321) - let %326 : Float = getElement(%317, %321) - let %327 : Float = call %floatx5Fdadd(%325, %326) - let %328 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%318, %321) - store(%328, %327) - unconditionalBranch(%329) - -block %324: - unconditionalBranch(%320) - -block %320: - let %330 : Array(Float, 5 : Int) = load(%318) - return_val(%330) - -block %329: - let %331 : Int = add(%321, 1 : Int) - unconditionalBranch(%319, %331) -} -func %180 : Func(Array(Float, 5 : Int)) -{ -block %332: - let %333 : Float = call %floatx5Fdzero() - let %334 : Array(Float, 5 : Int) = makeArrayFromElement(%333) - return_val(%334) -} -witness_table %193 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) -{ - witness_table_entry(%18,Array(Float, 5 : Int)) - - witness_table_entry(%20,%193) - - witness_table_entry(%24,%189) - - witness_table_entry(%22,%180) - -} - -### -### AFTER-SPECIALIZE: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] -[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] -[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] -[primalInstDecoration] -[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %78: - return_val(%t) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %88 : DiffPairUserCode(Float, %75) = load(%dpa) - let %89 : Float = GetDifferentialUserCode(%88) - store(%87, %89) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %90) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %93 : Float = GetDifferentialUserCode(%92) - store(%91, %93) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %94: - let %95 : %NullDifferential = makeStruct(0 : UInt) - return_val(%95) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %96( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -generic %98 : Generic -{ -block %99( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %101 : %98 -{ -block %102( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %104( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %105 : %NullDifferential = makeStruct(0 : UInt) - return_val(%105) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%106) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%101) - -} - -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_test_simple_loop")] -func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) -{ -block %107( - param %108 : InOut(DiffPairUserCode(Float, %75)), - param %109 : Float): - let %110 : DiffPairUserCode(Float, %75) = load(%108) - let %111 : Float = GetPrimalUserCode(%110) - let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) - let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) - return_val(void_constant) -} -[nameHint("s_primal_ctx_test_simple_loop")] -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) -{ -block %115( - [nameHint("dpy")] - param %dpy : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - unconditionalBranch(%116) - -block %116: - let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct - store(%x5Fsx5Fdiffx5Fctx, %117) - let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) - let %120 : Ptr(Array(Float, 5 : Int)) = var - let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%120, %121) - let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%118, %122) - let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) - [loopCounterDecoration] - let %125 : Ptr(Int) = var - store(%125, 0 : Int) - store(%123, 0 : Int) - unconditionalBranch(%126) - -block %126: - [loopMaxIters(4 : Int)] - loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) - -block %127( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t1 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i1 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc : Int): - let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) - store(%129, %t1) - store(%123, %x5Fpc) - ifElse(%x5Fbflag, %130, %131, %130) - -block %131: - unconditionalBranch(%128) - -block %128: - return_val(%t1) - -block %130: - unconditionalBranch(%132) - -block %132: - [primalInstDecoration] - let %133 : Bool = cmpLT(%i1, 3 : Int) - ifElse(%133, %134, %135, %136) - -block %135: - unconditionalBranch(%136, 0 : Int, 0 : Float) - -block %134: - [primalInstDecoration] - let %137 : Float = mul(%t1, %t1) - unconditionalBranch(%136, 1 : Int, %137) - -block %136( - [primalInstDecoration] - param %138 : Int, - [primalInstDecoration] - param %139 : Float): - unconditionalBranch(%140) - -block %140: - [primalInstDecoration] - let %141 : Bool = cmpNE(%138, 1 : Int) - ifElse(%141, %142, %143, %144) - -block %143: - unconditionalBranch(%144, %x5Fbflag) - -block %142: - unconditionalBranch(%144, false) - -block %144( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%145) - -block %145: - ifElse(%x5Fbflag1, %146, %147, %148) - -block %147: - unconditionalBranch(%148, %t1, %i1) - -block %146: - [primalInstDecoration] - let %149 : Int = add(%i1, 1 : Int) - unconditionalBranch(%148, %139, %149) - -block %148( - [primalInstDecoration] - [nameHint("t")] - param %t2 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i2 : Int): - [primalInstDecoration] - let %150 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) -} -[fwdDerivative(%151)] -[primalInstDecoration] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop1 : Func(Float, Float) -{ -block %152( - [nameHint("y")] - param %y1 : Float): - [loopMaxIters(4 : Int)] - loop(%153, %154, %153, true, %y1, 0 : Int) - -block %153( - [nameHint("_bflag")] - param %x5Fbflag2 : Bool, - [nameHint("t")] - param %t3 : Float, - [nameHint("i")] - param %i3 : Int): - ifElse(%x5Fbflag2, %155, %156, %155) - -block %156: - unconditionalBranch(%154) - -block %154: - return_val(%t3) - -block %155: - unconditionalBranch(%157) - -block %157: - let %158 : Bool = cmpLT(%i3, 3 : Int) - ifElse(%158, %159, %160, %161) - -block %160: - unconditionalBranch(%161, 0 : Int, 0 : Float) - -block %159: - let %162 : Float = mul(%t3, %t3) - unconditionalBranch(%161, 1 : Int, %162) - -block %161( - param %163 : Int, - param %164 : Float): - unconditionalBranch(%165) - -block %165: - let %166 : Bool = cmpNE(%163, 1 : Int) - ifElse(%166, %167, %168, %169) - -block %168: - unconditionalBranch(%169, %x5Fbflag2) - -block %167: - unconditionalBranch(%169, false) - -block %169( - [nameHint("_bflag")] - param %x5Fbflag3 : Bool): - unconditionalBranch(%170) - -block %170: - ifElse(%x5Fbflag3, %171, %172, %173) - -block %172: - unconditionalBranch(%173, %t3, %i3) - -block %171: - let %174 : Int = add(%i3, 1 : Int) - unconditionalBranch(%173, %164, %174) - -block %173( - [nameHint("t")] - param %t4 : Float, - [nameHint("i")] - param %i4 : Int): - unconditionalBranch(%153, %x5Fbflag3, %t4, %i4) -} -[derivativeMemberDecoration(%175)] -let %119 : _ = key -let %124 : _ = key -struct %176 : Type -{ - field(%175, Array(Float, 5 : Int)) -} - -func %177 : Func(%176) -{ -block %178: - let %179 : Array(Float, 5 : Int) = call %180() - let %181 : %176 = makeStruct(%179) - return_val(%181) -} -func %182 : Func(%176) -{ -block %183( - param %184 : %176, - param %185 : %176): - let %186 : Array(Float, 5 : Int) = get_field(%184, %175) - let %187 : Array(Float, 5 : Int) = get_field(%185, %175) - let %188 : Array(Float, 5 : Int) = call %189(%186, %187) - let %190 : %176 = makeStruct(%188) - return_val(%190) -} -witness_table %191 : witness_table_t(%IDifferentiable)(%176) -{ - witness_table_entry(%18,%176) - - witness_table_entry(%20,%191) - - witness_table_entry(%22,%177) - - witness_table_entry(%24,%182) - -} - -witness_table %192 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ - witness_table_entry(%18,%176) - - witness_table_entry(%20,%191) - - witness_table_entry(%22,%177) - - witness_table_entry(%24,%182) - -} - -[derivativeMemberDecoration(%175)] -let %175 : _ = key -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - [IntermediateContextFieldDifferentialTypeDecoration(%193)] - field(%119, Array(Float, 5 : Int)) - [loopCounterDecoration] - field(%124, Int) -} - -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ -block %194( - [nameHint("dpy")] - param %dpy1 : InOut(DiffPairUserCode(Float, %75)), - [nameHint("_s_dOut")] - param %x5Fsx5FdOut : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - unconditionalBranch(%195) - -block %195: - let %196 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %197 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %198 : Ptr(Array(Float, 5 : Int)) = var - store(%198, %197) - store(%198, %196) - let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %200 : Ptr(Int) = var - store(%200, %199) - store(%200, 0 : Int) - let %201 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %202 : Float = GetPrimalUserCode(%201) - unconditionalBranch(%203) - -block %203: - [loopMaxIters(4 : Int)] - loop(%204, %205, %204, true, %202, 0 : Int, 0 : Int) - -block %204( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag4 : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t5 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i5 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc1 : Int): - let %206 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %207 : Ptr(Array(Float, 5 : Int)) = var - store(%207, %206) - let %208 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%207, %x5Fpc1) - store(%208, %t5) - let %209 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %210 : Ptr(Int) = var - store(%210, %209) - store(%210, %x5Fpc1) - ifElse(%x5Fbflag4, %211, %212, %211) - -block %212: - unconditionalBranch(%205) - -block %205: - unconditionalBranch(%213) - -block %213: - unconditionalBranch(%214) - -block %214: - unconditionalBranch(%215) - -block %215: - unconditionalBranch(%216) - -block %216: - unconditionalBranch(%217) - -block %217: - let %218 : Float = call %floatx5Fdzero() - let %219 : Ptr(Float) = var - store(%219, %218) - let %220 : Float = call %floatx5Fdzero() - let %221 : Ptr(Float) = var - store(%221, %220) - let %222 : Float = load(%219) - let %223 : Float = call %floatx5Fdadd(%x5Fsx5FdOut, %222) - store(%219, %223) - unconditionalBranch(%224) - -block %224: - let %225 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %226 : Int = sub(%225, 1 : Int) - [loopMaxIters(4 : Int)] - loop(%227, %228, %229, %226) - -block %227( - [primalInstDecoration] - [nameHint("_dc")] - param %x5Fdc : Int): - let %230 : Int = add(%x5Fdc, 0 : Int) - let %231 : Float = load(%219) - let %232 : Float = call %floatx5Fdzero() - store(%219, %232) - let %233 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%233, %234, %235, %234) - -block %235: - unconditionalBranch(%228, %231) - -block %228( - param %236 : Float): - let %237 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %238 : Float = GetPrimalUserCode(%237) - let %239 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%238, %236) - store(%dpy1, %239) - return_val(void_constant) - -block %234: - unconditionalBranch(%240) - -block %240: - [primalInstDecoration] - let %241 : Bool = cmpLT(%230, 3 : Int) - ifElse(%241, %242, %243, %244) - -block %243: - unconditionalBranch(%244, 0 : Int) - -block %242: - unconditionalBranch(%244, 1 : Int) - -block %244( - [primalInstDecoration] - param %245 : Int): - unconditionalBranch(%246) - -block %246: - [primalInstDecoration] - let %247 : Bool = cmpNE(%245, 1 : Int) - ifElse(%247, %248, %249, %250) - -block %249: - unconditionalBranch(%250, true) - -block %248: - unconditionalBranch(%250, false) - -block %250( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag5 : Bool): - unconditionalBranch(%251) - -block %251: - ifElse(%x5Fbflag5, %252, %253, %254) - -block %253: - unconditionalBranch(%254) - -block %252: - unconditionalBranch(%254) - -block %254: - unconditionalBranch(%255) - -block %255: - unconditionalBranch(%256, %231) - -block %256( - param %257 : Float): - ifElse(%x5Fbflag5, %258, %259, %260) - -block %259: - unconditionalBranch(%261, %257) - -block %261( - param %262 : Float): - let %263 : Float = load(%219) - let %264 : Float = call %floatx5Fdadd(%262, %263) - store(%219, %264) - unconditionalBranch(%260) - -block %258: - unconditionalBranch(%265, %257) - -block %265( - param %266 : Float): - let %267 : Float = load(%221) - let %268 : Float = call %floatx5Fdadd(%266, %267) - store(%221, %268) - unconditionalBranch(%260) - -block %260: - unconditionalBranch(%269) - -block %269: - ifElse(%247, %270, %271, %272) - -block %271: - unconditionalBranch(%272) - -block %270: - unconditionalBranch(%272) - -block %272: - unconditionalBranch(%273) - -block %273: - let %274 : Float = load(%221) - let %275 : Float = call %floatx5Fdzero() - store(%221, %275) - ifElse(%241, %276, %277, %278) - -block %277: - unconditionalBranch(%279) - -block %279: - unconditionalBranch(%278) - -block %276: - unconditionalBranch(%280, %274) - -block %280( - param %281 : Float): - let %282 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %283 : Ptr(Array(Float, 5 : Int)) = var - store(%283, %282) - let %284 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%283, %x5Fdc) - let %285 : Float = load(%284) - let %286 : Float = mul(%285, %281) - let %287 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %288 : Ptr(Array(Float, 5 : Int)) = var - store(%288, %287) - let %289 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%288, %x5Fdc) - let %290 : Float = load(%289) - let %291 : Float = mul(%290, %281) - let %292 : Float = load(%219) - let %293 : Float = call %floatx5Fdadd(%286, %291) - let %294 : Float = call %floatx5Fdadd(%293, %292) - store(%219, %294) - unconditionalBranch(%278) - -block %278: - unconditionalBranch(%229) - -block %229: - [primalInstDecoration] - let %295 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%227, %295) - -block %211: - unconditionalBranch(%296) - -block %296: - [primalInstDecoration] - let %297 : Bool = cmpLT(%i5, 3 : Int) - ifElse(%297, %298, %299, %300) - -block %299: - unconditionalBranch(%300, 0 : Int, 0 : Float) - -block %298: - [primalInstDecoration] - let %301 : Float = mul(%t5, %t5) - unconditionalBranch(%300, 1 : Int, %301) - -block %300( - [primalInstDecoration] - param %302 : Int, - [primalInstDecoration] - param %303 : Float): - unconditionalBranch(%304) - -block %304: - [primalInstDecoration] - let %305 : Bool = cmpNE(%302, 1 : Int) - ifElse(%305, %306, %307, %308) - -block %307: - unconditionalBranch(%308, %x5Fbflag4) - -block %306: - unconditionalBranch(%308, false) - -block %308( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag6 : Bool): - unconditionalBranch(%309) - -block %309: - ifElse(%x5Fbflag6, %310, %311, %312) - -block %311: - unconditionalBranch(%312, %t5, %i5) - -block %310: - [primalInstDecoration] - let %313 : Int = add(%i5, 1 : Int) - unconditionalBranch(%312, %303, %313) - -block %312( - [primalInstDecoration] - [nameHint("t")] - param %t6 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i6 : Int): - [primalInstDecoration] - let %314 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%204, %x5Fbflag6, %t6, %i6, %314) -} -[backwardDifferentiable] -func %189 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) -{ -block %315( - param %316 : Array(Float, 5 : Int), - param %317 : Array(Float, 5 : Int)): - let %318 : Ptr(Array(Float, 5 : Int)) = var - loop(%319, %320, %319, 0 : Int) - -block %319( - param %321 : Int): - let %322 : Bool = cmpLT(%321, 5 : Int) - ifElse(%322, %323, %324, %324) - -block %323: - let %325 : Float = getElement(%316, %321) - let %326 : Float = getElement(%317, %321) - let %327 : Float = call %floatx5Fdadd(%325, %326) - let %328 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%318, %321) - store(%328, %327) - unconditionalBranch(%329) - -block %324: - unconditionalBranch(%320) - -block %320: - let %330 : Array(Float, 5 : Int) = load(%318) - return_val(%330) - -block %329: - let %331 : Int = add(%321, 1 : Int) - unconditionalBranch(%319, %331) -} -func %180 : Func(Array(Float, 5 : Int)) -{ -block %332: - let %333 : Float = call %floatx5Fdzero() - let %334 : Array(Float, 5 : Int) = makeArrayFromElement(%333) - return_val(%334) -} -witness_table %193 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) -{ - witness_table_entry(%18,Array(Float, 5 : Int)) - - witness_table_entry(%20,%193) - - witness_table_entry(%24,%189) - - witness_table_entry(%22,%180) - -} - -GenericSpecializationDictionary -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -### -### BEFORE-AUTODIFF: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] -[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] -[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] -[primalInstDecoration] -[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %78: - return_val(%t) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %88 : DiffPairUserCode(Float, %75) = load(%dpa) - let %89 : Float = GetDifferentialUserCode(%88) - store(%87, %89) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %90) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %93 : Float = GetDifferentialUserCode(%92) - store(%91, %93) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %94: - let %95 : %NullDifferential = makeStruct(0 : UInt) - return_val(%95) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %96( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -generic %98 : Generic -{ -block %99( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %101 : %98 -{ -block %102( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %104( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %105 : %NullDifferential = makeStruct(0 : UInt) - return_val(%105) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%106) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%101) - -} - -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_test_simple_loop")] -func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) -{ -block %107( - param %108 : InOut(DiffPairUserCode(Float, %75)), - param %109 : Float): - let %110 : DiffPairUserCode(Float, %75) = load(%108) - let %111 : Float = GetPrimalUserCode(%110) - let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) - let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) - return_val(void_constant) -} -[nameHint("s_primal_ctx_test_simple_loop")] -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) -{ -block %115( - [nameHint("dpy")] - param %dpy : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - unconditionalBranch(%116) - -block %116: - let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct - store(%x5Fsx5Fdiffx5Fctx, %117) - let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) - let %120 : Ptr(Array(Float, 5 : Int)) = var - let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%120, %121) - let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%118, %122) - let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) - [loopCounterDecoration] - let %125 : Ptr(Int) = var - store(%125, 0 : Int) - store(%123, 0 : Int) - unconditionalBranch(%126) - -block %126: - [loopMaxIters(4 : Int)] - loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) - -block %127( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t1 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i1 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc : Int): - let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) - store(%129, %t1) - store(%123, %x5Fpc) - ifElse(%x5Fbflag, %130, %131, %130) - -block %131: - unconditionalBranch(%128) - -block %128: - return_val(%t1) - -block %130: - unconditionalBranch(%132) - -block %132: - [primalInstDecoration] - let %133 : Bool = cmpLT(%i1, 3 : Int) - ifElse(%133, %134, %135, %136) - -block %135: - unconditionalBranch(%136, 0 : Int, 0 : Float) - -block %134: - [primalInstDecoration] - let %137 : Float = mul(%t1, %t1) - unconditionalBranch(%136, 1 : Int, %137) - -block %136( - [primalInstDecoration] - param %138 : Int, - [primalInstDecoration] - param %139 : Float): - unconditionalBranch(%140) - -block %140: - [primalInstDecoration] - let %141 : Bool = cmpNE(%138, 1 : Int) - ifElse(%141, %142, %143, %144) - -block %143: - unconditionalBranch(%144, %x5Fbflag) - -block %142: - unconditionalBranch(%144, false) - -block %144( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%145) - -block %145: - ifElse(%x5Fbflag1, %146, %147, %148) - -block %147: - unconditionalBranch(%148, %t1, %i1) - -block %146: - [primalInstDecoration] - let %149 : Int = add(%i1, 1 : Int) - unconditionalBranch(%148, %139, %149) - -block %148( - [primalInstDecoration] - [nameHint("t")] - param %t2 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i2 : Int): - [primalInstDecoration] - let %150 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) -} -[derivativeMemberDecoration(%151)] -let %119 : _ = key -let %124 : _ = key -struct %152 : Type -{ - field(%151, Array(Float, 5 : Int)) -} - -func %153 : Func(%152) -{ -block %154: - let %155 : Array(Float, 5 : Int) = call %156() - let %157 : %152 = makeStruct(%155) - return_val(%157) -} -func %158 : Func(%152) -{ -block %159( - param %160 : %152, - param %161 : %152): - let %162 : Array(Float, 5 : Int) = get_field(%160, %151) - let %163 : Array(Float, 5 : Int) = get_field(%161, %151) - let %164 : Array(Float, 5 : Int) = call %165(%162, %163) - let %166 : %152 = makeStruct(%164) - return_val(%166) -} -witness_table %167 : witness_table_t(%IDifferentiable)(%152) -{ - witness_table_entry(%18,%152) - - witness_table_entry(%20,%167) - - witness_table_entry(%22,%153) - - witness_table_entry(%24,%158) - -} - -witness_table %168 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ - witness_table_entry(%18,%152) - - witness_table_entry(%20,%167) - - witness_table_entry(%22,%153) - - witness_table_entry(%24,%158) - -} - -[derivativeMemberDecoration(%151)] -let %151 : _ = key -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - [IntermediateContextFieldDifferentialTypeDecoration(%169)] - field(%119, Array(Float, 5 : Int)) - [loopCounterDecoration] - field(%124, Int) -} - -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ -block %170( - [nameHint("dpy")] - param %dpy1 : InOut(DiffPairUserCode(Float, %75)), - [nameHint("_s_dOut")] - param %x5Fsx5FdOut : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - unconditionalBranch(%171) - -block %171: - let %172 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %173 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %174 : Ptr(Array(Float, 5 : Int)) = var - store(%174, %173) - store(%174, %172) - let %175 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %176 : Ptr(Int) = var - store(%176, %175) - store(%176, 0 : Int) - let %177 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %178 : Float = GetPrimalUserCode(%177) - unconditionalBranch(%179) - -block %179: - [loopMaxIters(4 : Int)] - loop(%180, %181, %180, true, %178, 0 : Int, 0 : Int) - -block %180( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag2 : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t3 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i3 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc1 : Int): - let %182 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %183 : Ptr(Array(Float, 5 : Int)) = var - store(%183, %182) - let %184 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%183, %x5Fpc1) - store(%184, %t3) - let %185 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %186 : Ptr(Int) = var - store(%186, %185) - store(%186, %x5Fpc1) - ifElse(%x5Fbflag2, %187, %188, %187) - -block %188: - unconditionalBranch(%181) - -block %181: - unconditionalBranch(%189) - -block %189: - unconditionalBranch(%190) - -block %190: - unconditionalBranch(%191) - -block %191: - unconditionalBranch(%192) - -block %192: - unconditionalBranch(%193) - -block %193: - let %194 : Ptr(Float) = var - store(%194, 0 : Float) - let %195 : Ptr(Float) = var - store(%195, 0 : Float) - let %196 : Float = load(%194) - let %197 : Float = add(%x5Fsx5FdOut, %196) - store(%194, %197) - unconditionalBranch(%198) - -block %198: - let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %200 : Int = sub(%199, 1 : Int) - [loopMaxIters(4 : Int)] - loop(%201, %202, %203, %200) - -block %201( - [primalInstDecoration] - [nameHint("_dc")] - param %x5Fdc : Int): - let %204 : Int = add(%x5Fdc, 0 : Int) - let %205 : Float = load(%194) - store(%194, 0 : Float) - let %206 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%206, %207, %208, %207) - -block %208: - unconditionalBranch(%202, %205) - -block %202( - param %209 : Float): - let %210 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %211 : Float = GetPrimalUserCode(%210) - let %212 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%211, %209) - store(%dpy1, %212) - return_val(void_constant) - -block %207: - unconditionalBranch(%213) - -block %213: - [primalInstDecoration] - let %214 : Bool = cmpLT(%204, 3 : Int) - ifElse(%214, %215, %216, %217) - -block %216: - unconditionalBranch(%217, 0 : Int) - -block %215: - unconditionalBranch(%217, 1 : Int) - -block %217( - [primalInstDecoration] - param %218 : Int): - unconditionalBranch(%219) - -block %219: - [primalInstDecoration] - let %220 : Bool = cmpNE(%218, 1 : Int) - ifElse(%220, %221, %222, %223) - -block %222: - unconditionalBranch(%223, true) - -block %221: - unconditionalBranch(%223, false) - -block %223( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag3 : Bool): - unconditionalBranch(%224) - -block %224: - ifElse(%x5Fbflag3, %225, %226, %227) - -block %226: - unconditionalBranch(%227) - -block %225: - unconditionalBranch(%227) - -block %227: - unconditionalBranch(%228) - -block %228: - unconditionalBranch(%229, %205) - -block %229( - param %230 : Float): - ifElse(%x5Fbflag3, %231, %232, %233) - -block %232: - unconditionalBranch(%234, %230) - -block %234( - param %235 : Float): - let %236 : Float = load(%194) - let %237 : Float = add(%235, %236) - store(%194, %237) - unconditionalBranch(%233) - -block %231: - unconditionalBranch(%238, %230) - -block %238( - param %239 : Float): - let %240 : Float = load(%195) - let %241 : Float = add(%239, %240) - store(%195, %241) - unconditionalBranch(%233) - -block %233: - unconditionalBranch(%242) - -block %242: - ifElse(%220, %243, %244, %245) - -block %244: - unconditionalBranch(%245) - -block %243: - unconditionalBranch(%245) - -block %245: - unconditionalBranch(%246) - -block %246: - let %247 : Float = load(%195) - store(%195, 0 : Float) - ifElse(%214, %248, %249, %250) - -block %249: - unconditionalBranch(%251) - -block %251: - unconditionalBranch(%250) - -block %248: - unconditionalBranch(%252, %247) - -block %252( - param %253 : Float): - let %254 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %255 : Ptr(Array(Float, 5 : Int)) = var - store(%255, %254) - let %256 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%255, %x5Fdc) - let %257 : Float = load(%256) - let %258 : Float = mul(%257, %253) - let %259 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %260 : Ptr(Array(Float, 5 : Int)) = var - store(%260, %259) - let %261 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%260, %x5Fdc) - let %262 : Float = load(%261) - let %263 : Float = mul(%262, %253) - let %264 : Float = load(%194) - let %265 : Float = add(%258, %263) - let %266 : Float = add(%265, %264) - store(%194, %266) - unconditionalBranch(%250) - -block %250: - unconditionalBranch(%203) - -block %203: - [primalInstDecoration] - let %267 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%201, %267) - -block %187: - unconditionalBranch(%268) - -block %268: - [primalInstDecoration] - let %269 : Bool = cmpLT(%i3, 3 : Int) - ifElse(%269, %270, %271, %272) - -block %271: - unconditionalBranch(%272, 0 : Int, 0 : Float) - -block %270: - [primalInstDecoration] - let %273 : Float = mul(%t3, %t3) - unconditionalBranch(%272, 1 : Int, %273) - -block %272( - [primalInstDecoration] - param %274 : Int, - [primalInstDecoration] - param %275 : Float): - unconditionalBranch(%276) - -block %276: - [primalInstDecoration] - let %277 : Bool = cmpNE(%274, 1 : Int) - ifElse(%277, %278, %279, %280) - -block %279: - unconditionalBranch(%280, %x5Fbflag2) - -block %278: - unconditionalBranch(%280, false) - -block %280( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag4 : Bool): - unconditionalBranch(%281) - -block %281: - ifElse(%x5Fbflag4, %282, %283, %284) - -block %283: - unconditionalBranch(%284, %t3, %i3) - -block %282: - [primalInstDecoration] - let %285 : Int = add(%i3, 1 : Int) - unconditionalBranch(%284, %275, %285) - -block %284( - [primalInstDecoration] - [nameHint("t")] - param %t4 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i4 : Int): - [primalInstDecoration] - let %286 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%180, %x5Fbflag4, %t4, %i4, %286) -} -[backwardDifferentiable] -func %165 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) -{ -block %287( - param %288 : Array(Float, 5 : Int), - param %289 : Array(Float, 5 : Int)): - let %290 : Ptr(Array(Float, 5 : Int)) = var - loop(%291, %292, %291, 0 : Int) - -block %291( - param %293 : Int): - let %294 : Bool = cmpLT(%293, 5 : Int) - ifElse(%294, %295, %296, %296) - -block %295: - let %297 : Float = getElement(%288, %293) - let %298 : Float = getElement(%289, %293) - let %299 : Float = add(%297, %298) - let %300 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%290, %293) - store(%300, %299) - unconditionalBranch(%301) - -block %296: - unconditionalBranch(%292) - -block %292: - let %302 : Array(Float, 5 : Int) = load(%290) - return_val(%302) - -block %301: - let %303 : Int = add(%293, 1 : Int) - unconditionalBranch(%291, %303) -} -func %156 : Func(Array(Float, 5 : Int)) -{ -block %304: - let %305 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) - return_val(%305) -} -witness_table %169 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) -{ - witness_table_entry(%18,Array(Float, 5 : Int)) - - witness_table_entry(%20,%169) - - witness_table_entry(%24,%165) - - witness_table_entry(%22,%156) - -} - -GenericSpecializationDictionary -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -### -### AFTER-AUTODIFF: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Void = no_diff -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[export("_ST4core15IDifferentiable12Differential")] -let %18 : _ = key -let %19 : _ = interface_req_entry(%18, associated_type(%IDifferentiable)) -[export("_S4core15IDifferentiable12DifferentialI4core15IDifferentiable")] -let %20 : _ = key -let %21 : _ = interface_req_entry(%20, witness_table_t(%IDifferentiable)) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable5dzerop0p4core15IDifferentiable12Differential")] -let %22 : _ = key -let %23 : _ = interface_req_entry(%22, Func(associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4daddp2pi_4core15IDifferentiable12Differentiali_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %24 : _ = key -let %25 : _ = interface_req_entry(%24, Func(associated_type(%IDifferentiable), associated_type(%IDifferentiable), associated_type(%IDifferentiable))) -[StaticRequirementDecoration] -[export("_S4core15IDifferentiable4dmulg2TC4core15IDifferentiable1T4core17__BuiltinRealTypep2pi_4core15IDifferentiable1Ti_4core15IDifferentiable12Differential4core15IDifferentiable12Differential")] -let %26 : _ = key -[export("_S4core17__BuiltinRealTypeI4core29__BuiltinSignedArithmeticType")] -let %27 : _ = key -[export("_S4core29__BuiltinSignedArithmeticTypeI4core23__BuiltinArithmeticType")] -let %28 : _ = key -[export("_S4core23__BuiltinArithmeticTypeI4core13__BuiltinType")] -let %29 : _ = key -[BuiltinDecoration] -[export("_ST4core13__BuiltinType")] -[nameHint("__BuiltinType")] -let %x5Fx5FBuiltinType : Type = interface -let %30 : _ = interface_req_entry(%29, witness_table_t(%x5Fx5FBuiltinType)) -[export("_S4core23__BuiltinArithmeticTypeI4core11IArithmetic")] -let %31 : _ = key -[export("_S4core11IArithmeticI4core11IComparable")] -let %32 : _ = key -[export("_S4core11IComparable6equalsp1pi_4core11IComparable4Thisb")] -let %33 : _ = key -let %34 : _ = interface_req_entry(%33, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable8lessThanp1pi_4core11IComparable4Thisb")] -let %35 : _ = key -let %36 : _ = interface_req_entry(%35, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_S4core11IComparable16lessThanOrEqualsp1pi_4core11IComparable4Thisb")] -let %37 : _ = key -let %38 : _ = interface_req_entry(%37, Func(Bool, this_type(%IComparable), this_type(%IComparable))) -[export("_ST4core11IComparable")] -[nameHint("IComparable")] -let %IComparable : Type = interface(%34, %36, %38) -let %39 : _ = interface_req_entry(%32, witness_table_t(%IComparable)) -[export("_S4core11IArithmetic3addp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %40 : _ = key -let %41 : _ = interface_req_entry(%40, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3subp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %42 : _ = key -let %43 : _ = interface_req_entry(%42, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3mulp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %44 : _ = key -let %45 : _ = interface_req_entry(%44, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3divp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %46 : _ = key -let %47 : _ = interface_req_entry(%46, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3modp1pi_4core11IArithmetic4This4core11IArithmetic4This")] -let %48 : _ = key -let %49 : _ = interface_req_entry(%48, Func(this_type(%IArithmetic), this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmetic3negp0p4core11IArithmetic4This")] -let %50 : _ = key -let %51 : _ = interface_req_entry(%50, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_S4core11IArithmeticR8_24xinitp1pi_i")] -let %52 : _ = key -let %53 : _ = interface_req_entry(%52, Func(this_type(%IArithmetic), Int)) -[export("_S4core11IArithmeticR8_24xinitp1pi_4core11IArithmetic4This")] -let %54 : _ = key -let %55 : _ = interface_req_entry(%54, Func(this_type(%IArithmetic), this_type(%IArithmetic))) -[export("_ST4core11IArithmetic")] -[nameHint("IArithmetic")] -let %IArithmetic : Type = interface(%39, %41, %43, %45, %47, %49, %51, %53, %55) -let %56 : _ = interface_req_entry(%31, witness_table_t(%IArithmetic)) -[BuiltinDecoration] -[export("_ST4core23__BuiltinArithmeticType")] -[nameHint("__BuiltinArithmeticType")] -let %x5Fx5FBuiltinArithmeticType : Type = interface(%30, %56) -let %57 : _ = interface_req_entry(%28, witness_table_t(%x5Fx5FBuiltinArithmeticType)) -[BuiltinDecoration] -[export("_ST4core29__BuiltinSignedArithmeticType")] -[nameHint("__BuiltinSignedArithmeticType")] -let %x5Fx5FBuiltinSignedArithmeticType : Type = interface(%57) -let %58 : _ = interface_req_entry(%27, witness_table_t(%x5Fx5FBuiltinSignedArithmeticType)) -[BuiltinDecoration] -[export("_ST4core17__BuiltinRealType")] -[nameHint("__BuiltinRealType")] -let %x5Fx5FBuiltinRealType : Type = interface(%58) -generic %59 : Generic -{ -block %60( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("IDifferentiable.T")] - param %IDifferentiablex5FT : type_t, - param %61 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(associated_type(%IDifferentiable), %IDifferentiablex5FT, associated_type(%IDifferentiable))) -} -let %62 : _ = interface_req_entry(%26, %59) -[export("_ST4core15IDifferentiable")] -[nameHint("IDifferentiable")] -let %IDifferentiable : Type = interface(%19, %21, %23, %25, %62) -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float5dzerop0pfb")] -[nameHint("float.dzero")] -func %floatx5Fdzero : Func(Float) -{ -block %63: - return_val(0 : Float) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[unsafeForceInlineEarly] -[method] -[export("_S4core5float4daddp2pi_fi_ffb")] -[nameHint("float.dadd")] -func %floatx5Fdadd : Func(Float, Float, Float) -{ -block %64( - [nameHint("a")] - param %a : Float, - [nameHint("b")] - param %b : Float): - let %65 : Float = add(%a, %b) - return_val(%65) -} -generic %66 : Generic -{ -block %67( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU : type_t, - param %68 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(Float, Attributed(%floatx5FU, %7), Float)) -} -[export("_S4core5float4dmulg2TC4core5float1U4core17__BuiltinRealTypep2pi_4core5float1Ui_ffb")] -generic %69 : %66 -{ -block %70( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("float.U")] - param %floatx5FU1 : type_t, - param %71 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [backwardDifferentiable] - [unsafeForceInlineEarly] - [nameHint("float.dmul")] - func %floatx5Fdmul : Func(Float, Attributed(%floatx5FU1, %7), Float) - { -block %72( - [nameHint("a")] - param %a1 : Attributed(%floatx5FU1, %7), - [nameHint("b")] - param %b1 : Float): - let %73 : Float = floatCast(%a1) - let %74 : Float = mul(%73, %b1) - return_val(%74) -} - return_val(%floatx5Fdmul) -} -[export("_SWf4core15IDifferentiable")] -witness_table %75 : witness_table_t(%IDifferentiable)(Float) -{ - witness_table_entry(%18,Float) - - witness_table_entry(%20,%75) - - witness_table_entry(%22,%floatx5Fdzero) - - witness_table_entry(%24,%floatx5Fdadd) - - witness_table_entry(%26,%69) - -} - -[backwardDiffIntermediateTypeReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)] -[backwardDiffPropagateReference(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop)] -[backwardDiffPrimalReference(%sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop)] -[primalInstDecoration] -[backwardDiffReference(%sx5Fbwdx5Ftestx5Fsimplex5Floop)] -[readNone] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[export("_SR15reverse_2Dxloop16test_simple_loopp1pi_ffb")] -[nameHint("test_simple_loop")] -func %testx5Fsimplex5Floop : Func(Float, Float) -{ -block %76( - [nameHint("y")] - param %y : Float): - [loopMaxIters(3 : Int)] - loop(%77, %78, %79, %y, 0 : Int) - -block %77( - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int): - let %80 : Bool = cmpLT(%i, 3 : Int) - ifElse(%80, %81, %78, %81) - -block %78: - return_val(%t) - -block %81: - let %82 : Float = mul(%t, %t) - unconditionalBranch(%79) - -block %79: - let %83 : Int = add(%i, 1 : Int) - unconditionalBranch(%77, %82, %83) -} -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %84 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %84) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %85( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(DiffPairUserCode(Float, %75)) = var - let %86 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(1 : Float, 0 : Float) - store(%dpa, %86) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %87 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %88 : DiffPairUserCode(Float, %75) = load(%dpa) - let %89 : Float = GetDifferentialUserCode(%88) - store(%87, %89) - [nameHint("dpa")] - let %dpa1 : Ptr(DiffPairUserCode(Float, %75)) = var - let %90 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(0.4 : Float, 0 : Float) - store(%dpa1, %90) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %91 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %92 : DiffPairUserCode(Float, %75) = load(%dpa1) - let %93 : Float = GetDifferentialUserCode(%92) - store(%91, %93) - return_val(void_constant) -} -[export("_SV16NullDifferential5dummy")] -[nameHint("dummy")] -let %dummy : _ = key -[AutoDiffBuiltinDecoration] -[keepAlive] -[hlslExport] -[export("_ST16NullDifferential")] -[nameHint("NullDifferential")] -struct %NullDifferential : Type -{ - field(%dummy, UInt) -} - -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential5dzerop0p16NullDifferentialb")] -[nameHint("NullDifferential.dzero")] -func %NullDifferentialx5Fdzero : Func(%NullDifferential) -{ -block %94: - let %95 : %NullDifferential = makeStruct(0 : UInt) - return_val(%95) -} -[readNone] -[DifferentiableTypeDictionaryDecoration] -[ForceInline] -[backwardDifferentiable] -[method] -[export("_S16NullDifferential4daddp2pi_16NullDifferentiali_16NullDifferential16NullDifferentialb")] -[nameHint("NullDifferential.dadd")] -func %NullDifferentialx5Fdadd : Func(%NullDifferential, %NullDifferential, %NullDifferential) -{ -block %96( - [nameHint("SLANG_anonymous_8")] - param %SLANGx5Fanonymousx5F8_ : %NullDifferential, - [nameHint("SLANG_anonymous_9")] - param %SLANGx5Fanonymousx5F9_ : %NullDifferential): - let %97 : %NullDifferential = makeStruct(0 : UInt) - return_val(%97) -} -generic %98 : Generic -{ -block %99( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT : type_t, - param %100 : witness_table_t(%x5Fx5FBuiltinRealType)): - return_val(Func(%NullDifferential, Attributed(%NullDifferentialx5FT, %7), %NullDifferential)) -} -[export("_S16NullDifferential4dmulg2TC16NullDifferential1T4core17__BuiltinRealTypep2pi_16NullDifferential1Ti_16NullDifferential16NullDifferentialb")] -generic %101 : %98 -{ -block %102( - [TypeConstraintDecoration(%x5Fx5FBuiltinRealType)] - [nameHint("NullDifferential.T")] - param %NullDifferentialx5FT1 : type_t, - param %103 : witness_table_t(%x5Fx5FBuiltinRealType)): - [readNone] - [DifferentiableTypeDictionaryDecoration] - [ForceInline] - [backwardDifferentiable] - [nameHint("NullDifferential.dmul")] - func %NullDifferentialx5Fdmul : Func(%NullDifferential, Attributed(%NullDifferentialx5FT1, %7), %NullDifferential) - { -block %104( - [nameHint("SLANG_anonymous_10")] - param %SLANGx5Fanonymousx5F10_ : Attributed(%NullDifferentialx5FT1, %7), - [nameHint("SLANG_anonymous_11")] - param %SLANGx5Fanonymousx5F11_ : %NullDifferential): - let %105 : %NullDifferential = makeStruct(0 : UInt) - return_val(%105) -} - return_val(%NullDifferentialx5Fdmul) -} -[keepAlive] -[hlslExport] -[export("_SW16NullDifferential4core15IDifferentiable")] -witness_table %106 : witness_table_t(%IDifferentiable)(%NullDifferential) -{ - witness_table_entry(%18,%NullDifferential) - - witness_table_entry(%20,%106) - - witness_table_entry(%22,%NullDifferentialx5Fdzero) - - witness_table_entry(%24,%NullDifferentialx5Fdadd) - - witness_table_entry(%26,%101) - -} - -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_test_simple_loop")] -func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float) -{ -block %107( - param %108 : InOut(DiffPairUserCode(Float, %75)), - param %109 : Float): - let %110 : DiffPairUserCode(Float, %75) = load(%108) - let %111 : Float = GetPrimalUserCode(%110) - let %112 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %113 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%111, %112) - let %114 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%112) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%108, %109, %114) - return_val(void_constant) -} -[nameHint("s_primal_ctx_test_simple_loop")] -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) -{ -block %115( - [nameHint("dpy")] - param %dpy : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - unconditionalBranch(%116) - -block %116: - let %117 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = defaultConstruct - store(%x5Fsx5Fdiffx5Fctx, %117) - let %118 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %119) - let %120 : Ptr(Array(Float, 5 : Int)) = var - let %121 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%120, %121) - let %122 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%118, %122) - let %123 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %124) - [loopCounterDecoration] - let %125 : Ptr(Int) = var - store(%125, 0 : Int) - store(%123, 0 : Int) - unconditionalBranch(%126) - -block %126: - [loopMaxIters(4 : Int)] - loop(%127, %128, %127, true, %dpy, 0 : Int, 0 : Int) - -block %127( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t1 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i1 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc : Int): - let %129 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%118, %x5Fpc) - store(%129, %t1) - store(%123, %x5Fpc) - ifElse(%x5Fbflag, %130, %131, %130) - -block %131: - unconditionalBranch(%128) - -block %128: - return_val(%t1) - -block %130: - unconditionalBranch(%132) - -block %132: - [primalInstDecoration] - let %133 : Bool = cmpLT(%i1, 3 : Int) - ifElse(%133, %134, %135, %136) - -block %135: - unconditionalBranch(%136, 0 : Int, 0 : Float) - -block %134: - [primalInstDecoration] - let %137 : Float = mul(%t1, %t1) - unconditionalBranch(%136, 1 : Int, %137) - -block %136( - [primalInstDecoration] - param %138 : Int, - [primalInstDecoration] - param %139 : Float): - unconditionalBranch(%140) - -block %140: - [primalInstDecoration] - let %141 : Bool = cmpNE(%138, 1 : Int) - ifElse(%141, %142, %143, %144) - -block %143: - unconditionalBranch(%144, %x5Fbflag) - -block %142: - unconditionalBranch(%144, false) - -block %144( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%145) - -block %145: - ifElse(%x5Fbflag1, %146, %147, %148) - -block %147: - unconditionalBranch(%148, %t1, %i1) - -block %146: - [primalInstDecoration] - let %149 : Int = add(%i1, 1 : Int) - unconditionalBranch(%148, %139, %149) - -block %148( - [primalInstDecoration] - [nameHint("t")] - param %t2 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i2 : Int): - [primalInstDecoration] - let %150 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%127, %x5Fbflag1, %t2, %i2, %150) -} -[derivativeMemberDecoration(%151)] -let %119 : _ = key -let %124 : _ = key -struct %152 : Type -{ - field(%151, Array(Float, 5 : Int)) -} - -func %153 : Func(%152) -{ -block %154: - let %155 : Array(Float, 5 : Int) = call %156() - let %157 : %152 = makeStruct(%155) - return_val(%157) -} -func %158 : Func(%152) -{ -block %159( - param %160 : %152, - param %161 : %152): - let %162 : Array(Float, 5 : Int) = get_field(%160, %151) - let %163 : Array(Float, 5 : Int) = get_field(%161, %151) - let %164 : Array(Float, 5 : Int) = call %165(%162, %163) - let %166 : %152 = makeStruct(%164) - return_val(%166) -} -witness_table %167 : witness_table_t(%IDifferentiable)(%152) -{ - witness_table_entry(%18,%152) - - witness_table_entry(%20,%167) - - witness_table_entry(%22,%153) - - witness_table_entry(%24,%158) - -} - -witness_table %168 : witness_table_t(%IDifferentiable)(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ - witness_table_entry(%18,%152) - - witness_table_entry(%20,%167) - - witness_table_entry(%22,%153) - - witness_table_entry(%24,%158) - -} - -[derivativeMemberDecoration(%151)] -let %151 : _ = key -[CheckpointIntermediateDecoration(%testx5Fsimplex5Floop)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - [IntermediateContextFieldDifferentialTypeDecoration(%169)] - field(%119, Array(Float, 5 : Int)) - [loopCounterDecoration] - field(%124, Int) -} - -[FloatingPointModeOverride(1 : Int)] -[DifferentiableTypeDictionaryDecoration] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(DiffPairUserCode(Float, %75)), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ -block %170( - [nameHint("dpy")] - param %dpy1 : InOut(DiffPairUserCode(Float, %75)), - [nameHint("_s_dOut")] - param %x5Fsx5FdOut : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - unconditionalBranch(%171) - -block %171: - let %172 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %173 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %174 : Ptr(Array(Float, 5 : Int)) = var - store(%174, %173) - store(%174, %172) - let %175 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %176 : Ptr(Int) = var - store(%176, %175) - store(%176, 0 : Int) - let %177 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %178 : Float = GetPrimalUserCode(%177) - unconditionalBranch(%179) - -block %179: - [loopMaxIters(4 : Int)] - loop(%180, %181, %180, true, %178, 0 : Int, 0 : Int) - -block %180( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag2 : Bool, - [primalInstDecoration] - [nameHint("t")] - param %t3 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i3 : Int, - [primalInstDecoration] - [nameHint("_pc")] - [loopCounterDecoration] - param %x5Fpc1 : Int): - let %182 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %183 : Ptr(Array(Float, 5 : Int)) = var - store(%183, %182) - let %184 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%183, %x5Fpc1) - store(%184, %t3) - let %185 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %186 : Ptr(Int) = var - store(%186, %185) - store(%186, %x5Fpc1) - ifElse(%x5Fbflag2, %187, %188, %187) - -block %188: - unconditionalBranch(%181) - -block %181: - unconditionalBranch(%189) - -block %189: - unconditionalBranch(%190) - -block %190: - unconditionalBranch(%191) - -block %191: - unconditionalBranch(%192) - -block %192: - unconditionalBranch(%193) - -block %193: - let %194 : Ptr(Float) = var - store(%194, 0 : Float) - let %195 : Ptr(Float) = var - store(%195, 0 : Float) - let %196 : Float = load(%194) - let %197 : Float = add(%x5Fsx5FdOut, %196) - store(%194, %197) - unconditionalBranch(%198) - -block %198: - let %199 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %124) - let %200 : Int = sub(%199, 1 : Int) - [loopMaxIters(4 : Int)] - loop(%201, %202, %203, %200) - -block %201( - [primalInstDecoration] - [nameHint("_dc")] - param %x5Fdc : Int): - let %204 : Int = add(%x5Fdc, 0 : Int) - let %205 : Float = load(%194) - store(%194, 0 : Float) - let %206 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%206, %207, %208, %207) - -block %208: - unconditionalBranch(%202, %205) - -block %202( - param %209 : Float): - let %210 : DiffPairUserCode(Float, %75) = load(%dpy1) - let %211 : Float = GetPrimalUserCode(%210) - let %212 : DiffPairUserCode(Float, %75) = MakeDiffPairUserCode(%211, %209) - store(%dpy1, %212) - return_val(void_constant) - -block %207: - unconditionalBranch(%213) - -block %213: - [primalInstDecoration] - let %214 : Bool = cmpLT(%204, 3 : Int) - ifElse(%214, %215, %216, %217) - -block %216: - unconditionalBranch(%217, 0 : Int) - -block %215: - unconditionalBranch(%217, 1 : Int) - -block %217( - [primalInstDecoration] - param %218 : Int): - unconditionalBranch(%219) - -block %219: - [primalInstDecoration] - let %220 : Bool = cmpNE(%218, 1 : Int) - ifElse(%220, %221, %222, %223) - -block %222: - unconditionalBranch(%223, true) - -block %221: - unconditionalBranch(%223, false) - -block %223( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag3 : Bool): - unconditionalBranch(%224) - -block %224: - ifElse(%x5Fbflag3, %225, %226, %227) - -block %226: - unconditionalBranch(%227) - -block %225: - unconditionalBranch(%227) - -block %227: - unconditionalBranch(%228) - -block %228: - unconditionalBranch(%229, %205) - -block %229( - param %230 : Float): - ifElse(%x5Fbflag3, %231, %232, %233) - -block %232: - unconditionalBranch(%234, %230) - -block %234( - param %235 : Float): - let %236 : Float = load(%194) - let %237 : Float = add(%235, %236) - store(%194, %237) - unconditionalBranch(%233) - -block %231: - unconditionalBranch(%238, %230) - -block %238( - param %239 : Float): - let %240 : Float = load(%195) - let %241 : Float = add(%239, %240) - store(%195, %241) - unconditionalBranch(%233) - -block %233: - unconditionalBranch(%242) - -block %242: - ifElse(%220, %243, %244, %245) - -block %244: - unconditionalBranch(%245) - -block %243: - unconditionalBranch(%245) - -block %245: - unconditionalBranch(%246) - -block %246: - let %247 : Float = load(%195) - store(%195, 0 : Float) - ifElse(%214, %248, %249, %250) - -block %249: - unconditionalBranch(%251) - -block %251: - unconditionalBranch(%250) - -block %248: - unconditionalBranch(%252, %247) - -block %252( - param %253 : Float): - let %254 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %255 : Ptr(Array(Float, 5 : Int)) = var - store(%255, %254) - let %256 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%255, %x5Fdc) - let %257 : Float = load(%256) - let %258 : Float = mul(%257, %253) - let %259 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %119) - let %260 : Ptr(Array(Float, 5 : Int)) = var - store(%260, %259) - let %261 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%260, %x5Fdc) - let %262 : Float = load(%261) - let %263 : Float = mul(%262, %253) - let %264 : Float = load(%194) - let %265 : Float = add(%258, %263) - let %266 : Float = add(%265, %264) - store(%194, %266) - unconditionalBranch(%250) - -block %250: - unconditionalBranch(%203) - -block %203: - [primalInstDecoration] - let %267 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%201, %267) - -block %187: - unconditionalBranch(%268) - -block %268: - [primalInstDecoration] - let %269 : Bool = cmpLT(%i3, 3 : Int) - ifElse(%269, %270, %271, %272) - -block %271: - unconditionalBranch(%272, 0 : Int, 0 : Float) - -block %270: - [primalInstDecoration] - let %273 : Float = mul(%t3, %t3) - unconditionalBranch(%272, 1 : Int, %273) - -block %272( - [primalInstDecoration] - param %274 : Int, - [primalInstDecoration] - param %275 : Float): - unconditionalBranch(%276) - -block %276: - [primalInstDecoration] - let %277 : Bool = cmpNE(%274, 1 : Int) - ifElse(%277, %278, %279, %280) - -block %279: - unconditionalBranch(%280, %x5Fbflag2) - -block %278: - unconditionalBranch(%280, false) - -block %280( - [primalInstDecoration] - [nameHint("_bflag")] - param %x5Fbflag4 : Bool): - unconditionalBranch(%281) - -block %281: - ifElse(%x5Fbflag4, %282, %283, %284) - -block %283: - unconditionalBranch(%284, %t3, %i3) - -block %282: - [primalInstDecoration] - let %285 : Int = add(%i3, 1 : Int) - unconditionalBranch(%284, %275, %285) - -block %284( - [primalInstDecoration] - [nameHint("t")] - param %t4 : Float, - [primalInstDecoration] - [nameHint("i")] - param %i4 : Int): - [primalInstDecoration] - let %286 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%180, %x5Fbflag4, %t4, %i4, %286) -} -[backwardDifferentiable] -func %165 : Func(Array(Float, 5 : Int), Array(Float, 5 : Int), Array(Float, 5 : Int)) -{ -block %287( - param %288 : Array(Float, 5 : Int), - param %289 : Array(Float, 5 : Int)): - let %290 : Ptr(Array(Float, 5 : Int)) = var - loop(%291, %292, %291, 0 : Int) - -block %291( - param %293 : Int): - let %294 : Bool = cmpLT(%293, 5 : Int) - ifElse(%294, %295, %296, %296) - -block %295: - let %297 : Float = getElement(%288, %293) - let %298 : Float = getElement(%289, %293) - let %299 : Float = add(%297, %298) - let %300 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%290, %293) - store(%300, %299) - unconditionalBranch(%301) - -block %296: - unconditionalBranch(%292) - -block %292: - let %302 : Array(Float, 5 : Int) = load(%290) - return_val(%302) - -block %301: - let %303 : Int = add(%293, 1 : Int) - unconditionalBranch(%291, %303) -} -func %156 : Func(Array(Float, 5 : Int)) -{ -block %304: - let %305 : Array(Float, 5 : Int) = makeArrayFromElement(0 : Float) - return_val(%305) -} -witness_table %169 : witness_table_t(%IDifferentiable)(Array(Float, 5 : Int)) -{ - witness_table_entry(%18,Array(Float, 5 : Int)) - - witness_table_entry(%20,%169) - - witness_table_entry(%24,%165) - - witness_table_entry(%22,%156) - -} - -GenericSpecializationDictionary -ExistentialFuncSpecializationDictionary -ExistentialTypeSpecializationDictionary -### -### BEFORE-LOWER-GENERICS: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -[nameHint("DiffPair_float")] -struct %DiffPairx5Ffloat : Type -{ - field(%primal, Float) - field(%differential, Float) -} - -let %7 : Void = EntryPointLayout(%8, %9) -let %9 : Void = varLayout(%10) -let %8 : Void = varLayout(%11) -let %11 : Void = structTypeLayout(%12) -let %12 : Void = fieldLayout(%13, %14) -let %14 : Void = varLayout(%10, %15, %16) -let %16 : Void = stage(6 : Int) -let %15 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %10 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %13 : _ = key -[export("_ST4core17IBufferDataLayout")] -[nameHint("IBufferDataLayout")] -let %IBufferDataLayout : Type = interface -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %17 : witness_table_t(%IBufferDataLayout)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %17) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%7)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %18( - [layout(%14)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(%DiffPairx5Ffloat) = var - let %19 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) - store(%dpa, %19) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %20 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %21 : %DiffPairx5Ffloat = load(%dpa) - let %22 : Float = get_field(%21, %differential) - store(%20, %22) - [nameHint("dpa")] - let %dpa1 : Ptr(%DiffPairx5Ffloat) = var - let %23 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) - store(%dpa1, %23) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %24 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %25 : %DiffPairx5Ffloat = load(%dpa1) - let %26 : Float = get_field(%25, %differential) - store(%24, %26) - return_val(void_constant) -} -[readNone] -[FloatingPointModeOverride(1 : Int)] -[backwardDifferentiable] -[nameHint("s_bwd_test_simple_loop")] -func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) -{ -block %27( - param %28 : InOut(%DiffPairx5Ffloat), - param %29 : Float): - let %30 : %DiffPairx5Ffloat = load(%28) - let %31 : Float = get_field(%30, %primal) - let %32 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %33 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%31, %32) - let %34 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%32) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%28, %29, %34) - return_val(void_constant) -} -[readNone] -[nameHint("s_primal_ctx_test_simple_loop")] -[FloatingPointModeOverride(1 : Int)] -[backwardDifferentiable] -func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) -{ -block %35( - [nameHint("dpy")] - param %dpy : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - let %36 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %37 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%36, 0 : Int) - store(%x5Fsx5Fdiffx5Fctx, %37) - let %38 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %39) - let %40 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%38, %40) - let %41 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %42) - store(%41, 0 : Int) - [loopMaxIters(4 : Int)] - loop(%43, %44, %43, true, %dpy, 0 : Int, 0 : Int) - -block %43( - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int, - [nameHint("_pc")] - param %x5Fpc : Int): - let %45 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%38, %x5Fpc) - store(%45, %t) - store(%41, %x5Fpc) - ifElse(%x5Fbflag, %46, %47, %46) - -block %47: - unconditionalBranch(%44) - -block %44: - return_val(%t) - -block %46: - unconditionalBranch(%48) - -block %48: - let %49 : Bool = cmpLT(%i, 3 : Int) - ifElse(%49, %50, %51, %52) - -block %51: - unconditionalBranch(%52, 0 : Int, 0 : Float) - -block %50: - let %53 : Float = mul(%t, %t) - unconditionalBranch(%52, 1 : Int, %53) - -block %52( - param %54 : Int, - param %55 : Float): - unconditionalBranch(%56) - -block %56: - let %57 : Bool = cmpNE(%54, 1 : Int) - ifElse(%57, %58, %59, %60) - -block %59: - unconditionalBranch(%60, %x5Fbflag) - -block %58: - unconditionalBranch(%60, false) - -block %60( - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%61) - -block %61: - ifElse(%x5Fbflag1, %62, %63, %64) - -block %63: - unconditionalBranch(%64, %t, %i) - -block %62: - let %65 : Int = add(%i, 1 : Int) - unconditionalBranch(%64, %55, %65) - -block %64( - [nameHint("t")] - param %t1 : Float, - [nameHint("i")] - param %i1 : Int): - let %66 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%43, %x5Fbflag1, %t1, %i1, %66) -} -let %39 : _ = key -let %42 : _ = key -[SizeAndAlignment(0 : Int, 24 : Int64, 4 : Int)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - [Offset(0 : Int, 0 : Int)] - field(%39, Array(Float, 5 : Int)) - [Offset(0 : Int, 20 : Int)] - field(%42, Int) -} - -[readNone] -[FloatingPointModeOverride(1 : Int)] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ -block %67( - [nameHint("dpy")] - param %dpy1 : InOut(%DiffPairx5Ffloat), - [nameHint("_s_dOut")] - param %x5Fsx5FdOut : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - let %68 : %DiffPairx5Ffloat = load(%dpy1) - let %69 : Float = get_field(%68, %primal) - [loopMaxIters(4 : Int)] - loop(%70, %71, %70, true, %69, 0 : Int, 0 : Int) - -block %70( - [nameHint("_bflag")] - param %x5Fbflag2 : Bool, - [nameHint("t")] - param %t2 : Float, - [nameHint("i")] - param %i2 : Int, - [nameHint("_pc")] - param %x5Fpc1 : Int): - let %72 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) - let %73 : Ptr(Array(Float, 5 : Int)) = var - store(%73, %72) - let %74 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%73, %x5Fpc1) - store(%74, %t2) - ifElse(%x5Fbflag2, %75, %76, %75) - -block %76: - unconditionalBranch(%71) - -block %71: - unconditionalBranch(%77) - -block %77: - let %78 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %42) - let %79 : Int = sub(%78, 1 : Int) - [loopMaxIters(4 : Int)] - loop(%80, %81, %82, %79, %x5Fsx5FdOut) - -block %80( - [nameHint("_dc")] - param %x5Fdc : Int, - param %83 : Float): - let %84 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%84, %85, %86, %85) - -block %86: - unconditionalBranch(%81) - -block %81: - let %87 : %DiffPairx5Ffloat = load(%dpy1) - let %88 : Float = get_field(%87, %primal) - let %89 : %DiffPairx5Ffloat = makeStruct(%88, %83) - store(%dpy1, %89) - return_val(void_constant) - -block %85: - unconditionalBranch(%90) - -block %90: - let %91 : Bool = cmpLT(%x5Fdc, 3 : Int) - ifElse(%91, %92, %93, %94) - -block %93: - unconditionalBranch(%94, 0 : Int) - -block %92: - unconditionalBranch(%94, 1 : Int) - -block %94( - param %95 : Int): - unconditionalBranch(%96) - -block %96: - let %97 : Bool = cmpNE(%95, 1 : Int) - let %98 : Bool = not(%97) - ifElse(%98, %99, %100, %101) - -block %100: - unconditionalBranch(%101, 0 : Float, %83) - -block %99: - unconditionalBranch(%101, %83, 0 : Float) - -block %101( - param %102 : Float, - param %103 : Float): - unconditionalBranch(%104) - -block %104: - ifElse(%91, %105, %106, %107) - -block %106: - unconditionalBranch(%107, %103) - -block %105: - let %108 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) - let %109 : Float = getElement(%108, %x5Fdc) - let %110 : Float = mul(%109, %102) - let %111 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %39) - let %112 : Float = getElement(%111, %x5Fdc) - let %113 : Float = mul(%112, %102) - let %114 : Float = add(%110, %113) - let %115 : Float = add(%114, %103) - unconditionalBranch(%107, %115) - -block %107( - param %116 : Float): - unconditionalBranch(%82) - -block %82: - let %117 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%80, %117, %116) - -block %75: - unconditionalBranch(%118) - -block %118: - let %119 : Bool = cmpLT(%i2, 3 : Int) - ifElse(%119, %120, %121, %122) - -block %121: - unconditionalBranch(%122, 0 : Int, 0 : Float) - -block %120: - let %123 : Float = mul(%t2, %t2) - unconditionalBranch(%122, 1 : Int, %123) - -block %122( - param %124 : Int, - param %125 : Float): - unconditionalBranch(%126) - -block %126: - let %127 : Bool = cmpNE(%124, 1 : Int) - ifElse(%127, %128, %129, %130) - -block %129: - unconditionalBranch(%130, %x5Fbflag2) - -block %128: - unconditionalBranch(%130, false) - -block %130( - [nameHint("_bflag")] - param %x5Fbflag3 : Bool): - unconditionalBranch(%131) - -block %131: - ifElse(%x5Fbflag3, %132, %133, %134) - -block %133: - unconditionalBranch(%134, %t2, %i2) - -block %132: - let %135 : Int = add(%i2, 1 : Int) - unconditionalBranch(%134, %125, %135) - -block %134( - [nameHint("t")] - param %t3 : Float, - [nameHint("i")] - param %i3 : Int): - let %136 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%70, %x5Fbflag3, %t3, %i3, %136) -} -[nameHint("primal")] -let %primal : _ = key -[nameHint("differential")] -let %differential : _ = key -### -### AFTER-LOWER-GENERICS: -undefined -let %1 : Void = varLayout(%2, %3) -let %3 : Void = offset(9 : Int, 0 : Int) -let %2 : Void = structuredBufferTypeLayout(%4, %5) -let %5 : Void = size(9 : Int, 1 : Int) -let %4 : Void = typeLayout(%6) -let %6 : Void = size(8 : Int, 4 : Int) -let %7 : Vec(UInt, 2 : Int) = makeVector(0 : UInt, 0 : UInt) -[nameHint("DiffPair_float")] -struct %DiffPairx5Ffloat : Type -{ - field(%primal, Float) - field(%differential, Float) -} - -let %8 : Void = EntryPointLayout(%9, %10) -let %10 : Void = varLayout(%11) -let %9 : Void = varLayout(%12) -let %12 : Void = structTypeLayout(%13) -let %13 : Void = fieldLayout(%14, %15) -let %15 : Void = varLayout(%11, %16, %17) -let %17 : Void = stage(6 : Int) -let %16 : Void = systemValueSemantic("SV_DispatchThreadID", 0 : Int) -let %11 : Void = typeLayout -[keepAlive] -global_hashed_string_literals("HLSL supports only float and half type textures", "Unsupported \'Load\' of \'texture cube array\' for \'metal\' target", "Unsupported \'Load\' of \'texture\' for \'metal\' target", "Unsupported \'Store\' of \'texture cube array\' for \'metal\' target", "Unable to use float with Atomicadd", "Atomic must be applied to a scalar texture or non-texture", "__metalImageInterlocked only allows \'int\'/\'uint\' textures", "__metalImageInterlocked implementation only allows \'uint\' coordinates", "Atomic must be applied to scalar texture or non-texture", "Unable to use float with Atomicand", "Unable to use float with Atomicexchange", "Metal atomic texture operations only allow \'int\'/\'uint\' textures", "Unable to use float with Atomicmax", "Unable to use float with Atomicmin", "Unable to use float with Atomicor", "Unable to use float with Atomicxor", "GL_EXT_shader_atomic_int64", "float atomic texture operations are disallowed with Metal target\'s", "\'float\' atomic texture operations are disallowed with Metal target\'s", "GL_EXT_shader_subgroup_extended_types_float16") -let %14 : _ = key -[SequentialIDDecoration(0 : UInt)] -[export("_SW4core17DefaultDataLayout4core17IBufferDataLayout")] -witness_table %18 : witness_table_t(0 : Int)(DefaultLayout); - -[nameHint("outputBuffer")] -[export("_SVR15reverse_2Dxloop12outputBuffer")] -[layout(%1)] -let %outputBuffer : RWStructuredBuffer(Float, DefaultLayout, %7) = global_param -[keepAlive] -[entryPoint(6 : Int, "computeMain", "reverse-loop")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_SR15reverse_2Dxloop11computeMainp1pi_v3uV")] -[nameHint("computeMain")] -[layout(%8)] -func %computeMain : Func(Void, Vec(UInt, 3 : Int)) -{ -block %19( - [layout(%15)] - [nameHint("dispatchThreadID")] - [semantic("SV_DispatchThreadID", 0 : Int)] - param %dispatchThreadID : Vec(UInt, 3 : Int)): - [nameHint("dpa")] - let %dpa : Ptr(%DiffPairx5Ffloat) = var - let %20 : %DiffPairx5Ffloat = makeStruct(1 : Float, 0 : Float) - store(%dpa, %20) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa, 1 : Float) - let %21 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 0 : Int) - let %22 : %DiffPairx5Ffloat = load(%dpa) - let %23 : Float = get_field(%22, %differential) - store(%21, %23) - [nameHint("dpa")] - let %dpa1 : Ptr(%DiffPairx5Ffloat) = var - let %24 : %DiffPairx5Ffloat = makeStruct(0.4 : Float, 0 : Float) - store(%dpa1, %24) - call %sx5Fbwdx5Ftestx5Fsimplex5Floop(%dpa1, 1 : Float) - let %25 : Ptr(Float) = rwstructuredBufferGetElementPtr(%outputBuffer, 1 : Int) - let %26 : %DiffPairx5Ffloat = load(%dpa1) - let %27 : Float = get_field(%26, %differential) - store(%25, %27) - return_val(void_constant) -} -[readNone] -[FloatingPointModeOverride(1 : Int)] -[backwardDifferentiable] -[nameHint("s_bwd_test_simple_loop")] -func %sx5Fbwdx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float) -{ -block %28( - param %29 : InOut(%DiffPairx5Ffloat), - param %30 : Float): - let %31 : %DiffPairx5Ffloat = load(%29) - let %32 : Float = get_field(%31, %primal) - let %33 : Ptr(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) = var - let %34 : Float = call %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop(%32, %33) - let %35 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = load(%33) - call %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop(%29, %30, %35) - return_val(void_constant) -} -[readNone] -[nameHint("s_primal_ctx_test_simple_loop")] -[FloatingPointModeOverride(1 : Int)] -[backwardDifferentiable] -func %sx5Fprimalx5Fctxx5Ftestx5Fsimplex5Floop : Func(Float, Float, Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)) -{ -block %36( - [nameHint("dpy")] - param %dpy : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx : Out(%sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates)): - let %37 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - let %38 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates = makeStruct(%37, 0 : Int) - store(%x5Fsx5Fdiffx5Fctx, %38) - let %39 : Ptr(Array(Float, 5 : Int)) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %40) - let %41 : Array(Float, 5 : Int) = makeArray(0 : Float, 0 : Float, 0 : Float, 0 : Float, 0 : Float) - store(%39, %41) - let %42 : Ptr(Int) = get_field_addr(%x5Fsx5Fdiffx5Fctx, %43) - store(%42, 0 : Int) - [loopMaxIters(4 : Int)] - loop(%44, %45, %44, true, %dpy, 0 : Int, 0 : Int) - -block %44( - [nameHint("_bflag")] - param %x5Fbflag : Bool, - [nameHint("t")] - param %t : Float, - [nameHint("i")] - param %i : Int, - [nameHint("_pc")] - param %x5Fpc : Int): - let %46 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%39, %x5Fpc) - store(%46, %t) - store(%42, %x5Fpc) - ifElse(%x5Fbflag, %47, %48, %47) - -block %48: - unconditionalBranch(%45) - -block %45: - return_val(%t) - -block %47: - unconditionalBranch(%49) - -block %49: - let %50 : Bool = cmpLT(%i, 3 : Int) - ifElse(%50, %51, %52, %53) - -block %52: - unconditionalBranch(%53, 0 : Int, 0 : Float) - -block %51: - let %54 : Float = mul(%t, %t) - unconditionalBranch(%53, 1 : Int, %54) - -block %53( - param %55 : Int, - param %56 : Float): - unconditionalBranch(%57) - -block %57: - let %58 : Bool = cmpNE(%55, 1 : Int) - ifElse(%58, %59, %60, %61) - -block %60: - unconditionalBranch(%61, %x5Fbflag) - -block %59: - unconditionalBranch(%61, false) - -block %61( - [nameHint("_bflag")] - param %x5Fbflag1 : Bool): - unconditionalBranch(%62) - -block %62: - ifElse(%x5Fbflag1, %63, %64, %65) - -block %64: - unconditionalBranch(%65, %t, %i) - -block %63: - let %66 : Int = add(%i, 1 : Int) - unconditionalBranch(%65, %56, %66) - -block %65( - [nameHint("t")] - param %t1 : Float, - [nameHint("i")] - param %i1 : Int): - let %67 : Int = add(%x5Fpc, 1 : Int) - unconditionalBranch(%44, %x5Fbflag1, %t1, %i1, %67) -} -let %40 : _ = key -let %43 : _ = key -[SizeAndAlignment(0 : Int, 24 : Int64, 4 : Int)] -[nameHint("s_bwd_prop_test_simple_loop_Intermediates")] -struct %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates : Type -{ - [Offset(0 : Int, 0 : Int)] - field(%40, Array(Float, 5 : Int)) - [Offset(0 : Int, 20 : Int)] - field(%43, Int) -} - -[readNone] -[FloatingPointModeOverride(1 : Int)] -[backwardDifferentiable] -[nameHint("s_bwd_prop_test_simple_loop")] -func %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floop : Func(Void, InOut(%DiffPairx5Ffloat), Float, %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates) -{ -block %68( - [nameHint("dpy")] - param %dpy1 : InOut(%DiffPairx5Ffloat), - [nameHint("_s_dOut")] - param %x5Fsx5FdOut : Float, - [nameHint("_s_diff_ctx")] - param %x5Fsx5Fdiffx5Fctx1 : %sx5Fbwdx5Fpropx5Ftestx5Fsimplex5Floopx5FIntermediates): - let %69 : %DiffPairx5Ffloat = load(%dpy1) - let %70 : Float = get_field(%69, %primal) - [loopMaxIters(4 : Int)] - loop(%71, %72, %71, true, %70, 0 : Int, 0 : Int) - -block %71( - [nameHint("_bflag")] - param %x5Fbflag2 : Bool, - [nameHint("t")] - param %t2 : Float, - [nameHint("i")] - param %i2 : Int, - [nameHint("_pc")] - param %x5Fpc1 : Int): - let %73 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) - let %74 : Ptr(Array(Float, 5 : Int)) = var - store(%74, %73) - let %75 : Ptr(Float, 2147483647 : UInt64) = getElementPtr(%74, %x5Fpc1) - store(%75, %t2) - ifElse(%x5Fbflag2, %76, %77, %76) - -block %77: - unconditionalBranch(%72) - -block %72: - unconditionalBranch(%78) - -block %78: - let %79 : Int = get_field(%x5Fsx5Fdiffx5Fctx1, %43) - let %80 : Int = sub(%79, 1 : Int) - [loopMaxIters(4 : Int)] - loop(%81, %82, %83, %80, %x5Fsx5FdOut) - -block %81( - [nameHint("_dc")] - param %x5Fdc : Int, - param %84 : Float): - let %85 : Bool = cmpGE(%x5Fdc, 0 : Int) - ifElse(%85, %86, %87, %86) - -block %87: - unconditionalBranch(%82) - -block %82: - let %88 : %DiffPairx5Ffloat = load(%dpy1) - let %89 : Float = get_field(%88, %primal) - let %90 : %DiffPairx5Ffloat = makeStruct(%89, %84) - store(%dpy1, %90) - return_val(void_constant) - -block %86: - unconditionalBranch(%91) - -block %91: - let %92 : Bool = cmpLT(%x5Fdc, 3 : Int) - ifElse(%92, %93, %94, %95) - -block %94: - unconditionalBranch(%95, 0 : Int) - -block %93: - unconditionalBranch(%95, 1 : Int) - -block %95( - param %96 : Int): - unconditionalBranch(%97) - -block %97: - let %98 : Bool = cmpNE(%96, 1 : Int) - let %99 : Bool = not(%98) - ifElse(%99, %100, %101, %102) - -block %101: - unconditionalBranch(%102, 0 : Float, %84) - -block %100: - unconditionalBranch(%102, %84, 0 : Float) - -block %102( - param %103 : Float, - param %104 : Float): - unconditionalBranch(%105) - -block %105: - ifElse(%92, %106, %107, %108) - -block %107: - unconditionalBranch(%108, %104) - -block %106: - let %109 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) - let %110 : Float = getElement(%109, %x5Fdc) - let %111 : Float = mul(%110, %103) - let %112 : Array(Float, 5 : Int) = get_field(%x5Fsx5Fdiffx5Fctx1, %40) - let %113 : Float = getElement(%112, %x5Fdc) - let %114 : Float = mul(%113, %103) - let %115 : Float = add(%111, %114) - let %116 : Float = add(%115, %104) - unconditionalBranch(%108, %116) - -block %108( - param %117 : Float): - unconditionalBranch(%83) - -block %83: - let %118 : Int = sub(%x5Fdc, 1 : Int) - unconditionalBranch(%81, %118, %117) - -block %76: - unconditionalBranch(%119) - -block %119: - let %120 : Bool = cmpLT(%i2, 3 : Int) - ifElse(%120, %121, %122, %123) - -block %122: - unconditionalBranch(%123, 0 : Int, 0 : Float) - -block %121: - let %124 : Float = mul(%t2, %t2) - unconditionalBranch(%123, 1 : Int, %124) - -block %123( - param %125 : Int, - param %126 : Float): - unconditionalBranch(%127) - -block %127: - let %128 : Bool = cmpNE(%125, 1 : Int) - ifElse(%128, %129, %130, %131) - -block %130: - unconditionalBranch(%131, %x5Fbflag2) - -block %129: - unconditionalBranch(%131, false) - -block %131( - [nameHint("_bflag")] - param %x5Fbflag3 : Bool): - unconditionalBranch(%132) - -block %132: - ifElse(%x5Fbflag3, %133, %134, %135) - -block %134: - unconditionalBranch(%135, %t2, %i2) - -block %133: - let %136 : Int = add(%i2, 1 : Int) - unconditionalBranch(%135, %126, %136) - -block %135( - [nameHint("t")] - param %t3 : Float, - [nameHint("i")] - param %i3 : Int): - let %137 : Int = add(%x5Fpc1, 1 : Int) - unconditionalBranch(%71, %x5Fbflag3, %t3, %i3, %137) -} -[nameHint("primal")] -let %primal : _ = key -[nameHint("differential")] -let %differential : _ = key -### diff --git a/checkpoint-report.txt b/checkpoint-report.txt deleted file mode 100644 index fb9330546c..0000000000 --- a/checkpoint-report.txt +++ /dev/null @@ -1,10 +0,0 @@ -checkpointing context generated for function: test_simple_loop - defined at tests/autodiff/reverse-loop.slang:12 - size of context: 24 bytes - - 20 bytes used for variable defined at tests/autodiff/reverse-loop.slang:14 - float t = y; - ^ - 4 bytes used for loop counter created for loop at tests/autodiff/reverse-loop.slang:16 - for (int i = 0; i < 3; i++) - ^~~ diff --git a/include/slang.h b/include/slang.h index 777cd406b3..6f63384e57 100644 --- a/include/slang.h +++ b/include/slang.h @@ -851,6 +851,7 @@ extern "C" EmitIr, // bool ReportDownstreamTime, // bool ReportPerfBenchmark, // bool + ReportCheckpointIntermediates, // bool SkipSPIRVValidation, // bool SourceEmbedStyle, SourceEmbedName, diff --git a/out.glsl b/out.glsl deleted file mode 100644 index f236cc337d..0000000000 --- a/out.glsl +++ /dev/null @@ -1,146 +0,0 @@ -#version 450 -layout(row_major) uniform; -layout(row_major) buffer; -layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { - float _data[]; -} outputBuffer_0; -struct DiffPair_float_0 -{ - float primal_0; - float differential_0; -}; - -struct s_bwd_prop_test_simple_loop_Intermediates_0 -{ - float _S1[5]; - int _S2; -}; - -float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_0) -{ - float _S3[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; - _s_diff_ctx_0._S1 = _S3; - _s_diff_ctx_0._S2 = 0; - _s_diff_ctx_0._S1[0] = 0.0; - _s_diff_ctx_0._S1[1] = 0.0; - _s_diff_ctx_0._S1[2] = 0.0; - _s_diff_ctx_0._S1[3] = 0.0; - _s_diff_ctx_0._S1[4] = 0.0; - _s_diff_ctx_0._S2 = 0; - bool _bflag_0 = true; - float t_0 = dpy_0; - int i_0 = 0; - int _pc_0 = 0; - for(;;) - { - _s_diff_ctx_0._S1[_pc_0] = t_0; - _s_diff_ctx_0._S2 = _pc_0; - if(_bflag_0) - { - } - else - { - break; - } - float _S4; - int _S5; - if(i_0 < 3) - { - float _S6 = t_0 * t_0; - _S5 = 1; - _S4 = _S6; - } - else - { - _S5 = 0; - _S4 = 0.0; - } - if(_S5 != 1) - { - _bflag_0 = false; - } - if(_bflag_0) - { - int _S7 = i_0 + 1; - t_0 = _S4; - i_0 = _S7; - } - _pc_0 = _pc_0 + 1; - } - return t_0; -} - -void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0, s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_1) -{ - int _dc_0 = _s_diff_ctx_1._S2 - 1; - float _S8 = _s_dOut_0; - for(;;) - { - if(_dc_0 >= 0) - { - } - else - { - break; - } - bool _S9 = _dc_0 < 3; - int _S10; - if(_S9) - { - _S10 = 1; - } - else - { - _S10 = 0; - } - float _S11; - float _S12; - if(!(_S10 != 1)) - { - _S11 = _S8; - _S12 = 0.0; - } - else - { - _S11 = 0.0; - _S12 = _S8; - } - if(_S9) - { - _S8 = _s_diff_ctx_1._S1[_dc_0] * _S11 + _s_diff_ctx_1._S1[_dc_0] * _S11 + _S12; - } - else - { - _S8 = _S12; - } - _dc_0 = _dc_0 - 1; - } - dpy_1.primal_0 = dpy_1.primal_0; - dpy_1.differential_0 = _S8; - return; -} - -void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S13, float _S14) -{ - s_bwd_prop_test_simple_loop_Intermediates_0 _S15; - float _S16 = s_primal_ctx_test_simple_loop_0(_S13.primal_0, _S15); - s_bwd_prop_test_simple_loop_0(_S13, _S14, _S15); - return; -} - -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -void main() -{ - DiffPair_float_0 dpa_0; - dpa_0.primal_0 = 1.0; - dpa_0.differential_0 = 0.0; - s_bwd_test_simple_loop_0(dpa_0, 1.0); - outputBuffer_0._data[uint(0)] = dpa_0.differential_0; - DiffPair_float_0 dpa_1; - dpa_1.primal_0 = 0.40000000596046448; - dpa_1.differential_0 = 0.0; - s_bwd_test_simple_loop_0(dpa_1, 1.0); - outputBuffer_0._data[uint(1)] = dpa_1.differential_0; - return; -} - diff --git a/source/slang-record-replay/util/emum-to-string.h b/source/slang-record-replay/util/emum-to-string.h index 7226edc04c..8c140cf3d6 100644 --- a/source/slang-record-replay/util/emum-to-string.h +++ b/source/slang-record-replay/util/emum-to-string.h @@ -149,6 +149,7 @@ namespace SlangRecord CASE(EmitIr); CASE(ReportDownstreamTime); CASE(ReportPerfBenchmark); + CASE(ReportCheckpointIntermediates); CASE(SkipSPIRVValidation); CASE(SourceEmbedStyle); CASE(SourceEmbedName); diff --git a/source/slang/slang-compiler.cpp b/source/slang/slang-compiler.cpp index 541085b4ee..c89d94c807 100644 --- a/source/slang/slang-compiler.cpp +++ b/source/slang/slang-compiler.cpp @@ -2451,12 +2451,16 @@ namespace Slang return getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::DumpIr); } + bool CodeGenContext::shouldReportCheckpointIntermediates() + { + return getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::ReportCheckpointIntermediates); + } + bool CodeGenContext::shouldDumpIntermediates() { return getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::DumpIntermediates); } - bool CodeGenContext::shouldTrackLiveness() { return getTargetProgram()->getOptionSet().getBoolOption(CompilerOptionName::TrackLiveness); diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h index 62e4c5f4a8..1181686794 100755 --- a/source/slang/slang-compiler.h +++ b/source/slang/slang-compiler.h @@ -2716,6 +2716,7 @@ namespace Slang bool shouldValidateIR(); bool shouldDumpIR(); + bool shouldReportCheckpointIntermediates(); bool shouldTrackLiveness(); diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 6e761420cb..8c20b982a9 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -837,7 +837,8 @@ Result linkAndOptimizeIR( } // Report checkpointing information - reportCheckpointIntermediates(codeGenContext, sink, irModule); + if (codeGenContext->shouldReportCheckpointIntermediates()) + reportCheckpointIntermediates(codeGenContext, sink, irModule); if (requiredLoweringPassSet.autodiff) finalizeAutoDiffPass(targetProgram, irModule); diff --git a/source/slang/slang-options.cpp b/source/slang/slang-options.cpp index c02a009570..b9a12f971e 100644 --- a/source/slang/slang-options.cpp +++ b/source/slang/slang-options.cpp @@ -339,6 +339,7 @@ void initCommandOptions(CommandOptions& options) { OptionKind::InputFilesRemain, "--", nullptr, "Treat the rest of the command line as input files."}, { OptionKind::ReportDownstreamTime, "-report-downstream-time", nullptr, "Reports the time spent in the downstream compiler." }, { OptionKind::ReportPerfBenchmark, "-report-perf-benchmark", nullptr, "Reports compiler performance benchmark results." }, + { OptionKind::ReportCheckpointIntermediates, "-report-checkpoint-intermediates", nullptr, "Reports information about checkpoint contexts used for reverse-mode automatic differentiation." }, { OptionKind::SkipSPIRVValidation, "-skip-spirv-validation", nullptr, "Skips spirv validation." }, { OptionKind::SourceEmbedStyle, "-source-embed-style", "-source-embed-style ", "If source embedding is enabled, defines the style used. When enabled (with any style other than `none`), " @@ -1703,6 +1704,7 @@ SlangResult OptionsParser::_parse( case OptionKind::DumpReproOnError: case OptionKind::ReportDownstreamTime: case OptionKind::ReportPerfBenchmark: + case OptionKind::ReportCheckpointIntermediates: case OptionKind::SkipSPIRVValidation: case OptionKind::DisableSpecialization: case OptionKind::DisableDynamicDispatch: From e1ae8f4bc2b9d190741eb10fc56b2d3ec9790377 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 9 Sep 2024 15:48:00 -0700 Subject: [PATCH 09/32] Display types of checkpointed fields --- source/slang/slang-emit.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 8c20b982a9..4e1b4a4f0f 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -231,6 +231,14 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno return HumaneSourceLoc(); }; + SourceWriter typeWriter(sourceManager, LineDirectiveMode::None, nullptr); + + CLikeSourceEmitter::Desc description; + description.codeGenContext = codeGenContext; + description.sourceWriter = &typeWriter; + + GLSLSourceEmitter emitter(description); + StringBuilder builder; for (auto inst : irModule->getGlobalInsts()) { IRStructType *structType = as(inst); @@ -253,18 +261,25 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); builder << "\n"; - builder << "\tdefined at " << hloc.pathInfo.foundPath << ":" << hloc.line << "\n"; - builder << "\tsize of context: " << sizeInfo.size << " bytes\n"; + builder << " defined at " << hloc.pathInfo.foundPath << ":" << hloc.line << "\n"; + builder << " size of context: " << sizeInfo.size << " bytes\n"; builder << "\n"; for (auto field : structType->getFields()) { IRType *fieldType = field->getFieldType(); IRSizeAndAlignment sizeInfo; getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); + + emitter.emitType(fieldType); HumaneSourceLoc hloc = getHumanLoc(field->sourceLoc); - builder << "\t" << sizeInfo.size << " bytes used for "; + builder << " " << sizeInfo.size; + builder << " bytes used for field of type: "; + builder << typeWriter.getContent() << "\n"; + typeWriter.clearContent(); + + builder << " generated to checkpoint "; if (field->findDecoration()) builder << "loop counter created for loop at "; else From 1d96da741dce667f11a6319f37edbbac0434f70b Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 9 Sep 2024 15:59:52 -0700 Subject: [PATCH 10/32] Message in case there are no checkpointing contexts --- source/slang/slang-emit.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 4e1b4a4f0f..f639214587 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -240,13 +240,16 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno GLSLSourceEmitter emitter(description); StringBuilder builder; + int nonEmptyCount = 0; + for (auto inst : irModule->getGlobalInsts()) { IRStructType *structType = as(inst); if (!structType) continue; auto checkpointDecoration = structType->findDecoration(); - if (checkpointDecoration) { + bool nonEmpty = structType->getChildren().getFirst(); + if (checkpointDecoration && nonEmpty) { builder << "checkpointing context generated for function: "; auto func = checkpointDecoration->getSourceFunction(); @@ -288,10 +291,15 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); + + nonEmptyCount++; } } } + if (nonEmptyCount == 0) + builder << "no checkpointing contexts were generated\n"; + SourceWriter writer(sourceManager, LineDirectiveMode::None, nullptr); writer.emit(builder); From d7ebae6347c6575ac7f0670ee0877a74ea049429 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Tue, 10 Sep 2024 16:36:34 -0700 Subject: [PATCH 11/32] Catch source locations for function calls --- source/slang/slang-emit.cpp | 31 +++++++++++++------ source/slang/slang-ir-autodiff-fwd.cpp | 8 ++++- .../slang/slang-ir-autodiff-primal-hoist.cpp | 4 +-- source/slang/slang-ir-autodiff-rev.cpp | 13 ++++++++ .../slang-ir-autodiff-transcriber-base.cpp | 12 +++++++ source/slang/slang-ir-autodiff-unzip.h | 17 ++++++++++ source/slang/slang-ir.cpp | 2 ++ 7 files changed, 75 insertions(+), 12 deletions(-) diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index f639214587..20d446bd47 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -242,14 +242,24 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno StringBuilder builder; int nonEmptyCount = 0; - for (auto inst : irModule->getGlobalInsts()) { + for (auto inst : irModule->getGlobalInsts()) + { IRStructType *structType = as(inst); if (!structType) continue; auto checkpointDecoration = structType->findDecoration(); - bool nonEmpty = structType->getChildren().getFirst(); - if (checkpointDecoration && nonEmpty) { + if (checkpointDecoration) + { + IRSizeAndAlignment sizeInfo; + getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); + + // Reporting happens before empty structs are optimized out + // and we still want to keep the checkpointing decorations, + // so we end up needing to check for non-zero-ness + if (sizeInfo.size == 0) + continue; + builder << "checkpointing context generated for function: "; auto func = checkpointDecoration->getSourceFunction(); @@ -258,9 +268,6 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno else if (auto nameHint = func->findDecoration()) builder << nameHint->getName(); - IRSizeAndAlignment sizeInfo; - getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); - HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); builder << "\n"; @@ -268,10 +275,13 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno builder << " size of context: " << sizeInfo.size << " bytes\n"; builder << "\n"; - for (auto field : structType->getFields()) { + for (auto field : structType->getFields()) + { IRType *fieldType = field->getFieldType(); IRSizeAndAlignment sizeInfo; getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); + if (sizeInfo.size == 0) + continue; emitter.emitType(fieldType); @@ -286,11 +296,14 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno if (field->findDecoration()) builder << "loop counter created for loop at "; else - builder << "variable defined at "; + builder << "the following item defined at "; builder << hloc.pathInfo.foundPath << ":" << hloc.line << "\n"; SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); - sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); + if (sourceView) + sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); + else + builder << " no source view found for field\n"; nonEmptyCount++; } diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index bad8ea44c3..097569ab4f 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -604,6 +604,9 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig IRInst* origCallee = origCall->getCallee(); + printf("transcribing call (%d):\n", origCall->sourceLoc.getRaw()); + origCall->dump(); + if (!origCallee) { // Note that this can only happen if the callee is a result @@ -671,7 +674,7 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig IRBuilder argBuilder = *builder; IRBuilder afterBuilder = argBuilder; afterBuilder.setInsertAfter(placeholderCall); - + List args; // Go over the parameter list and create pairs for each input (if required) for (UIndex ii = 0; ii < origCall->getArgCount(); ii++) @@ -778,6 +781,8 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig diffReturnType, diffCallee, args); + + callInst->sourceLoc = origCall->sourceLoc; placeholderCall->removeAndDeallocate(); argBuilder.markInstAsMixedDifferential(callInst, diffReturnType); argBuilder.addAutoDiffOriginalValueDecoration(callInst, primalCallee); @@ -1811,6 +1816,7 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr InstPair ForwardDiffTranscriber::transcribeInstImpl(IRBuilder* builder, IRInst* origInst) { + printf("%s: instruction operation is: %s\n", __FUNCTION__, getIROpInfo(origInst->m_op).name); // Handle common SSA-style operations switch (origInst->getOp()) { diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index e607e928fa..455d71d4bb 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -379,7 +379,7 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( if (processedUses.contains(use)) continue; - printf("use with usedVal:\n"); + printf("\n----use with usedVal:\n"); use.usedVal->dump(); processedUses.add(use); @@ -1932,7 +1932,7 @@ RefPtr applyCheckpointPolicy(IRGlobalValueWithCode* func) sortBlocksInFunc(func); printf("(applyCheckpointPolicy) ===============================\n"); - // func->dump(); + func->dump(); for (auto block : func->getBlocks()) { for (auto inst = block->getFirstInst(); inst; inst = inst->next) { printf("inst with location: %d (%d)\n", diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index f558a517d9..f8eb8669fc 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -695,6 +695,19 @@ namespace Slang { tempBuilder.setInsertBefore(diffPropagateFunc); } + + printf("(primalFunc from generateNewForwardDerivative)===============================\n"); + primalFunc->dump(); + for (auto block : primalFunc->getBlocks()) { + for (auto inst = block->getFirstInst(); inst; inst = inst->next) { + printf("inst with location: %d (%d)\n", + inst->sourceLoc.getRaw(), + inst->sourceLoc.isValid()); + + inst->dump(); + } + } + auto fwdDiffFunc = generateNewForwardDerivativeForFunc(&tempBuilder, primalFunc, diffPropagateFunc); if (!fwdDiffFunc) diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp index 55e68fff7f..4d6152881d 100644 --- a/source/slang/slang-ir-autodiff-transcriber-base.cpp +++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp @@ -713,6 +713,9 @@ InstPair AutoDiffTranscriberBase::transcribeBlockImpl(IRBuilder* builder, IRBloc // for (auto child = origBlock->getFirstOrdinaryInst(); child; child = child->getNextInst()) { + printf("transcribing instruction with op: %s\n", getIROpInfo(child->m_op).name); + child->dump(); + if (instsToSkip.contains(child)) { continue; @@ -944,12 +947,21 @@ IRInst* AutoDiffTranscriberBase::transcribe(IRBuilder* builder, IRInst* origInst // instsInProgress.add(origInst); auto actualInstToTranscribe = getActualInstToTranscribe(origInst); + printf("transcribing actual instruction:\n"); + printf("sourceloc info: %d (%d)\n", actualInstToTranscribe->sourceLoc.getRaw(), actualInstToTranscribe->sourceLoc.isValid()); + printf("> "); + actualInstToTranscribe->dump(); InstPair pair = transcribeInst(builder, actualInstToTranscribe); instsInProgress.remove(origInst); if (pair.primal) { + printf("\tresult:\n"); + printf("sourceloc info: %d (%d)\n", pair.primal->sourceLoc.getRaw(), pair.primal->sourceLoc.isValid()); + printf("\t> "); + pair.primal->dump(); + mapPrimalInst(origInst, pair.primal); mapDifferentialInst(origInst, pair.differential); diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index 3be1a158c6..7f4b7f474e 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -201,6 +201,9 @@ struct DiffUnzipPass InstPair splitCall(IRBuilder* primalBuilder, IRBuilder* diffBuilder, IRCall* mixedCall) { + printf("splitCall: %d\n", mixedCall->sourceLoc.getRaw()); + mixedCall->dump(); + IRBuilder globalBuilder(autodiffContext->moduleInst->getModule()); auto fwdCalleeType = mixedCall->getCallee()->getDataType(); @@ -246,6 +249,10 @@ struct DiffUnzipPass if (!as(intermediateType)) { intermediateVar = primalBuilder->emitVar((IRType*)intermediateType); + intermediateVar->sourceLoc = mixedCall->sourceLoc; + printf("creating intermediate var for mixed call (splitCall):\n"); + printf("intermediate var: %d\n", intermediateVar->sourceLoc.getRaw()); + intermediateVar->dump(); primalBuilder->markInstAsPrimal(intermediateVar); } @@ -292,6 +299,7 @@ struct DiffUnzipPass } auto primalVal = primalBuilder->emitCallInst(primalType, primalFn, primalArgs); + primalVal->sourceLoc = mixedCall->sourceLoc; if (intermediateVar) primalBuilder->addBackwardDerivativePrimalContextDecoration(primalVal, intermediateVar); primalBuilder->markInstAsPrimal(primalVal); @@ -409,6 +417,11 @@ struct DiffUnzipPass resultType, newFwdCallee, diffArgs); + + callInst->sourceLoc = mixedCall->sourceLoc; + printf("created callInst for diffBuilder: %d\n", callInst->sourceLoc.getRaw()); + callInst->dump(); + diffBuilder->markInstAsDifferential(callInst, primalType); if (intermediateVar) @@ -733,9 +746,13 @@ struct DiffUnzipPass IRBuilder diffBuilder(autodiffContext->moduleInst->getModule()); diffBuilder.setInsertInto(diffBlock); + printf("@@@@@@@@ splitting block:\n"); + List splitInsts; for (auto child : block->getModifiableChildren()) { + printf("\tchild: (%d)\n", child->sourceLoc.getRaw()); + child->dump(); if (auto getDiffInst = as(child)) { // Replace GetDiff(A) with A.d diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp index 9305d17830..6c7691d134 100644 --- a/source/slang/slang-ir.cpp +++ b/source/slang/slang-ir.cpp @@ -3512,6 +3512,7 @@ namespace Slang auto inst = createInstWithTrailingArgs( this, kIROp_MakeDifferentialPair, type, 2, args); addInst(inst); + inst->sourceLoc = primal->sourceLoc; return inst; } @@ -3524,6 +3525,7 @@ namespace Slang auto inst = createInstWithTrailingArgs( this, kIROp_MakeDifferentialPairUserCode, type, 2, args); addInst(inst); + inst->sourceLoc = primal->sourceLoc; return inst; } From 6060bdb1d071c279c4e1792a9372c3e3b9730756 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Tue, 10 Sep 2024 16:43:46 -0700 Subject: [PATCH 12/32] Source cleanup --- out.hlsl | 146 ------------------ source/slang/slang-emit.cpp | 1 - source/slang/slang-ir-autodiff-fwd.cpp | 34 +--- .../slang/slang-ir-autodiff-primal-hoist.cpp | 77 +-------- source/slang/slang-ir-autodiff-region.cpp | 2 +- source/slang/slang-ir-autodiff-rev.cpp | 75 --------- .../slang-ir-autodiff-transcriber-base.cpp | 36 +---- source/slang/slang-ir-autodiff-unzip.cpp | 9 -- source/slang/slang-ir-autodiff-unzip.h | 11 -- source/slang/slang-ir-autodiff.cpp | 3 - .../slang-ir-eliminate-multilevel-break.cpp | 24 --- source/slang/slang-ir-eliminate-phis.cpp | 4 +- source/slang/slang-ir-ssa.cpp | 62 +------- source/slang/slang-lower-to-ir.cpp | 15 -- tests/modules/ad-report | 1 - 15 files changed, 10 insertions(+), 490 deletions(-) delete mode 100644 out.hlsl delete mode 100644 tests/modules/ad-report diff --git a/out.hlsl b/out.hlsl deleted file mode 100644 index f236cc337d..0000000000 --- a/out.hlsl +++ /dev/null @@ -1,146 +0,0 @@ -#version 450 -layout(row_major) uniform; -layout(row_major) buffer; -layout(std430, binding = 0) buffer StructuredBuffer_float_t_0 { - float _data[]; -} outputBuffer_0; -struct DiffPair_float_0 -{ - float primal_0; - float differential_0; -}; - -struct s_bwd_prop_test_simple_loop_Intermediates_0 -{ - float _S1[5]; - int _S2; -}; - -float s_primal_ctx_test_simple_loop_0(float dpy_0, out s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_0) -{ - float _S3[5] = { 0.0, 0.0, 0.0, 0.0, 0.0 }; - _s_diff_ctx_0._S1 = _S3; - _s_diff_ctx_0._S2 = 0; - _s_diff_ctx_0._S1[0] = 0.0; - _s_diff_ctx_0._S1[1] = 0.0; - _s_diff_ctx_0._S1[2] = 0.0; - _s_diff_ctx_0._S1[3] = 0.0; - _s_diff_ctx_0._S1[4] = 0.0; - _s_diff_ctx_0._S2 = 0; - bool _bflag_0 = true; - float t_0 = dpy_0; - int i_0 = 0; - int _pc_0 = 0; - for(;;) - { - _s_diff_ctx_0._S1[_pc_0] = t_0; - _s_diff_ctx_0._S2 = _pc_0; - if(_bflag_0) - { - } - else - { - break; - } - float _S4; - int _S5; - if(i_0 < 3) - { - float _S6 = t_0 * t_0; - _S5 = 1; - _S4 = _S6; - } - else - { - _S5 = 0; - _S4 = 0.0; - } - if(_S5 != 1) - { - _bflag_0 = false; - } - if(_bflag_0) - { - int _S7 = i_0 + 1; - t_0 = _S4; - i_0 = _S7; - } - _pc_0 = _pc_0 + 1; - } - return t_0; -} - -void s_bwd_prop_test_simple_loop_0(inout DiffPair_float_0 dpy_1, float _s_dOut_0, s_bwd_prop_test_simple_loop_Intermediates_0 _s_diff_ctx_1) -{ - int _dc_0 = _s_diff_ctx_1._S2 - 1; - float _S8 = _s_dOut_0; - for(;;) - { - if(_dc_0 >= 0) - { - } - else - { - break; - } - bool _S9 = _dc_0 < 3; - int _S10; - if(_S9) - { - _S10 = 1; - } - else - { - _S10 = 0; - } - float _S11; - float _S12; - if(!(_S10 != 1)) - { - _S11 = _S8; - _S12 = 0.0; - } - else - { - _S11 = 0.0; - _S12 = _S8; - } - if(_S9) - { - _S8 = _s_diff_ctx_1._S1[_dc_0] * _S11 + _s_diff_ctx_1._S1[_dc_0] * _S11 + _S12; - } - else - { - _S8 = _S12; - } - _dc_0 = _dc_0 - 1; - } - dpy_1.primal_0 = dpy_1.primal_0; - dpy_1.differential_0 = _S8; - return; -} - -void s_bwd_test_simple_loop_0(inout DiffPair_float_0 _S13, float _S14) -{ - s_bwd_prop_test_simple_loop_Intermediates_0 _S15; - float _S16 = s_primal_ctx_test_simple_loop_0(_S13.primal_0, _S15); - s_bwd_prop_test_simple_loop_0(_S13, _S14, _S15); - return; -} - -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -void main() -{ - DiffPair_float_0 dpa_0; - dpa_0.primal_0 = 1.0; - dpa_0.differential_0 = 0.0; - s_bwd_test_simple_loop_0(dpa_0, 1.0); - outputBuffer_0._data[uint(0)] = dpa_0.differential_0; - DiffPair_float_0 dpa_1; - dpa_1.primal_0 = 0.40000000596046448; - dpa_1.differential_0 = 0.0; - s_bwd_test_simple_loop_0(dpa_1, 1.0); - outputBuffer_0._data[uint(1)] = dpa_1.differential_0; - return; -} - diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 20d446bd47..aff52a30a5 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -881,7 +881,6 @@ Result linkAndOptimizeIR( // Remove auto-diff related decorations. // We may have an autodiff decoration regardless of if autodiff is being used. - // TODO: strip checkpoint decorations stripAutoDiffDecorations(irModule); finalizeSpecialization(irModule); diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index 097569ab4f..b2359ed1b8 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -604,9 +604,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig IRInst* origCallee = origCall->getCallee(); - printf("transcribing call (%d):\n", origCall->sourceLoc.getRaw()); - origCall->dump(); - if (!origCallee) { // Note that this can only happen if the callee is a result @@ -674,7 +671,7 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig IRBuilder argBuilder = *builder; IRBuilder afterBuilder = argBuilder; afterBuilder.setInsertAfter(placeholderCall); - + List args; // Go over the parameter list and create pairs for each input (if required) for (UIndex ii = 0; ii < origCall->getArgCount(); ii++) @@ -1612,9 +1609,6 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) auto tempVar = builder.emitVar(ptrType->getValueType()); param->replaceUsesWith(tempVar); mapParamToTempVar[param] = tempVar; - // TODO: link source locations for this? - printf("%s -> param:\n", __FUNCTION__); - param->dump(); if (ptrType->getOp() != kIROp_OutType) { builder.emitStore(tempVar, builder.emitLoad(param)); @@ -1724,19 +1718,6 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr // Create a clone for original func and run additional transformations on the clone. IRCloneEnv env; auto primalFuncClone = as(cloneInst(&env, &builder, primalFunc)); - - // printf("(prepareFuncForForwardDiff)===============================\n"); - // primalFuncClone->dump(); - // for (auto block : primalFuncClone->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - - // inst->dump(); - // } - // } - prepareFuncForForwardDiff(primalFuncClone); builder.setInsertInto(diffFunc); @@ -1798,25 +1779,12 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr #if _DEBUG checkAutodiffInstDecorations(diffFunc); #endif - - // printf("(diffFunc at prepareFuncForForwardDiff)===============================\n"); - // diffFunc->dump(); - // for (auto block : diffFunc->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - - // inst->dump(); - // } - // } return InstPair(primalFunc, diffFunc); } InstPair ForwardDiffTranscriber::transcribeInstImpl(IRBuilder* builder, IRInst* origInst) { - printf("%s: instruction operation is: %s\n", __FUNCTION__, getIROpInfo(origInst->m_op).name); // Handle common SSA-style operations switch (origInst->getOp()) { diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index 455d71d4bb..163f50a2df 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -281,18 +281,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( IROutOfOrderCloneContext* cloneCtx, Dictionary>& blockIndexInfo) { - // printf("(Checkpoint policy)==========================================\n"); - // func->dump(); - // for (auto block : func->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - - // inst->dump(); - // } - // } - collectInductionValues(func); RefPtr checkpointInfo = new CheckpointSetInfo(); @@ -328,8 +316,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( } }; - printf("### %s\n", __FUNCTION__); - // Populate recompute/store/invert sets with insts, by applying the policy // to them. // @@ -370,7 +356,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( addPrimalOperandsToWorkList(block->getTerminator()); } - printf("processing workList\n"); while (workList.getCount() > 0) { auto use = workList.getLast(); @@ -379,9 +364,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( if (processedUses.contains(use)) continue; - printf("\n----use with usedVal:\n"); - use.usedVal->dump(); - processedUses.add(use); HoistResult result = this->classify(use); @@ -389,13 +371,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( if (result.mode == HoistResult::Mode::Store) { SLANG_ASSERT(!checkpointInfo->recomputeSet.contains(result.instToStore)); - printf("\n[#] %s, adding %p to storeSet\n", __FUNCTION__, result.instToStore); - result.instToStore->dump(); - IRInst* inst = result.instToStore; - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - checkpointInfo->storeSet.add(result.instToStore); } else if (result.mode == HoistResult::Mode::Recompute) @@ -490,7 +465,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( { checkpointInfo->recomputeSet.add(callUser); checkpointInfo->storeSet.remove(callUser); - printf("storeSet removing %p\n", callUser); if (instWorkListSet.add(callUser)) instWorkList.add(callUser); } @@ -498,7 +472,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( { checkpointInfo->recomputeSet.add(storeUser); checkpointInfo->storeSet.remove(storeUser); - printf("storeSet removing %p\n", storeUser); if (instWorkListSet.add(callUser)) instWorkList.add(callUser); } @@ -512,7 +485,6 @@ RefPtr AutodiffCheckpointPolicyBase::processFunc( { checkpointInfo->recomputeSet.add(varArg); checkpointInfo->storeSet.remove(varArg); - printf("storeSet removing %p\n", varArg); if (instWorkListSet.add(varArg)) instWorkList.add(varArg); } @@ -1479,8 +1451,6 @@ RefPtr ensurePrimalAvailability( OrderedHashSet processedStoreSet; - printf("****** ensureInstAvailable\n"); - auto ensureInstAvailable = [&](OrderedHashSet& instSet, bool isRecomputeInst) { SLANG_ASSERT(!isDifferentialBlock(defaultVarBlock)); @@ -1494,9 +1464,6 @@ RefPtr ensurePrimalAvailability( { auto instToStore = workList.getLast(); workList.removeLast(); - - printf("ensureInstAvailable, worklist element:\n"); - instToStore->dump(); if (seenInstSet.contains(instToStore)) continue; @@ -1565,7 +1532,6 @@ RefPtr ensurePrimalAvailability( if (outOfScopeUses.getCount() == 0) { - printf(">> NO OUT OF SCOPE USES\n"); if (!isRecomputeInst) processedStoreSet.add(instToStore); seenInstSet.add(instToStore); @@ -1667,7 +1633,6 @@ RefPtr ensurePrimalAvailability( bool isLoopCounter = (instToStore->findDecoration() != nullptr); if (isLoopCounter) { - printf(">> LOOP COUNTER!\n"); defBlockIndices.removeAt(0); } else @@ -1691,11 +1656,8 @@ RefPtr ensurePrimalAvailability( loadIndexedValue(&builder, localVar, defBlock, defBlockIndices, useBlockIndices)); } - if (!isRecomputeInst) { - printf("%% localVar:\n"); - localVar->dump(); + if (!isRecomputeInst) processedStoreSet.add(localVar); - } } seenInstSet.add(instToStore); @@ -1779,13 +1741,7 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC primalInitBlock->getTerminator())->getTargetBlock(); builder.setInsertBefore(primalInitBlock->getTerminator()); - printf("Adding counter for primalLoop:\n"); - primalLoop->dump(); - printf(" > sourceLoc: %d (%d)\n", - primalLoop->sourceLoc.getRaw(), - primalLoop->sourceLoc.isValid()); SourceLoc loc = primalLoop->sourceLoc; - auto phiCounterArgLoopEntryIndex = addPhiOutputArg( &builder, primalInitBlock, @@ -1802,12 +1758,6 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC builder.addNameHintDecoration(primalCountParam, UnownedStringSlice("_pc")); builder.markInstAsPrimal(primalCountParam); primalCountParam->sourceLoc = loc; - - printf(">> Counter for primalLoop:\n"); - primalCountParam->dump(); - printf(" > sourceLoc: %d (%d)\n", - primalCountParam->sourceLoc.getRaw(), - primalCountParam->sourceLoc.isValid()); IRBlock* primalUpdateBlock = getUpdateBlock(primalLoop); IRInst* terminator = primalUpdateBlock->getTerminator(); @@ -1931,18 +1881,6 @@ RefPtr applyCheckpointPolicy(IRGlobalValueWithCode* func) { sortBlocksInFunc(func); - printf("(applyCheckpointPolicy) ===============================\n"); - func->dump(); - for (auto block : func->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } - // Insert loop counters and establish loop regions. // Also makes the reverse loops counting downwards from the final iteration count. // @@ -1964,21 +1902,10 @@ RefPtr applyCheckpointPolicy(IRGlobalValueWithCode* func) chkPolicy->preparePolicy(func); auto primalsInfo = chkPolicy->processFunc(func, recomputeBlockMap, cloneCtx, indexedBlockInfo); - // NOTE: (Mostly) original instructions are here... - printf("****** (before legalization) # of elements in the store set for hoistInfo: %d\n", primalsInfo->storeSet.getCount()); - for (auto stored : primalsInfo->storeSet) { - printf("source loc recorded: %d (%d)\n", - stored->sourceLoc.getRaw(), - stored->sourceLoc.isValid()); - stored->dump(); - } - // Legalize the primal inst accesses by introducing local variables / arrays and emitting // necessary load/store logic. // - primalsInfo = ensurePrimalAvailability(primalsInfo, func, indexedBlockInfo); - - return primalsInfo; + return ensurePrimalAvailability(primalsInfo, func, indexedBlockInfo); } void DefaultCheckpointPolicy::preparePolicy(IRGlobalValueWithCode* func) diff --git a/source/slang/slang-ir-autodiff-region.cpp b/source/slang/slang-ir-autodiff-region.cpp index 04182eef23..98b64f179a 100644 --- a/source/slang/slang-ir-autodiff-region.cpp +++ b/source/slang/slang-ir-autodiff-region.cpp @@ -50,7 +50,7 @@ namespace Slang{ workList.add(successor); } } - + return regionMap; } }; diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index f8eb8669fc..fae4b7fceb 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -582,18 +582,6 @@ namespace Slang // reversible. if (SLANG_FAILED(prepareFuncForBackwardDiff(primalFunc))) return diffPropagateFunc; - - // printf("(result after prepareFuncForBackwardDiff)===============================\n"); - // //primalFunc->dump(); - // for (auto block : primalFunc->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - - // inst->dump(); - // } - // } // Forward transcribe the clone of the original func. ForwardDiffTranscriber& fwdTranscriber = *static_cast( @@ -605,7 +593,6 @@ namespace Slang auto newCount = autoDiffSharedContext->followUpFunctionsToTranscribe.getCount(); for (auto i = oldCount; i < newCount; i++) { - // printf("transcribing function with fwd mode: %d (%d, %d)\n", i, oldCount, newCount); auto pendingTask = autoDiffSharedContext->followUpFunctionsToTranscribe.getLast(); autoDiffSharedContext->followUpFunctionsToTranscribe.removeLast(); SLANG_RELEASE_ASSERT(pendingTask.type == FuncBodyTranscriptionTaskType::Forward); @@ -695,36 +682,11 @@ namespace Slang { tempBuilder.setInsertBefore(diffPropagateFunc); } - - printf("(primalFunc from generateNewForwardDerivative)===============================\n"); - primalFunc->dump(); - for (auto block : primalFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } - auto fwdDiffFunc = generateNewForwardDerivativeForFunc(&tempBuilder, primalFunc, diffPropagateFunc); if (!fwdDiffFunc) return; - printf("(fwdDiffFunc from generateNewForwardDerivative)===============================\n"); - fwdDiffFunc->dump(); - for (auto block : fwdDiffFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } - bool isResultDifferentiable = as(fwdDiffFunc->getResultType()); // Split first block into a paramter block. @@ -738,20 +700,6 @@ namespace Slang diffUnzipPass->unzipDiffInsts(fwdDiffFunc); IRFunc* unzippedFwdDiffFunc = fwdDiffFunc; - - printf("(diffPropagateFunc after unzipping)===============================\n"); - diffPropagateFunc->dump(); - - printf("(unzipDiffInsts)===============================\n"); - for (auto block : unzippedFwdDiffFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } // Move blocks from `unzippedFwdDiffFunc` to the `diffPropagateFunc` shell. builder->setInsertInto(diffPropagateFunc->getParent()); @@ -763,18 +711,6 @@ namespace Slang for (auto block : workList) block->insertAtEnd(diffPropagateFunc); } - - printf("(diffPropagateFunc moving blocks)===============================\n"); - diffPropagateFunc->dump(); - for (auto block : diffPropagateFunc->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } // Transpose the first block (parameter block) auto paramTransposeInfo = @@ -797,17 +733,6 @@ namespace Slang auto primalsInfo = applyCheckpointPolicy(diffPropagateFunc); eliminateDeadCode(diffPropagateFunc); - - printf("****** (after legalization) # of elements in the store set for hoistInfo: %d\n", primalsInfo->storeSet.getCount()); - for (auto stored : primalsInfo->storeSet) { - printf("source loc recorded: %d (%d)\n", - stored->sourceLoc.getRaw(), - stored->sourceLoc.isValid()); - stored->dump(); - getSink()->diagnose(stored->sourceLoc, Diagnostics::alsoSeePipelineDefinition); - - IRType* type = stored->getFullType(); - } // Extracts the primal computations into its own func, turn all accesses to stored primal insts into // explicit intermediate data structure reads and writes. diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp index 4d6152881d..75db5f56ad 100644 --- a/source/slang/slang-ir-autodiff-transcriber-base.cpp +++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp @@ -713,9 +713,6 @@ InstPair AutoDiffTranscriberBase::transcribeBlockImpl(IRBuilder* builder, IRBloc // for (auto child = origBlock->getFirstOrdinaryInst(); child; child = child->getNextInst()) { - printf("transcribing instruction with op: %s\n", getIROpInfo(child->m_op).name); - child->dump(); - if (instsToSkip.contains(child)) { continue; @@ -947,21 +944,12 @@ IRInst* AutoDiffTranscriberBase::transcribe(IRBuilder* builder, IRInst* origInst // instsInProgress.add(origInst); auto actualInstToTranscribe = getActualInstToTranscribe(origInst); - printf("transcribing actual instruction:\n"); - printf("sourceloc info: %d (%d)\n", actualInstToTranscribe->sourceLoc.getRaw(), actualInstToTranscribe->sourceLoc.isValid()); - printf("> "); - actualInstToTranscribe->dump(); InstPair pair = transcribeInst(builder, actualInstToTranscribe); instsInProgress.remove(origInst); if (pair.primal) { - printf("\tresult:\n"); - printf("sourceloc info: %d (%d)\n", pair.primal->sourceLoc.getRaw(), pair.primal->sourceLoc.isValid()); - printf("\t> "); - pair.primal->dump(); - mapPrimalInst(origInst, pair.primal); mapDifferentialInst(origInst, pair.differential); @@ -1044,32 +1032,12 @@ InstPair AutoDiffTranscriberBase::transcribeInst(IRBuilder* builder, IRInst* ori // if (as(origInst->getParent()) && !as(origInst)) return InstPair(origInst, nullptr); - - //printf("\n\ntranscribing an original instruction: %d (%d)\n", - // origInst->sourceLoc.getRaw(), origInst->sourceLoc.isValid()); - //printf(" >"); - //origInst->dump(); auto result = transcribeInstImpl(builder, origInst); - - //printf("result:\n"); - if (result.primal) { - //printf(" >"); - //result.primal->dump(); + if (result.primal) result.primal->sourceLoc = origInst->sourceLoc; - //printf(" [P] source loc: %d (%d)\n", - // result.primal->sourceLoc.getRaw(), - // result.primal->sourceLoc.isValid()); - } - - if (result.differential) { - //printf(" >"); - //result.differential->dump(); + if (result.differential) result.differential->sourceLoc = origInst->sourceLoc; - //printf(" [D] source loc: %d (%d)\n", - // result.differential->sourceLoc.getRaw(), - // result.differential->sourceLoc.isValid()); - } if (result.primal == nullptr && result.differential == nullptr) { diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp index 4c4fafa868..6ab86b1174 100644 --- a/source/slang/slang-ir-autodiff-unzip.cpp +++ b/source/slang/slang-ir-autodiff-unzip.cpp @@ -181,10 +181,6 @@ struct ExtractPrimalFuncContext auto newFuncType = generatePrimalFuncType(unzippedFunc, originalFunc, intermediateType); outIntermediateType = intermediateType; func->setFullType((IRType*)newFuncType); - - printf("in unzipping function:\n"); - printf("createIntermediate type:\n"); - intermediateType->dump(); auto paramBlock = func->getFirstBlock(); builder.setInsertInto(paramBlock); @@ -227,14 +223,9 @@ struct ExtractPrimalFuncContext { auto field = addIntermediateContextField(cast(inst->getDataType())->getValueType(), outIntermediary); field->sourceLoc = inst->sourceLoc; - if (inst->findDecoration()) builder.addLoopCounterDecoration(field); - printf("ADDING FIELD:\n"); - inst->dump(); - field->dump(); - builder.setInsertBefore(inst); auto fieldAddr = builder.emitFieldAddress( inst->getFullType(), outIntermediary, field->getKey()); diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index 7f4b7f474e..ac252726af 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -201,7 +201,6 @@ struct DiffUnzipPass InstPair splitCall(IRBuilder* primalBuilder, IRBuilder* diffBuilder, IRCall* mixedCall) { - printf("splitCall: %d\n", mixedCall->sourceLoc.getRaw()); mixedCall->dump(); IRBuilder globalBuilder(autodiffContext->moduleInst->getModule()); @@ -250,9 +249,6 @@ struct DiffUnzipPass { intermediateVar = primalBuilder->emitVar((IRType*)intermediateType); intermediateVar->sourceLoc = mixedCall->sourceLoc; - printf("creating intermediate var for mixed call (splitCall):\n"); - printf("intermediate var: %d\n", intermediateVar->sourceLoc.getRaw()); - intermediateVar->dump(); primalBuilder->markInstAsPrimal(intermediateVar); } @@ -419,9 +415,6 @@ struct DiffUnzipPass diffArgs); callInst->sourceLoc = mixedCall->sourceLoc; - printf("created callInst for diffBuilder: %d\n", callInst->sourceLoc.getRaw()); - callInst->dump(); - diffBuilder->markInstAsDifferential(callInst, primalType); if (intermediateVar) @@ -746,13 +739,9 @@ struct DiffUnzipPass IRBuilder diffBuilder(autodiffContext->moduleInst->getModule()); diffBuilder.setInsertInto(diffBlock); - printf("@@@@@@@@ splitting block:\n"); - List splitInsts; for (auto child : block->getModifiableChildren()) { - printf("\tchild: (%d)\n", child->sourceLoc.getRaw()); - child->dump(); if (auto getDiffInst = as(child)) { // Replace GetDiff(A) with A.d diff --git a/source/slang/slang-ir-autodiff.cpp b/source/slang/slang-ir-autodiff.cpp index 5bd6467237..07a6a76fb3 100644 --- a/source/slang/slang-ir-autodiff.cpp +++ b/source/slang/slang-ir-autodiff.cpp @@ -1952,21 +1952,18 @@ struct AutoDiffPass : public InstPassBase break; case kIROp_BackwardDifferentiatePrimal: { - printf("BACKWARD DIFFERENTIATE PRIMAL\n"); auto baseFunc = differentiateInst->getOperand(0); diffFunc = backwardPrimalTranscriber.transcribe(&subBuilder, baseFunc); } break; case kIROp_BackwardDifferentiatePropagate: { - printf("BACKWARD DIFFERENTIATE PROPOGATE\n"); auto baseFunc = differentiateInst->getOperand(0); diffFunc = backwardPropagateTranscriber.transcribe(&subBuilder, baseFunc); } break; case kIROp_BackwardDifferentiate: { - printf("BACKWARD DIFFERENTIATE\n"); auto baseFunc = differentiateInst->getOperand(0); diffFunc = backwardTranscriber.transcribe(&subBuilder, baseFunc); } diff --git a/source/slang/slang-ir-eliminate-multilevel-break.cpp b/source/slang/slang-ir-eliminate-multilevel-break.cpp index 7ff5761cf2..eafdbbcec6 100644 --- a/source/slang/slang-ir-eliminate-multilevel-break.cpp +++ b/source/slang/slang-ir-eliminate-multilevel-break.cpp @@ -303,18 +303,6 @@ struct EliminateMultiLevelBreakContext void processFunc(IRGlobalValueWithCode* func) { - //printf("(result before branch normalization)===============================\n"); - //func->dump(); - //for (auto block : func->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - - // inst->dump(); - // } - //} - normalizeBranchesIntoBreakBlocks(func); // If func does not have any multi-level breaks, return. @@ -325,18 +313,6 @@ struct EliminateMultiLevelBreakContext if (funcInfo.multiLevelBreaks.getCount() == 0) return; } - - printf("(result before eliminating phis)===============================\n"); - //func->dump(); - for (auto block : func->getBlocks()) { - for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - printf("inst with location: %d (%d)\n", - inst->sourceLoc.getRaw(), - inst->sourceLoc.isValid()); - - inst->dump(); - } - } // To make things easy, eliminate Phis before perform transformations. eliminatePhisInFunc(LivenessMode::Disabled, irModule, func, PhiEliminationOptions::getFast()); diff --git a/source/slang/slang-ir-eliminate-phis.cpp b/source/slang/slang-ir-eliminate-phis.cpp index fcf96d3446..0db2fc765c 100644 --- a/source/slang/slang-ir-eliminate-phis.cpp +++ b/source/slang/slang-ir-eliminate-phis.cpp @@ -120,7 +120,7 @@ struct PhiEliminationContext // for Phi parameters and other insts that benefit from // converting to memory. initializePerFuncState(func); - + // First, we eliminate all the phi instructions (params) // using the result of register allocation. // The first block in a function is always the entry block, @@ -138,7 +138,7 @@ struct PhiEliminationContext eliminatePhisInBlock(block); } - + // Next, convert the definition of other ordinary insts to assignments. convertInstDefToRegisterAssignment(); diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index 8ff1b0f286..bac4d2544e 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -1109,24 +1109,6 @@ bool constructSSA(ConstructSSAContext* context) // and stores of promotable variables with simple values. auto globalVal = context->globalVal; - - auto func = as(globalVal); - bool dump = func->findDecoration (); - - //if (dump) { - // printf("(globalVal)===============================\n"); - // func->dump(); - - // //for (auto block : func->getBlocks()) { - // // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // // printf("inst with location: %d (%d)\n", - // // inst->sourceLoc.getRaw(), - // // inst->sourceLoc.isValid()); - // // inst->dump(); - // // } - // //} - //} - for(auto bb : globalVal->getBlocks()) { auto blockInfo = new SSABlockInfo(); @@ -1155,21 +1137,9 @@ bool constructSSA(ConstructSSAContext* context) auto blockInfo = *context->blockInfos.tryGetValue(bb); // First remove phis from their parent blocks. - for (auto phiInfo : blockInfo->phis) { - //if (dump) { - // printf("phiInfo:\n"); - // phiInfo->var->dump(); - // phiInfo->phi->dump(); - // printf(">> locations: %d (%d) & %d (%d)\n", - // phiInfo->var->sourceLoc.getRaw(), - // phiInfo->var->sourceLoc.isValid(), - // phiInfo->phi->sourceLoc.getRaw(), - // phiInfo->phi->sourceLoc.isValid()); - //} - + for (auto phiInfo : blockInfo->phis) if (!phiInfo->replacement) phiInfo->phi->removeFromParent(); - } // Then, add them back in a consistent order, and add predecessor // args in the same order. @@ -1269,13 +1239,7 @@ bool constructSSA(ConstructSSAContext* context) // TODO: do we need to be careful here in case one // of thes operations still has uses, as part of // another to-be-remvoed instruction? - //if (dump) { - // printf("removing instruction:\n"); - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - // inst->dump(); - //} + inst->removeAndDeallocate(); } @@ -1283,30 +1247,8 @@ bool constructSSA(ConstructSSAContext* context) // of of the variables for (auto var : context->promotableVars) { - //if (dump) { - // printf("removing variable:\n"); - // printf("inst with location: %d (%d)\n", - // var->sourceLoc.getRaw(), - // var->sourceLoc.isValid()); - // var->dump(); - //} var->removeAndDeallocate(); } - - //if (dump) { - // printf("<<<< (globalVal-END)===============================\n"); - // func->dump(); - - // for (auto block : func->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - // inst->dump(); - // } - // } - //} - return true; } diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index dec214e60a..8134677437 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -10318,21 +10318,6 @@ struct DeclLoweringVisitor : DeclVisitor // of global values. irFunc->moveToEnd(); - //printf("(lowered function) =============================================\n"); - //irFunc->dump(); - - //for (auto block : irFunc->getBlocks()) { - // for (auto inst = block->getFirstInst(); inst; inst = inst->next) { - // printf("inst with location: %d (%d)\n", - // inst->sourceLoc.getRaw(), - // inst->sourceLoc.isValid()); - // inst->dump(); - - // if (inst->sourceLoc.isValid()) - // getSink()->diagnose(inst->sourceLoc, Diagnostics::seeDeclarationOf, inst); - // } - //} - // If this function is defined inside an interface, add a reference to the IRFunc from // the interface's type definition. auto finalVal = finishOuterGenerics(subBuilder, irFunc, outerGeneric); diff --git a/tests/modules/ad-report b/tests/modules/ad-report deleted file mode 100644 index e197cbb89d..0000000000 --- a/tests/modules/ad-report +++ /dev/null @@ -1 +0,0 @@ -(0): error 1: cannot open file 'tests/autodiff/reverse-loop.slang'. From 0cf45fe4cd736f27f98da79e0e88a64d559e0597 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 11 Sep 2024 10:28:38 -0700 Subject: [PATCH 13/32] Fix compilation warnings --- source/slang/slang-emit.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index aff52a30a5..77fa837737 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -251,13 +251,13 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno auto checkpointDecoration = structType->findDecoration(); if (checkpointDecoration) { - IRSizeAndAlignment sizeInfo; - getNaturalSizeAndAlignment(optionSet, structType, &sizeInfo); + IRSizeAndAlignment structSize; + getNaturalSizeAndAlignment(optionSet, structType, &structSize); // Reporting happens before empty structs are optimized out // and we still want to keep the checkpointing decorations, // so we end up needing to check for non-zero-ness - if (sizeInfo.size == 0) + if (structSize.size == 0) continue; builder << "checkpointing context generated for function: "; @@ -268,26 +268,26 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno else if (auto nameHint = func->findDecoration()) builder << nameHint->getName(); - HumaneSourceLoc hloc = getHumanLoc(structType->sourceLoc); + HumaneSourceLoc structLocation = getHumanLoc(structType->sourceLoc); builder << "\n"; - builder << " defined at " << hloc.pathInfo.foundPath << ":" << hloc.line << "\n"; - builder << " size of context: " << sizeInfo.size << " bytes\n"; + builder << " defined at " << structLocation.pathInfo.foundPath << ":" << structLocation.line << "\n"; + builder << " size of context: " << structSize.size << " bytes\n"; builder << "\n"; for (auto field : structType->getFields()) { IRType *fieldType = field->getFieldType(); - IRSizeAndAlignment sizeInfo; - getNaturalSizeAndAlignment(optionSet, fieldType, &sizeInfo); - if (sizeInfo.size == 0) + IRSizeAndAlignment fieldSize; + getNaturalSizeAndAlignment(optionSet, fieldType, &fieldSize); + if (fieldSize.size == 0) continue; emitter.emitType(fieldType); - HumaneSourceLoc hloc = getHumanLoc(field->sourceLoc); + HumaneSourceLoc fieldLocation = getHumanLoc(field->sourceLoc); - builder << " " << sizeInfo.size; + builder << " " << fieldSize.size; builder << " bytes used for field of type: "; builder << typeWriter.getContent() << "\n"; typeWriter.clearContent(); @@ -297,7 +297,7 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno builder << "loop counter created for loop at "; else builder << "the following item defined at "; - builder << hloc.pathInfo.foundPath << ":" << hloc.line << "\n"; + builder << fieldLocation.pathInfo.foundPath << ":" << fieldLocation.line << "\n"; SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); if (sourceView) From d96bd61bdfbcaae5b5c944ab093fa84204d2e353 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 16 Sep 2024 11:32:49 -0700 Subject: [PATCH 14/32] Remove stray dump() --- source/slang/slang-ir-autodiff-unzip.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index ac252726af..32bfe986b7 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -201,8 +201,6 @@ struct DiffUnzipPass InstPair splitCall(IRBuilder* primalBuilder, IRBuilder* diffBuilder, IRCall* mixedCall) { - mixedCall->dump(); - IRBuilder globalBuilder(autodiffContext->moduleInst->getModule()); auto fwdCalleeType = mixedCall->getCallee()->getDataType(); From 9e1439f8ab621b472d127cc90a6fd393fe3188c8 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Mon, 16 Sep 2024 17:00:27 -0700 Subject: [PATCH 15/32] Provide the report through diagnostic notes --- source/slang/slang-diagnostic-defs.h | 5 +++ source/slang/slang-emit.cpp | 53 +++++----------------------- 2 files changed, 13 insertions(+), 45 deletions(-) diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 81170fac3e..258a41e7a8 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -894,6 +894,11 @@ DIAGNOSTIC(58002, Error, unhandledGLSLSSBOType, "Unhandled GLSL Shader Storage B DIAGNOSTIC(58003, Error, inconsistentPointerAddressSpace, "'$0': use of pointer with inconsistent address space.") +// Autodiff checkpoint reporting +DIAGNOSTIC(-1, Note, reportCheckpointIntermediates, "checkpointing context of $1 bytes was generated for function: '$0'") +DIAGNOSTIC(-1, Note, reportCheckpointVariable, "$0 bytes ($1) used for a variable here:") +DIAGNOSTIC(-1, Note, reportCheckpointCounter, "$0 bytes ($1) used for a loop counter here:") + // // 8xxxx - Issues specific to a particular library/technology/platform/etc. // diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 77fa837737..cffb497aeb 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -239,9 +239,6 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno GLSLSourceEmitter emitter(description); - StringBuilder builder; - int nonEmptyCount = 0; - for (auto inst : irModule->getGlobalInsts()) { IRStructType *structType = as(inst); @@ -260,20 +257,8 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno if (structSize.size == 0) continue; - builder << "checkpointing context generated for function: "; - auto func = checkpointDecoration->getSourceFunction(); - if (!func) - builder << "(?)"; - else if (auto nameHint = func->findDecoration()) - builder << nameHint->getName(); - - HumaneSourceLoc structLocation = getHumanLoc(structType->sourceLoc); - - builder << "\n"; - builder << " defined at " << structLocation.pathInfo.foundPath << ":" << structLocation.line << "\n"; - builder << " size of context: " << structSize.size << " bytes\n"; - builder << "\n"; + sink->diagnose(structType, Diagnostics::reportCheckpointIntermediates, func, structSize.size); for (auto field : structType->getFields()) { @@ -283,40 +268,18 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno if (fieldSize.size == 0) continue; - emitter.emitType(fieldType); - - HumaneSourceLoc fieldLocation = getHumanLoc(field->sourceLoc); - - builder << " " << fieldSize.size; - builder << " bytes used for field of type: "; - builder << typeWriter.getContent() << "\n"; typeWriter.clearContent(); + emitter.emitType(fieldType); - builder << " generated to checkpoint "; - if (field->findDecoration()) - builder << "loop counter created for loop at "; - else - builder << "the following item defined at "; - builder << fieldLocation.pathInfo.foundPath << ":" << fieldLocation.line << "\n"; - - SourceView *sourceView = sourceManager->findSourceViewRecursively(field->sourceLoc); - if (sourceView) - sourceLocationNoteDiagnostic(sink, sourceView, field->sourceLoc, builder); - else - builder << " no source view found for field\n"; - - nonEmptyCount++; + sink->diagnose(field->sourceLoc, + field->findDecoration() + ? Diagnostics::reportCheckpointCounter + : Diagnostics::reportCheckpointVariable, + fieldSize.size, + typeWriter.getContent()); } } } - - if (nonEmptyCount == 0) - builder << "no checkpointing contexts were generated\n"; - - SourceWriter writer(sourceManager, LineDirectiveMode::None, nullptr); - writer.emit(builder); - - File::writeAllText("checkpoint-report.txt", writer.getContent()); } struct LinkingAndOptimizationOptions From b40285508746b50f50e7903223a3034e85e7fe36 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Tue, 17 Sep 2024 10:28:09 -0700 Subject: [PATCH 16/32] Add missing path for sourceLoc during unzip pass --- source/slang/slang-diagnostic-defs.h | 2 +- source/slang/slang-emit.cpp | 65 +++++++++++------------- source/slang/slang-ir-autodiff-unzip.cpp | 1 + 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 258a41e7a8..4458d840e3 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -896,7 +896,7 @@ DIAGNOSTIC(58003, Error, inconsistentPointerAddressSpace, "'$0': use of pointer // Autodiff checkpoint reporting DIAGNOSTIC(-1, Note, reportCheckpointIntermediates, "checkpointing context of $1 bytes was generated for function: '$0'") -DIAGNOSTIC(-1, Note, reportCheckpointVariable, "$0 bytes ($1) used for a variable here:") +DIAGNOSTIC(-1, Note, reportCheckpointVariable, "$0 bytes ($1) used to checkpoint the following item:") DIAGNOSTIC(-1, Note, reportCheckpointCounter, "$0 bytes ($1) used for a loop counter here:") // diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index cffb497aeb..74c11d9f1a 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -223,14 +223,7 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno SLANG_ASSERT(compileRequest); SourceManager* sourceManager = sink->getSourceManager(); - auto getHumanLoc = [&](const SourceLoc &sourceLoc) - { - SourceView *sourceView = sourceManager->findSourceViewRecursively(sourceLoc); - if (sourceView) - return sourceView->getHumaneLoc(sourceLoc); - return HumaneSourceLoc(); - }; - + SourceWriter typeWriter(sourceManager, LineDirectiveMode::None, nullptr); CLikeSourceEmitter::Desc description; @@ -246,38 +239,38 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno continue; auto checkpointDecoration = structType->findDecoration(); - if (checkpointDecoration) - { - IRSizeAndAlignment structSize; - getNaturalSizeAndAlignment(optionSet, structType, &structSize); + if (!checkpointDecoration) + continue; + + IRSizeAndAlignment structSize; + getNaturalSizeAndAlignment(optionSet, structType, &structSize); - // Reporting happens before empty structs are optimized out - // and we still want to keep the checkpointing decorations, - // so we end up needing to check for non-zero-ness - if (structSize.size == 0) + // Reporting happens before empty structs are optimized out + // and we still want to keep the checkpointing decorations, + // so we end up needing to check for non-zero-ness + if (structSize.size == 0) + continue; + + auto func = checkpointDecoration->getSourceFunction(); + sink->diagnose(structType, Diagnostics::reportCheckpointIntermediates, func, structSize.size); + + for (auto field : structType->getFields()) + { + IRType *fieldType = field->getFieldType(); + IRSizeAndAlignment fieldSize; + getNaturalSizeAndAlignment(optionSet, fieldType, &fieldSize); + if (fieldSize.size == 0) continue; - auto func = checkpointDecoration->getSourceFunction(); - sink->diagnose(structType, Diagnostics::reportCheckpointIntermediates, func, structSize.size); + typeWriter.clearContent(); + emitter.emitType(fieldType); - for (auto field : structType->getFields()) - { - IRType *fieldType = field->getFieldType(); - IRSizeAndAlignment fieldSize; - getNaturalSizeAndAlignment(optionSet, fieldType, &fieldSize); - if (fieldSize.size == 0) - continue; - - typeWriter.clearContent(); - emitter.emitType(fieldType); - - sink->diagnose(field->sourceLoc, - field->findDecoration() - ? Diagnostics::reportCheckpointCounter - : Diagnostics::reportCheckpointVariable, - fieldSize.size, - typeWriter.getContent()); - } + sink->diagnose(field->sourceLoc, + field->findDecoration() + ? Diagnostics::reportCheckpointCounter + : Diagnostics::reportCheckpointVariable, + fieldSize.size, + typeWriter.getContent()); } } } diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp index 6ab86b1174..8ae8865450 100644 --- a/source/slang/slang-ir-autodiff-unzip.cpp +++ b/source/slang/slang-ir-autodiff-unzip.cpp @@ -157,6 +157,7 @@ struct ExtractPrimalFuncContext IRInst* intermediateOutput) { auto field = addIntermediateContextField(inst->getDataType(), intermediateOutput); + field->sourceLoc = inst->sourceLoc; auto key = field->getKey(); if (auto nameHint = inst->findDecoration()) cloneDecoration(nameHint, key); From f1c6200ba9e2bb0a7cf44b3f30c830c2fb5d8234 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Tue, 17 Sep 2024 11:13:52 -0700 Subject: [PATCH 17/32] Add tests for reporting intermediates --- tests/autodiff/reverse-checkpoint-1.slang | 6 ++++++ tests/autodiff/reverse-checkpoint-2.slang | 2 ++ tests/autodiff/reverse-continue-loop.slang | 6 ++++++ tests/autodiff/reverse-loop-checkpoint-test.slang | 8 ++++++++ tests/autodiff/reverse-loop.slang | 6 ++++++ tests/autodiff/reverse-nested-calls.slang | 5 +++++ 6 files changed, 33 insertions(+) diff --git a/tests/autodiff/reverse-checkpoint-1.slang b/tests/autodiff/reverse-checkpoint-1.slang index 5172970135..cd93db1a6e 100644 --- a/tests/autodiff/reverse-checkpoint-1.slang +++ b/tests/autodiff/reverse-checkpoint-1.slang @@ -2,6 +2,7 @@ //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj //TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile cs_5_0 -entry computeMain -line-directive-mode none +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; @@ -16,13 +17,16 @@ float g(float x) return log(x); } +//CHK: note: checkpointing context of 4 bytes was generated for function: 'f' [BackwardDifferentiable] float f(int p, float x) { float y = 1.0; // Test that phi parameter can be restored. if (p == 0) + //CHK: note: 4 bytes (float) used to checkpoint the following item: y = g(x); + return y * y; } @@ -41,3 +45,5 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) __bwd_diff(f)(0, dpa, 1.0f); outputBuffer[0] = dpa.d; // Expect: 1 } + +//CHK-NOT: note \ No newline at end of file diff --git a/tests/autodiff/reverse-checkpoint-2.slang b/tests/autodiff/reverse-checkpoint-2.slang index 8a7262aa4d..1dd3f29638 100644 --- a/tests/autodiff/reverse-checkpoint-2.slang +++ b/tests/autodiff/reverse-checkpoint-2.slang @@ -41,3 +41,5 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) __bwd_diff(f)(0, dpa, 1.0f); outputBuffer[0] = dpa.d; // Expect: 1 } + +//CHK-NOT: note \ No newline at end of file diff --git a/tests/autodiff/reverse-continue-loop.slang b/tests/autodiff/reverse-continue-loop.slang index 0f95026734..65abcb7a47 100644 --- a/tests/autodiff/reverse-continue-loop.slang +++ b/tests/autodiff/reverse-continue-loop.slang @@ -1,6 +1,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; @@ -8,11 +9,14 @@ RWStructuredBuffer outputBuffer; typedef DifferentialPair dpfloat; typedef float.Differential dfloat; +//CHK: note: checkpointing context of 24 bytes was generated for function: 'test_loop_with_continue' [BackwardDifferentiable] float test_loop_with_continue(float y) { + //CHK: note: 20 bytes (float [5]) used to checkpoint the following item: float t = y; + //CHK: note: 4 bytes (int) used for a loop counter here: for (int i = 0; i < 3; i++) { if (t > 4.0) @@ -41,3 +45,5 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) outputBuffer[1] = dpa.d; // Expect: 0.0131072 } } + +//CHK-NOT: note \ No newline at end of file diff --git a/tests/autodiff/reverse-loop-checkpoint-test.slang b/tests/autodiff/reverse-loop-checkpoint-test.slang index fc206e1289..15afbad805 100644 --- a/tests/autodiff/reverse-loop-checkpoint-test.slang +++ b/tests/autodiff/reverse-loop-checkpoint-test.slang @@ -1,5 +1,6 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type //TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile cs_5_0 -entry computeMain -line-directive-mode none +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; @@ -44,13 +45,18 @@ float3 infinitesimal(float3 x) return x - detach(x); } +//CHK: note: checkpointing context of 20 bytes was generated for function: 'computeLoop' [BackwardDifferentiable] [PreferRecompute] float3 computeLoop(float y) { + //CHK: note: 4 bytes (float) used to checkpoint the following item: float w = 0; + + //CHK: note: 12 bytes (vec3) used to checkpoint the following item: float3 w3 = float3(0, 0, 0); + //CHK: note: 4 bytes (int) used for a loop counter here: for (int i = 0; i < 8; i++) { float k = compute(i, y); @@ -93,3 +99,5 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) outputBuffer[2] = computeLoop(1.0).x; } + +//CHK-NOT: note \ No newline at end of file diff --git a/tests/autodiff/reverse-loop.slang b/tests/autodiff/reverse-loop.slang index a2c826be98..bdd040cf8a 100644 --- a/tests/autodiff/reverse-loop.slang +++ b/tests/autodiff/reverse-loop.slang @@ -1,6 +1,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; @@ -8,11 +9,14 @@ RWStructuredBuffer outputBuffer; typedef DifferentialPair dpfloat; typedef float.Differential dfloat; +//CHK: note: checkpointing context of 24 bytes was generated for function: 'test_simple_loop' [Differentiable] float test_simple_loop(float y) { + //CHK: note: 20 bytes (float [5]) used to checkpoint the following item: float t = y; + //CHK: note: 4 bytes (int) used for a loop counter here: for (int i = 0; i < 3; i++) { t = t * t; @@ -38,3 +42,5 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) outputBuffer[1] = dpa.d; // Expect: 0.0131072 } } + +//CHK-NOT: note \ No newline at end of file diff --git a/tests/autodiff/reverse-nested-calls.slang b/tests/autodiff/reverse-nested-calls.slang index caf2df6f8c..f87e941576 100644 --- a/tests/autodiff/reverse-nested-calls.slang +++ b/tests/autodiff/reverse-nested-calls.slang @@ -1,6 +1,7 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type -shaderobj +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; @@ -15,9 +16,11 @@ float g(float y) return result * result; } +//CHK: note: checkpointing context of 4 bytes was generated for function: 'f' [BackwardDifferentiable] float f(float x) { + //CHK: note: 4 bytes (float) used to checkpoint the following item: return 3.0f * g(2.0f * x); } @@ -29,3 +32,5 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) __bwd_diff(f)(dpa, 1.0f); outputBuffer[0] = dpa.d; // Expect: 96.0 } + +//CHK-NOT: note \ No newline at end of file From 5fadff302eea22aed8d88745e4e1fe131c749768 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Tue, 17 Sep 2024 16:48:21 -0700 Subject: [PATCH 18/32] Include more transfer cases for source locations --- source/slang/slang-diagnostic-defs.h | 2 +- source/slang/slang-emit.cpp | 5 +- .../slang/slang-ir-addr-inst-elimination.cpp | 49 +++++++--- source/slang/slang-ir-autodiff-fwd.cpp | 96 +++++++++++++++---- source/slang/slang-ir-autodiff-rev.cpp | 22 ++++- .../slang-ir-autodiff-transcriber-base.cpp | 1 + source/slang/slang-ir-autodiff-transpose.h | 83 ++++++++++++---- 7 files changed, 203 insertions(+), 55 deletions(-) diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index 4458d840e3..ac9386cd29 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -895,7 +895,7 @@ DIAGNOSTIC(58002, Error, unhandledGLSLSSBOType, "Unhandled GLSL Shader Storage B DIAGNOSTIC(58003, Error, inconsistentPointerAddressSpace, "'$0': use of pointer with inconsistent address space.") // Autodiff checkpoint reporting -DIAGNOSTIC(-1, Note, reportCheckpointIntermediates, "checkpointing context of $1 bytes was generated for function: '$0'") +DIAGNOSTIC(-1, Note, reportCheckpointIntermediates, "checkpointing context of $1 bytes associated with function: '$0'") DIAGNOSTIC(-1, Note, reportCheckpointVariable, "$0 bytes ($1) used to checkpoint the following item:") DIAGNOSTIC(-1, Note, reportCheckpointCounter, "$0 bytes ($1) used for a loop counter here:") diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 74c11d9f1a..e04ab42a6b 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -218,10 +218,7 @@ static void dumpIRIfEnabled( static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, DiagnosticSink* sink, IRModule* irModule) { // Report checkpointing information - EndToEndCompileRequest *compileRequest = codeGenContext->isEndToEndCompile(); - CompilerOptionSet &optionSet = compileRequest->getOptionSet(); - SLANG_ASSERT(compileRequest); - + CompilerOptionSet& optionSet = codeGenContext->getTargetProgram()->getOptionSet(); SourceManager* sourceManager = sink->getSourceManager(); SourceWriter typeWriter(sourceManager, LineDirectiveMode::None, nullptr); diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp index 8a48936d7e..30cbdcfbf8 100644 --- a/source/slang/slang-ir-addr-inst-elimination.cpp +++ b/source/slang/slang-ir-addr-inst-elimination.cpp @@ -16,26 +16,36 @@ struct AddressInstEliminationContext IRModule* module; DiagnosticSink* sink; - IRInst* getValue(IRBuilder& builder, IRInst* addr) + IRInst* getValue(IRBuilder& builder, IRInst* addr, SourceLoc loc) { switch (addr->getOp()) { default: - return builder.emitLoad(addr); + { + IRInst* load = builder.emitLoad(addr); + load->sourceLoc = loc; + return load; + } case kIROp_GetElementPtr: case kIROp_FieldAddress: { - IRInst* args[] = { getValue(builder, addr->getOperand(0)), addr->getOperand(1) }; - return builder.emitIntrinsicInst( + IRInst* first = getValue(builder, addr->getOperand(0), loc); + + IRInst* args[] = { first, addr->getOperand(1) }; + IRInst* value = builder.emitIntrinsicInst( cast(addr->getFullType())->getValueType(), (addr->getOp() == kIROp_GetElementPtr ? kIROp_GetElement : kIROp_FieldExtract), - 2, - args); + 2, args); + + first->sourceLoc = loc; + value->sourceLoc = loc; + + return value; } } } - void storeValue(IRBuilder& builder, IRInst* addr, IRInst* val) + void storeValue(IRBuilder& builder, IRInst* addr, IRInst* val, SourceLoc loc) { List accessChain; @@ -53,7 +63,7 @@ struct AddressInstEliminationContext break; } } - endLoop:; + endLoop: auto lastAddr = accessChain.getLast(); accessChain.removeLast(); accessChain.reverse(); @@ -61,11 +71,16 @@ struct AddressInstEliminationContext { auto lastVal = builder.emitLoad(lastAddr); auto update = builder.emitUpdateElement(lastVal, accessChain.getArrayView(), val); - builder.emitStore(lastAddr, update); + auto store = builder.emitStore(lastAddr, update); + + lastVal->sourceLoc = loc; + update->sourceLoc = loc; + store->sourceLoc = loc; } else { - builder.emitStore(lastAddr, val); + auto store = builder.emitStore(lastAddr, val); + store->sourceLoc = loc; } } @@ -76,7 +91,7 @@ struct AddressInstEliminationContext IRBuilder builder(module); builder.setInsertBefore(use->getUser()); - auto value = getValue(builder, addr); + auto value = getValue(builder, addr, load->sourceLoc); load->replaceUsesWith(value); load->removeAndDeallocate(); } @@ -88,7 +103,7 @@ struct AddressInstEliminationContext IRBuilder builder(module); builder.setInsertBefore(use->getUser()); - storeValue(builder, addr, store->getVal()); + storeValue(builder, addr, store->getVal(), store->sourceLoc); store->removeAndDeallocate(); } @@ -110,9 +125,15 @@ struct AddressInstEliminationContext // Store the initial value of the mutable argument into temp var. // If this is an `out` var, the initial value will be undefined, // which will get cleaned up later into a `defaultConstruct`. - builder.emitStore(tempVar, getValue(builder, addr)); + auto value = getValue(builder, addr, call->sourceLoc); + auto store = builder.emitStore(tempVar, value); + auto load = builder.emitLoad(tempVar); + + store->sourceLoc = call->sourceLoc; + load->sourceLoc = call->sourceLoc; + builder.setInsertAfter(call); - storeValue(builder, addr, builder.emitLoad(tempVar)); + storeValue(builder, addr, load, store->sourceLoc); use->set(tempVar); } diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index b2359ed1b8..a4d73f8c01 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -208,6 +208,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns case kIROp_Add: { auto diffAdd = builder->emitAdd(diffType, diffLeft, diffRight); + diffAdd->sourceLoc = origArith->sourceLoc; builder->markInstAsDifferential(diffAdd, resultType); return InstPair(primalArith, diffAdd); @@ -222,6 +223,10 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns auto diffAdd = builder->emitAdd(diffType, diffLeftTimesRight, diffRightTimesLeft); builder->markInstAsDifferential(diffAdd, resultType); + + diffLeftTimesRight->sourceLoc = origArith->sourceLoc; + diffRightTimesLeft->sourceLoc = origArith->sourceLoc; + diffAdd->sourceLoc = origArith->sourceLoc; return InstPair(primalArith, diffAdd); } @@ -229,6 +234,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns case kIROp_Sub: { auto diffSub = builder->emitSub(diffType, diffLeft, diffRight); + diffSub->sourceLoc = origArith->sourceLoc; builder->markInstAsDifferential(diffSub, resultType); return InstPair(primalArith, diffSub); @@ -254,6 +260,8 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns diff = builder->emitDiv(diffType, diffLeft, primalRight); builder->markInstAsDifferential(diff, resultType); } + + diff->sourceLoc = origArith->sourceLoc; return InstPair(primalArith, diff); } else @@ -272,6 +280,12 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns auto diffDiv = builder->emitDiv(diffType, diffSub, diffMul); builder->markInstAsDifferential(diffDiv, resultType); + + diffLeftTimesRight->sourceLoc = origArith->sourceLoc; + diffRightTimesLeft->sourceLoc = origArith->sourceLoc; + diffSub->sourceLoc = origArith->sourceLoc; + diffMul->sourceLoc = origArith->sourceLoc; + diffDiv->sourceLoc = origArith->sourceLoc; return InstPair(primalArith, diffDiv); } @@ -350,9 +364,14 @@ InstPair ForwardDiffTranscriber::transcribeLoad(IRBuilder* builder, IRLoad* orig auto load = builder->emitLoad(primalPtr); builder->markInstAsMixedDifferential(load, diffPairType); + auto diffType = differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, diffPairType); auto primalElement = builder->emitDifferentialPairGetPrimal(load); - auto diffElement = builder->emitDifferentialPairGetDifferential( - (IRType*)differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, diffPairType), load); + auto diffElement = builder->emitDifferentialPairGetDifferential(as(diffType), load); + + load->sourceLoc = origLoad->sourceLoc; + primalElement->sourceLoc = origLoad->sourceLoc; + diffElement->sourceLoc = origLoad->sourceLoc; + return InstPair(primalElement, diffElement); } } @@ -363,6 +382,7 @@ InstPair ForwardDiffTranscriber::transcribeLoad(IRBuilder* builder, IRLoad* orig { // Default case, we're loading from a known differential inst. diffLoad = as(builder->emitLoad(diffPtr)); + diffLoad->sourceLoc = origLoad->sourceLoc; } return InstPair(primalLoad, diffLoad); } @@ -387,6 +407,9 @@ InstPair ForwardDiffTranscriber::transcribeStore(IRBuilder* builder, IRStore* or auto store = builder->emitStore(primalStoreLocation, valToStore); builder->markInstAsMixedDifferential(store, diffPairType); + valToStore->sourceLoc = origStore->sourceLoc; + store->sourceLoc = origStore->sourceLoc; + return InstPair(store, nullptr); } } @@ -402,8 +425,8 @@ InstPair ForwardDiffTranscriber::transcribeStore(IRBuilder* builder, IRStore* or if (diffStoreLocation && diffStoreVal) { // Default case, storing the entire type (and not a member) - diffStore = as( - builder->emitStore(diffStoreLocation, diffStoreVal)); + diffStore = as(builder->emitStore(diffStoreLocation, diffStoreVal)); + diffStore->sourceLoc = origStore->sourceLoc; return InstPair(primalStore, diffStore); } @@ -1165,8 +1188,8 @@ InstPair ForwardDiffTranscriber::transcribeUpdateElement(IRBuilder* builder, IRI auto origVal = updateInst->getElementValue(); auto primalVal = findOrTranscribePrimalInst(builder, origVal); - IRInst* primalUpdateField = - builder->emitUpdateElement(primalBase, primalAccessChain.getArrayView(), primalVal); + IRInst* primalUpdateField = builder->emitUpdateElement(primalBase, primalAccessChain.getArrayView(), primalVal); + primalUpdateField->sourceLoc = originalInst->sourceLoc; IRInst* diffUpdateElement = nullptr; List diffAccessChain; @@ -1351,6 +1374,10 @@ InstPair ForwardDiffTranscriber::transcribeDifferentialPairGetElement(IRBuilder* else diffResultType = diffValPairType->getValueType(); auto diffResult = builder->emitIntrinsicInst((IRType*)diffResultType, origInst->getOp(), 1, &diffVal); + + primalResult->sourceLoc = origInst->sourceLoc; + diffResult->sourceLoc = origInst->sourceLoc; + return InstPair(primalResult, diffResult); } @@ -1609,14 +1636,23 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) auto tempVar = builder.emitVar(ptrType->getValueType()); param->replaceUsesWith(tempVar); mapParamToTempVar[param] = tempVar; + + IRInst* store; + IRInst* value; if (ptrType->getOp() != kIROp_OutType) { - builder.emitStore(tempVar, builder.emitLoad(param)); + value = builder.emitLoad(param); + store = builder.emitStore(tempVar, value); } else { - builder.emitStore(tempVar, builder.emitDefaultConstruct(ptrType->getValueType())); + value = builder.emitDefaultConstruct(ptrType->getValueType()); + store = builder.emitStore(tempVar, value); } + + tempVar->sourceLoc = param->sourceLoc; + store->sourceLoc = param->sourceLoc; + value->sourceLoc = param->sourceLoc; } for (auto block : func->getBlocks()) @@ -1626,8 +1662,12 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) if (inst->getOp() == kIROp_Return) { builder.setInsertBefore(inst); - for (const auto& [param, var] : mapParamToTempVar) - builder.emitStore(param, builder.emitLoad(var)); + for (const auto& [param, var] : mapParamToTempVar) { + auto value = builder.emitLoad(var); + auto store = builder.emitStore(param, value); + value->sourceLoc = inst->sourceLoc; + store->sourceLoc = inst->sourceLoc; + } } } } @@ -1754,6 +1794,8 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr if (writeBack.value.differential) { auto diffVal = builder.emitLoad(writeBack.value.differential); + diffVal->sourceLoc = writeBack.value.differential->sourceLoc; + builder.markInstAsDifferential(diffVal, primalVal->getFullType()); valToStore = builder.emitMakeDifferentialPair(cast(param->getFullType())->getValueType(), @@ -1771,6 +1813,10 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr { builder.markInstAsMixedDifferential(storeInst, valToStore->getFullType()); } + + primalVal->sourceLoc = writeBack.value.primal->sourceLoc; + valToStore->sourceLoc = inst->sourceLoc; + storeInst->sourceLoc = inst->sourceLoc; } } } @@ -2038,6 +2084,7 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam if (auto diffPairType = tryGetDiffPairType(builder, (IRType*)origParam->getFullType())) { IRInst* diffPairParam = builder->emitParam(diffPairType); + diffPairParam->sourceLoc = origParam->sourceLoc; auto diffPairVarName = makeDiffPairName(origParam); if (diffPairVarName.getLength() > 0) @@ -2047,11 +2094,15 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam if (auto pairType = as(diffPairType)) { - return InstPair( - builder->emitDifferentialPairGetPrimal(diffPairParam), - builder->emitDifferentialPairGetDifferential( - (IRType*)differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, pairType), - diffPairParam)); + auto primal = builder->emitDifferentialPairGetPrimal(diffPairParam); + auto differential = builder->emitDifferentialPairGetDifferential( + (IRType*)differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, pairType), + diffPairParam); + + primal->sourceLoc = origParam->sourceLoc; + differential->sourceLoc = origParam->sourceLoc; + + return InstPair(primal, differential); } else if (auto pairPtrType = as(diffPairType)) { @@ -2074,19 +2125,28 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam else { auto initVal = builder->emitLoad(diffPairParam); + initVal->sourceLoc = origParam->sourceLoc; + builder->markInstAsMixedDifferential(initVal, ptrInnerPairType); primalInitVal = builder->emitDifferentialPairGetPrimal(initVal); diffInitVal = builder->emitDifferentialPairGetDifferential(diffType, initVal); + + primalInitVal->sourceLoc = origParam->sourceLoc; + diffInitVal->sourceLoc = origParam->sourceLoc; } builder->markInstAsDifferential(diffInitVal, ptrInnerPairType->getValueType()); - - builder->emitStore(primal, primalInitVal); - + auto primalStore = builder->emitStore(primal, primalInitVal); auto diffStore = builder->emitStore(diff, diffInitVal); builder->markInstAsDifferential(diffStore, ptrInnerPairType->getValueType()); mapInOutParamToWriteBackValue[diffPairParam] = InstPair(primal, diff); + + primal->sourceLoc = origParam->sourceLoc; + diff->sourceLoc = origParam->sourceLoc; + primalStore->sourceLoc = origParam->sourceLoc; + diffStore->sourceLoc = origParam->sourceLoc; + return InstPair(primal, diff); } } diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index fae4b7fceb..62db217b3e 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -403,6 +403,7 @@ namespace Slang List primalTypes, propagateTypes; IRType* primalResultType = transcribeParamTypeForPrimalFunc(&builder, origFuncType->getResultType()); + IRParam *currentParam = origFunc->getFirstParam(); for (UInt i = 0; i < origFuncType->getParamCount(); i++) { auto primalParamType = transcribeParamTypeForPrimalFunc(&builder, origFuncType->getParamType(i)); @@ -410,6 +411,8 @@ namespace Slang if (propagateParamType) { auto param = builder.emitParam(propagateParamType); + param->sourceLoc = currentParam->sourceLoc; + propagateTypes.add(propagateParamType); propagateArgs.add(param); @@ -432,10 +435,12 @@ namespace Slang { // If primal parameter is mutable, we need to pass in a temp var. auto tempVar = builder.emitVar(primalParamPtrType->getValueType()); + tempVar->sourceLoc = currentParam->sourceLoc; if (primalParamPtrType->getOp() == kIROp_InOutType) { // If the primal parameter is inout, we need to set the initial value. - builder.emitStore(tempVar, primalArg); + auto store = builder.emitStore(tempVar, primalArg); + store->sourceLoc = currentParam->sourceLoc; } primalArgs.add(tempVar); } @@ -450,9 +455,11 @@ namespace Slang SLANG_RELEASE_ASSERT(primalPtrType); auto primalValueType = primalPtrType->getValueType(); auto var = builder.emitVar(primalValueType); + var->sourceLoc = currentParam->sourceLoc; primalArgs.add(var); } primalTypes.add(primalParamType); + currentParam = currentParam->getNextParam(); } // Add dOut argument to propagateArgs. @@ -928,6 +935,8 @@ namespace Slang { // Create dOut param. auto diffParam = builder->emitParam(diffType); + diffParam->sourceLoc = fwdParam->sourceLoc; + copyNameHintAndDebugDecorations(diffParam, fwdParam); result.propagateFuncParams.add(diffParam); primalRefReplacement = builder->emitParam(builder->getOutType(primalType)); @@ -960,6 +969,7 @@ namespace Slang // Create a local var for the out param for the primal part of the prop func. auto tempPrimalVar = nextBlockBuilder.emitVar(outType->getValueType()); + tempPrimalVar->sourceLoc = fwdParam->sourceLoc; copyNameHintAndDebugDecorations(tempPrimalVar, fwdParam); result.mapPrimalSpecificParamToReplacementInPropFunc[primalRefReplacement] = tempPrimalVar; @@ -985,6 +995,7 @@ namespace Slang // Create a local var for the out param for the primal part of the prop func. auto tempPrimalVar = nextBlockBuilder.emitVar(inoutType->getValueType()); + tempPrimalVar->sourceLoc = fwdParam->sourceLoc; copyNameHintAndDebugDecorations(tempPrimalVar, fwdParam); result.propagateFuncSpecificPrimalInsts.add(tempPrimalVar); @@ -1020,10 +1031,15 @@ namespace Slang auto propParam = builder->emitParam(inoutDiffPairType); copyNameHintAndDebugDecorations(propParam, fwdParam); result.propagateFuncParams.add(propParam); + + primalRefReplacement->sourceLoc = fwdParam->sourceLoc; + propParam->sourceLoc = fwdParam->sourceLoc; // A reference to this parameter from the diff blocks should be replaced with a load // of the differential component of the pair. auto newParamLoad = diffBuilder.emitLoad(propParam); + newParamLoad->sourceLoc = fwdParam->sourceLoc; + diffBuilder.markInstAsDifferential(newParamLoad, primalType); result.propagateFuncSpecificPrimalInsts.add(newParamLoad); @@ -1056,6 +1072,9 @@ namespace Slang auto diffParam = builder->emitParam(inoutType); copyNameHintAndDebugDecorations(diffParam, fwdParam); result.propagateFuncParams.add(diffParam); + + primalParam->sourceLoc = fwdParam->sourceLoc; + diffParam->sourceLoc = fwdParam->sourceLoc; // Primal references to this param is the new primal param. primalRefReplacement = primalParam; @@ -1065,6 +1084,7 @@ namespace Slang // Load the inital diff value. auto loadedParam = nextBlockBuilder.emitLoad(diffParam); + loadedParam->sourceLoc = fwdParam->sourceLoc; result.propagateFuncSpecificPrimalInsts.add(loadedParam); auto initDiff = nextBlockBuilder.emitDifferentialPairGetDifferential(diffType, loadedParam); diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp index 75db5f56ad..41f4bfe3dd 100644 --- a/source/slang/slang-ir-autodiff-transcriber-base.cpp +++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp @@ -505,6 +505,7 @@ InstPair AutoDiffTranscriberBase::transcribeParam(IRBuilder* builder, IRParam* o if (IRType* diffType = differentiateType(builder, (IRType*)origParam->getDataType())) { diff = builder->emitParam(diffType); + diff->sourceLoc = origParam->sourceLoc; } return InstPair(primal, diff); } diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h index d42462e1ba..66ed07ad7b 100644 --- a/source/slang/slang-ir-autodiff-transpose.h +++ b/source/slang/slang-ir-autodiff-transpose.h @@ -616,7 +616,10 @@ struct DiffTransposePass varInst->insertAtEnd(firstRevDiffBlock); auto dzero = emitDZeroOfDiffInstType(&builder, ptrPrimalType->getValueType()); - builder.emitStore(varInst, dzero); + auto store = builder.emitStore(varInst, dzero); + + dzero->sourceLoc = varInst->sourceLoc; + store->sourceLoc = varInst->sourceLoc; } else { @@ -706,6 +709,8 @@ struct DiffTransposePass if (auto accVar = getOrCreateAccumulatorVar(fwdInst)) { auto gradValue = builder->emitLoad(accVar); + gradValue->sourceLoc = fwdInst->sourceLoc; + builder->emitStore( accVar, emitDZeroOfDiffInstType( @@ -747,9 +752,12 @@ struct DiffTransposePass // Emit a var in the top-level differential block to hold the gradient, // and initialize it. auto tempRevVar = tempVarBuilder.emitVar(diffType); - tempVarBuilder.emitStore(tempRevVar, zero); + auto tempRevStore = tempVarBuilder.emitStore(tempRevVar, zero); revAccumulatorVarMap[fwdInst] = tempRevVar; + tempRevVar->sourceLoc = fwdInst->sourceLoc; + tempRevStore->sourceLoc = fwdInst->sourceLoc; + return tempRevVar; } @@ -793,6 +801,7 @@ struct DiffTransposePass auto diffType = arg->getDataType(); auto revParam = builder.emitParam(diffType); + revParam->sourceLoc = arg->sourceLoc; addRevGradientForFwdInst( arg, @@ -953,7 +962,9 @@ struct DiffTransposePass // into one inst. // auto gradients = popRevGradients(externInst); - gradients.add(RevGradient(externInst, builder.emitLoad(accVar), nullptr)); + auto loaded = builder.emitLoad(accVar); + loaded->sourceLoc = externInst->sourceLoc; + gradients.add(RevGradient(externInst, loaded, nullptr)); auto gradInst = emitAggregateValue( &builder, @@ -1145,7 +1156,14 @@ struct DiffTransposePass auto diffVal = builder->emitLoad(instPair->getDiff()); auto pairVal = builder->emitMakeDifferentialPair(pairType, primalVal, diffVal); - builder->emitStore(tempVar, pairVal); + auto store = builder->emitStore(tempVar, pairVal); + + tempVar->sourceLoc = fwdCall->sourceLoc; + primalVal->sourceLoc = fwdCall->sourceLoc; + diffVal->sourceLoc = fwdCall->sourceLoc; + pairVal->sourceLoc = fwdCall->sourceLoc; + store->sourceLoc = fwdCall->sourceLoc; + args.add(tempVar); argTypes.add(builder->getInOutType(pairType)); argRequiresLoad.add(false); @@ -1163,16 +1181,20 @@ struct DiffTransposePass auto pairType = as(arg->getDataType()); auto var = builder->emitVar(arg->getDataType()); - auto diffZero = emitDZeroOfDiffInstType(builder, pairType->getValueType()); // Initialize this var to (arg.primal, 0). - builder->emitStore( - var, - builder->emitMakeDifferentialPair( + auto diffPair = builder->emitMakeDifferentialPair( arg->getDataType(), makePairArg->getPrimalValue(), - diffZero)); + diffZero); + + auto storeInit = builder->emitStore(var, diffPair); + + var->sourceLoc = fwdCall->sourceLoc; + diffZero->sourceLoc = fwdCall->sourceLoc; + diffPair->sourceLoc = fwdCall->sourceLoc; + storeInit->sourceLoc = fwdCall->sourceLoc; args.add(var); argTypes.add(builder->getInOutType(pairType)); @@ -1216,11 +1238,10 @@ struct DiffTransposePass auto primalContextVar = primalContextDecor->getBackwardDerivativePrimalContextVar(); auto contextLoad = builder->emitLoad(primalContextVar); + contextLoad->sourceLoc = fwdCall->sourceLoc; args.add(contextLoad); - argTypes.add(as( - primalContextVar->getDataType()) - ->getValueType()); + argTypes.add(as(primalContextVar->getDataType())->getValueType()); argRequiresLoad.add(false); } @@ -1266,6 +1287,8 @@ struct DiffTransposePass for (auto wb : writebacks) { auto loadedPair = builder->emitLoad(wb.srcTempPairVar); + loadedPair->sourceLoc = fwdCall->sourceLoc; + auto diffType = as(wb.destVar->getDataType())->getValueType(); auto loadedDiff = builder->emitDifferentialPairGetDifferential(diffType, loadedPair); builder->emitStore(wb.destVar, loadedDiff); @@ -1288,11 +1311,17 @@ struct DiffTransposePass auto diffArgType = (IRType*)diffTypeContext.getDifferentialForType( builder, diffPairType->getValueType()); + + auto loaded = builder->emitLoad(args[ii]); + loaded->sourceLoc = fwdCall->sourceLoc; + + auto diffPairGet = builder->emitDifferentialPairGetDifferential(diffArgType, loaded); + diffPairGet->sourceLoc = fwdCall->sourceLoc; + gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdCall->getArg(ii), - builder->emitDifferentialPairGetDifferential( - diffArgType, builder->emitLoad(args[ii])), + diffPairGet, nullptr)); } } @@ -1549,6 +1578,7 @@ struct DiffTransposePass { // Re-emit a load to get the _current_ value of revPtr. auto revCurrGrad = builder->emitLoad(revPtr); + revCurrGrad->sourceLoc = fwdLoad->sourceLoc; // Add the current value to the aggregation list. gradients.add(RevGradient( @@ -1594,7 +1624,11 @@ struct DiffTransposePass // Clear the value at the differential address, by setting to 0. IRInst* emptyVal = emitDZeroOfDiffInstType(builder, primalType); - builder->emitStore(fwdStore->getPtr(), emptyVal); + IRInst* storeInst = builder->emitStore(fwdStore->getPtr(), emptyVal); + + revVal->sourceLoc = fwdStore->sourceLoc; + emptyVal->sourceLoc = fwdStore->sourceLoc; + storeInst->sourceLoc = fwdStore->sourceLoc; if (auto diffPairType = as(revVal->getDataType())) { @@ -2018,6 +2052,10 @@ struct DiffTransposePass revValue, accessChain.getArrayView(), diffZero); + + diffZero->sourceLoc = fwdUpdate->sourceLoc; + revRest->sourceLoc = fwdUpdate->sourceLoc; + gradients.add(RevGradient( RevGradient::Flavor::Simple, updateInst->getOldValue(), @@ -2316,6 +2354,11 @@ struct DiffTransposePass kIROp_Select, 3, List(primalCondition, rightZero, revValue).getBuffer()); + + leftZero->sourceLoc = fwdInst->sourceLoc; + leftGradientInst->sourceLoc = fwdInst->sourceLoc; + rightZero->sourceLoc = fwdInst->sourceLoc; + rightGradientInst->sourceLoc = fwdInst->sourceLoc; return TranspositionResult( List( @@ -2692,11 +2735,14 @@ struct DiffTransposePass builder->emitStore(revGradTargetAddress, emitAggregateValue(builder, primalType, subGrads)); } + auto loadedRevGradVar = builder->emitLoad(revGradVar); + loadedRevGradVar->sourceLoc = revGradVar->sourceLoc; + // Load the entire var and return it. return RevGradient( RevGradient::Flavor::Simple, gradients[0].targetInst, - builder->emitLoad(revGradVar), + loadedRevGradVar, nullptr); } @@ -2757,12 +2803,15 @@ struct DiffTransposePass builder->emitStore(revGradTargetAddress, emitAggregateValue(builder, primalType, subGrads)); } + + auto loadedRevGradVar = builder->emitLoad(revGradVar); + loadedRevGradVar->sourceLoc = revGradVar->sourceLoc; // Load the entire var and return it. return RevGradient( RevGradient::Flavor::Simple, gradients[0].targetInst, - builder->emitLoad(revGradVar), + loadedRevGradVar, nullptr); } From 0c17bcf1705cbe95bf07fed46d5bc14f8938f4c2 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Tue, 17 Sep 2024 17:54:14 -0700 Subject: [PATCH 19/32] Fix ordering in address elimination --- source/slang/slang-diagnostic-defs.h | 1 + source/slang/slang-emit.cpp | 7 ++++++- source/slang/slang-ir-addr-inst-elimination.cpp | 8 ++++---- source/slang/slang-ir-autodiff-unzip.h | 7 +++++++ tests/autodiff/reverse-checkpoint-1.slang | 2 +- tests/autodiff/reverse-continue-loop.slang | 6 +++--- tests/autodiff/reverse-loop-checkpoint-test.slang | 6 +++--- tests/autodiff/reverse-loop.slang | 6 +++--- tests/autodiff/reverse-nested-calls.slang | 2 +- 9 files changed, 29 insertions(+), 16 deletions(-) diff --git a/source/slang/slang-diagnostic-defs.h b/source/slang/slang-diagnostic-defs.h index ac9386cd29..e0f1e90c5c 100644 --- a/source/slang/slang-diagnostic-defs.h +++ b/source/slang/slang-diagnostic-defs.h @@ -898,6 +898,7 @@ DIAGNOSTIC(58003, Error, inconsistentPointerAddressSpace, "'$0': use of pointer DIAGNOSTIC(-1, Note, reportCheckpointIntermediates, "checkpointing context of $1 bytes associated with function: '$0'") DIAGNOSTIC(-1, Note, reportCheckpointVariable, "$0 bytes ($1) used to checkpoint the following item:") DIAGNOSTIC(-1, Note, reportCheckpointCounter, "$0 bytes ($1) used for a loop counter here:") +DIAGNOSTIC(-1, Note, reportCheckpointNone, "no checkpoint contexts to report") // // 8xxxx - Issues specific to a particular library/technology/platform/etc. diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index e04ab42a6b..6e3556064e 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -227,8 +227,9 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno description.codeGenContext = codeGenContext; description.sourceWriter = &typeWriter; - GLSLSourceEmitter emitter(description); + CPPSourceEmitter emitter(description); + int nonEmptyStructs = 0; for (auto inst : irModule->getGlobalInsts()) { IRStructType *structType = as(inst); @@ -250,6 +251,7 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno auto func = checkpointDecoration->getSourceFunction(); sink->diagnose(structType, Diagnostics::reportCheckpointIntermediates, func, structSize.size); + nonEmptyStructs++; for (auto field : structType->getFields()) { @@ -270,6 +272,9 @@ static void reportCheckpointIntermediates(CodeGenContext* codeGenContext, Diagno typeWriter.getContent()); } } + + if (nonEmptyStructs == 0) + sink->diagnose(SourceLoc(), Diagnostics::reportCheckpointNone); } struct LinkingAndOptimizationOptions diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp index 30cbdcfbf8..2aa23c77b1 100644 --- a/source/slang/slang-ir-addr-inst-elimination.cpp +++ b/source/slang/slang-ir-addr-inst-elimination.cpp @@ -127,14 +127,14 @@ struct AddressInstEliminationContext // which will get cleaned up later into a `defaultConstruct`. auto value = getValue(builder, addr, call->sourceLoc); auto store = builder.emitStore(tempVar, value); + + builder.setInsertAfter(call); auto load = builder.emitLoad(tempVar); + storeValue(builder, addr, load, call->sourceLoc); + use->set(tempVar); store->sourceLoc = call->sourceLoc; load->sourceLoc = call->sourceLoc; - - builder.setInsertAfter(call); - storeValue(builder, addr, load, store->sourceLoc); - use->set(tempVar); } SlangResult eliminateAddressInstsImpl( diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index 32bfe986b7..de8d0014d3 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -91,8 +91,12 @@ struct DiffUnzipPass IRInst* diffType = diffTypeContext.getDiffTypeFromPairType(builder, pairType); if (as(primalParam->getFullType())) diffType = builder->getPtrType(primalParam->getFullType()->getOp(), (IRType*)diffType); + auto primalRef = builder->emitPrimalParamRef(primalParam); auto diffRef = builder->emitDiffParamRef((IRType*)diffType, primalParam); + primalRef->sourceLoc = primalParam->sourceLoc; + diffRef->sourceLoc = primalParam->sourceLoc; + builder->markInstAsDifferential(diffRef, pairType->getValueType()); primalMap[primalParam] = primalRef; diffMap[primalParam] = diffRef; @@ -427,6 +431,7 @@ struct DiffUnzipPass { diffVal = diffBuilder->emitDifferentialPairGetDifferential(diffType, callInst); diffBuilder->markInstAsDifferential(diffVal, primalType); + diffVal->sourceLoc = callInst->sourceLoc; } return InstPair(primalVal, diffVal); } @@ -442,6 +447,8 @@ struct DiffUnzipPass auto diffPtr = lookupDiffInst(mixedLoad->getPtr()); auto primalVal = primalBuilder->emitLoad(primalPtr); auto diffVal = diffBuilder->emitLoad(diffPtr); + primalVal->sourceLoc = mixedLoad->sourceLoc; + diffVal->sourceLoc = mixedLoad->sourceLoc; diffBuilder->markInstAsDifferential(diffVal, primalVal->getFullType()); return InstPair(primalVal, diffVal); } diff --git a/tests/autodiff/reverse-checkpoint-1.slang b/tests/autodiff/reverse-checkpoint-1.slang index cd93db1a6e..3d6e9e702f 100644 --- a/tests/autodiff/reverse-checkpoint-1.slang +++ b/tests/autodiff/reverse-checkpoint-1.slang @@ -17,7 +17,7 @@ float g(float x) return log(x); } -//CHK: note: checkpointing context of 4 bytes was generated for function: 'f' +//CHK: note: checkpointing context of 4 bytes associated with function: 'f' [BackwardDifferentiable] float f(int p, float x) { diff --git a/tests/autodiff/reverse-continue-loop.slang b/tests/autodiff/reverse-continue-loop.slang index 65abcb7a47..0b6e56f783 100644 --- a/tests/autodiff/reverse-continue-loop.slang +++ b/tests/autodiff/reverse-continue-loop.slang @@ -9,14 +9,14 @@ RWStructuredBuffer outputBuffer; typedef DifferentialPair dpfloat; typedef float.Differential dfloat; -//CHK: note: checkpointing context of 24 bytes was generated for function: 'test_loop_with_continue' +//CHK: note: checkpointing context of 24 bytes associated with function: 'test_loop_with_continue' [BackwardDifferentiable] float test_loop_with_continue(float y) { - //CHK: note: 20 bytes (float [5]) used to checkpoint the following item: + //CHK: note: 20 bytes (FixedArray ) used to checkpoint the following item: float t = y; - //CHK: note: 4 bytes (int) used for a loop counter here: + //CHK: note: 4 bytes (int32_t) used for a loop counter here: for (int i = 0; i < 3; i++) { if (t > 4.0) diff --git a/tests/autodiff/reverse-loop-checkpoint-test.slang b/tests/autodiff/reverse-loop-checkpoint-test.slang index 15afbad805..68ad823ac2 100644 --- a/tests/autodiff/reverse-loop-checkpoint-test.slang +++ b/tests/autodiff/reverse-loop-checkpoint-test.slang @@ -45,7 +45,7 @@ float3 infinitesimal(float3 x) return x - detach(x); } -//CHK: note: checkpointing context of 20 bytes was generated for function: 'computeLoop' +//CHK: note: checkpointing context of 20 bytes associated with function: 'computeLoop' [BackwardDifferentiable] [PreferRecompute] float3 computeLoop(float y) @@ -53,10 +53,10 @@ float3 computeLoop(float y) //CHK: note: 4 bytes (float) used to checkpoint the following item: float w = 0; - //CHK: note: 12 bytes (vec3) used to checkpoint the following item: + //CHK: note: 12 bytes (Vector ) used to checkpoint the following item: float3 w3 = float3(0, 0, 0); - //CHK: note: 4 bytes (int) used for a loop counter here: + //CHK: note: 4 bytes (int32_t) used for a loop counter here: for (int i = 0; i < 8; i++) { float k = compute(i, y); diff --git a/tests/autodiff/reverse-loop.slang b/tests/autodiff/reverse-loop.slang index bdd040cf8a..2ba8535bee 100644 --- a/tests/autodiff/reverse-loop.slang +++ b/tests/autodiff/reverse-loop.slang @@ -9,14 +9,14 @@ RWStructuredBuffer outputBuffer; typedef DifferentialPair dpfloat; typedef float.Differential dfloat; -//CHK: note: checkpointing context of 24 bytes was generated for function: 'test_simple_loop' +//CHK: note: checkpointing context of 24 bytes associated with function: 'test_simple_loop' [Differentiable] float test_simple_loop(float y) { - //CHK: note: 20 bytes (float [5]) used to checkpoint the following item: + //CHK: note: 20 bytes (FixedArray ) used to checkpoint the following item: float t = y; - //CHK: note: 4 bytes (int) used for a loop counter here: + //CHK: note: 4 bytes (int32_t) used for a loop counter here: for (int i = 0; i < 3; i++) { t = t * t; diff --git a/tests/autodiff/reverse-nested-calls.slang b/tests/autodiff/reverse-nested-calls.slang index f87e941576..3c1a52c21c 100644 --- a/tests/autodiff/reverse-nested-calls.slang +++ b/tests/autodiff/reverse-nested-calls.slang @@ -16,7 +16,7 @@ float g(float y) return result * result; } -//CHK: note: checkpointing context of 4 bytes was generated for function: 'f' +//CHK: note: checkpointing context of 4 bytes associated with function: 'f' [BackwardDifferentiable] float f(float x) { From 62f211589f389c9424c0fce119e5606f0780de26 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 11:37:43 -0700 Subject: [PATCH 20/32] Fill in more holes with source location transfer --- .../slang/slang-ir-addr-inst-elimination.cpp | 1 + source/slang/slang-ir-autodiff-fwd.cpp | 57 +++++++--- .../slang/slang-ir-autodiff-primal-hoist.cpp | 33 ++++-- source/slang/slang-ir-autodiff-rev.cpp | 71 +++++++++--- source/slang/slang-ir-autodiff-rev.h | 1 + source/slang/slang-ir-autodiff-transpose.h | 104 ++++++++++++------ source/slang/slang-ir-autodiff-unzip.cpp | 15 ++- source/slang/slang-ir-autodiff-unzip.h | 33 +++++- source/slang/slang-ir-init-local-var.cpp | 12 +- tests/autodiff/reverse-control-flow-1.slang | 3 + tests/autodiff/reverse-control-flow-2.slang | 3 + tests/autodiff/reverse-control-flow-3.slang | 11 +- 12 files changed, 260 insertions(+), 84 deletions(-) diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp index 2aa23c77b1..154cff7cb0 100644 --- a/source/slang/slang-ir-addr-inst-elimination.cpp +++ b/source/slang/slang-ir-addr-inst-elimination.cpp @@ -133,6 +133,7 @@ struct AddressInstEliminationContext storeValue(builder, addr, load, call->sourceLoc); use->set(tempVar); + tempVar->sourceLoc = addr->sourceLoc; store->sourceLoc = call->sourceLoc; load->sourceLoc = call->sourceLoc; } diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index a4d73f8c01..bffe27abad 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -526,10 +526,11 @@ InstPair ForwardDiffTranscriber::transcribeMakeStruct(IRBuilder* builder, IRInst auto operandDataType = origMakeStruct->getOperand(ii)->getDataType(); auto diffOperandType = differentiateType(builder, operandDataType); + IRInst* dzero; if (diffOperandType) { operandDataType = (IRType*)findOrTranscribePrimalInst(builder, operandDataType); - diffOperands.add(getDifferentialZeroOfType(builder, operandDataType)); + dzero = getDifferentialZeroOfType(builder, operandDataType); } else { @@ -539,19 +540,22 @@ InstPair ForwardDiffTranscriber::transcribeMakeStruct(IRBuilder* builder, IRInst // auto diffFieldOperandType = differentiateType(builder, field->getFieldType()); SLANG_RELEASE_ASSERT(diffFieldOperandType); - diffOperands.add(getDifferentialZeroOfType(builder, (IRType*)diffFieldOperandType)); + dzero = getDifferentialZeroOfType(builder, as(diffFieldOperandType)); } + + dzero->sourceLoc = origMakeStruct->sourceLoc; + diffOperands.add(dzero); } ii++; } - return InstPair( - primalMakeStruct, - builder->emitIntrinsicInst( + auto diffMakeStruct = builder->emitIntrinsicInst( diffStructType, kIROp_MakeStruct, diffOperands.getCount(), - diffOperands.getBuffer())); + diffOperands.getBuffer()); + + return InstPair(primalMakeStruct, diffMakeStruct); } else { @@ -669,9 +673,10 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig // If the function is marked for auto-diff, push a `differentiate` inst for a follow up pass // to generate the implementation. diffCallee = builder->emitForwardDifferentiateInst( - differentiateFunctionType( - builder, primalCallee, as(primalCallee->getFullType())), + differentiateFunctionType(builder, primalCallee, as(primalCallee->getFullType())), primalCallee); + + diffCallee->sourceLoc = origCall->sourceLoc; } if (!diffCallee) @@ -690,6 +695,8 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig SLANG_RELEASE_ASSERT(diffCalleeType->getParamCount() == origCall->getArgCount()); auto placeholderCall = builder->emitCallInst(nullptr, builder->emitUndefined(builder->getTypeKind()), 0, nullptr); + placeholderCall->sourceLoc = origCall->sourceLoc; + builder->setInsertBefore(placeholderCall); IRBuilder argBuilder = *builder; IRBuilder afterBuilder = argBuilder; @@ -726,6 +733,8 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig { // Create temp var to pass in/out arguments. auto srcVar = argBuilder.emitVar(pairValType); + srcVar->sourceLoc = origCall->sourceLoc; + argBuilder.markInstAsMixedDifferential(srcVar, pairValType->getValueType()); auto diffArg = findOrTranscribeDiffInst(&argBuilder, origArg); @@ -733,17 +742,23 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig { // Set initial value. auto primalVal = argBuilder.emitLoad(primalArg); + primalVal->sourceLoc = origCall->sourceLoc; + auto diffArgVal = diffArg; if (!diffArg) diffArgVal = getDifferentialZeroOfType(builder, (IRType*)pairValType->getValueType()); else { diffArgVal = argBuilder.emitLoad(diffArg); + diffArgVal->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsDifferential(diffArgVal, pairValType->getValueType()); } auto initVal = argBuilder.emitMakeDifferentialPair(pairValType, primalVal, diffArgVal); + initVal->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsMixedDifferential(initVal, primalType); + auto store = argBuilder.emitStore(srcVar, initVal); + store->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsMixedDifferential(store, primalType); } if (as(ptrParamType)) @@ -751,16 +766,23 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig // Read back new value. auto newVal = afterBuilder.emitLoad(srcVar); afterBuilder.markInstAsMixedDifferential(newVal, pairValType->getValueType()); + newVal->sourceLoc = origCall->sourceLoc; + auto newPrimalVal = afterBuilder.emitDifferentialPairGetPrimal(pairValType->getValueType(), newVal); - afterBuilder.emitStore(primalArg, newPrimalVal); + newPrimalVal->sourceLoc = origCall->sourceLoc; + + auto store = afterBuilder.emitStore(primalArg, newPrimalVal); + store->sourceLoc = origCall->sourceLoc; if (diffArg) { auto newDiffVal = afterBuilder.emitDifferentialPairGetDifferential((IRType*)diffType, newVal); afterBuilder.markInstAsDifferential(newDiffVal, pairValType->getValueType()); + newDiffVal->sourceLoc = origCall->sourceLoc; auto storeInst = afterBuilder.emitStore(diffArg, newDiffVal); afterBuilder.markInstAsDifferential(storeInst, pairValType->getValueType()); + storeInst->sourceLoc = origCall->sourceLoc; } } args.add(srcVar); @@ -776,6 +798,8 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig SLANG_RELEASE_ASSERT(diffArg); auto diffPair = argBuilder.emitMakeDifferentialPair(pairType, primalArg, diffArg); + diffPair->sourceLoc = origCall->sourceLoc; + argBuilder.markInstAsMixedDifferential(diffPair, pairType); args.add(diffPair); @@ -811,9 +835,11 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig if (diffReturnType->getOp() == kIROp_DifferentialPairType) { - IRInst* primalResultValue = afterBuilder.emitDifferentialPairGetPrimal(callInst); auto diffType = differentiateType(&afterBuilder, origCall->getFullType()); + IRInst* primalResultValue = afterBuilder.emitDifferentialPairGetPrimal(callInst); IRInst* diffResultValue = afterBuilder.emitDifferentialPairGetDifferential(diffType, callInst); + primalResultValue->sourceLoc = origCall->sourceLoc; + diffResultValue->sourceLoc = origCall->sourceLoc; return InstPair(primalResultValue, diffResultValue); } else @@ -1221,20 +1247,21 @@ InstPair ForwardDiffTranscriber::transcribeUpdateElement(IRBuilder* builder, IRI if (auto diffVal = findOrTranscribeDiffInst(builder, origVal)) { auto primalElementType = primalVal->getDataType(); - - diffUpdateElement = builder->emitUpdateElement( - diffBase, diffAccessChain.getArrayView(), diffVal); + diffUpdateElement = builder->emitUpdateElement(diffBase, diffAccessChain.getArrayView(), diffVal); builder->addPrimalElementTypeDecoration(diffUpdateElement, primalElementType); } else { auto primalElementType = primalVal->getDataType(); auto zeroElementDiff = getDifferentialZeroOfType(builder, primalElementType); - diffUpdateElement = builder->emitUpdateElement( - diffBase, diffAccessChain.getArrayView(), zeroElementDiff); + zeroElementDiff->sourceLoc = originalInst->sourceLoc; + + diffUpdateElement = builder->emitUpdateElement(diffBase, diffAccessChain.getArrayView(), zeroElementDiff); builder->addPrimalElementTypeDecoration(diffUpdateElement, primalElementType); } } + + diffUpdateElement->sourceLoc = originalInst->sourceLoc; return InstPair(primalUpdateField, diffUpdateElement); } diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index 163f50a2df..4171a9bde9 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -1092,7 +1092,8 @@ IRType* getTypeForLocalStorage( IRVar* emitIndexedLocalVar( IRBlock* varBlock, IRType* baseType, - const List& defBlockIndices) + const List& defBlockIndices, + SourceLoc location) { // Cannot store pointers. Case should have been handled by now. SLANG_RELEASE_ASSERT(!as(baseType)); @@ -1106,7 +1107,12 @@ IRVar* emitIndexedLocalVar( IRType* varType = getTypeForLocalStorage(&varBuilder, baseType, defBlockIndices); auto var = varBuilder.emitVar(varType); - varBuilder.emitStore(var, varBuilder.emitDefaultConstruct(varType)); + auto defaultVal = varBuilder.emitDefaultConstruct(varType); + auto storeInit = varBuilder.emitStore(var, defaultVal); + + var->sourceLoc = location; + defaultVal->sourceLoc = location; + storeInit->sourceLoc = location; return var; } @@ -1114,7 +1120,8 @@ IRVar* emitIndexedLocalVar( IRInst* emitIndexedStoreAddressForVar( IRBuilder* builder, IRVar* localVar, - const List& defBlockIndices) + const List& defBlockIndices, + SourceLoc location) { IRInst* storeAddr = localVar; for (auto& index : defBlockIndices) @@ -1122,6 +1129,8 @@ IRInst* emitIndexedStoreAddressForVar( storeAddr = builder->emitElementAddress( storeAddr, index.primalCountParam); + + storeAddr->sourceLoc = location; } return storeAddr; @@ -1179,11 +1188,18 @@ IRVar* storeIndexedValue( IRInst* instToStore, const List& defBlockIndices) { - IRVar* localVar = emitIndexedLocalVar(defaultVarBlock, instToStore->getDataType(), defBlockIndices); + IRVar* localVar = emitIndexedLocalVar(defaultVarBlock, + instToStore->getDataType(), + defBlockIndices, + instToStore->sourceLoc); - IRInst* addr = emitIndexedStoreAddressForVar(builder, localVar, defBlockIndices); + IRInst* addr = emitIndexedStoreAddressForVar(builder, + localVar, + defBlockIndices, + instToStore->sourceLoc); - builder->emitStore(addr, instToStore); + auto store = builder->emitStore(addr, instToStore); + store->sourceLoc = instToStore->sourceLoc; return localVar; } @@ -1574,11 +1590,14 @@ RefPtr ensurePrimalAvailability( // region, that means there's no need to allocate a fully indexed var. // defBlockIndices = maybeTrimIndices(defBlockIndices, indexedBlockInfo, outOfScopeUses); + + auto load = builder.emitLoad(varToStore); + load->sourceLoc = varToStore->sourceLoc; IRVar* localVar = storeIndexedValue( &builder, varBlock, - builder.emitLoad(varToStore), + load, defBlockIndices); for (auto use : outOfScopeUses) diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index 62db217b3e..f81ba87728 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -589,12 +589,13 @@ namespace Slang // reversible. if (SLANG_FAILED(prepareFuncForBackwardDiff(primalFunc))) return diffPropagateFunc; - + // Forward transcribe the clone of the original func. ForwardDiffTranscriber& fwdTranscriber = *static_cast( autoDiffSharedContext->transcriberSet.forwardTranscriber); auto oldCount = autoDiffSharedContext->followUpFunctionsToTranscribe.getCount(); IRFunc* fwdDiffFunc = as(getGenericReturnVal(fwdTranscriber.transcribe(builder, primalOuterParent))); + fwdDiffFunc->sourceLoc = primalFunc->sourceLoc; SLANG_ASSERT(fwdDiffFunc); auto newCount = autoDiffSharedContext->followUpFunctionsToTranscribe.getCount(); @@ -689,7 +690,8 @@ namespace Slang { tempBuilder.setInsertBefore(diffPropagateFunc); } - + + auto hint = primalFunc->findDecoration()->getName().begin(); auto fwdDiffFunc = generateNewForwardDerivativeForFunc(&tempBuilder, primalFunc, diffPropagateFunc); if (!fwdDiffFunc) return; @@ -720,8 +722,10 @@ namespace Slang } // Transpose the first block (parameter block) - auto paramTransposeInfo = - splitAndTransposeParameterBlock(builder, diffPropagateFunc, isResultDifferentiable); + auto paramTransposeInfo = splitAndTransposeParameterBlock(builder, + diffPropagateFunc, + primalFunc->sourceLoc, + isResultDifferentiable); // The insts we inserted in paramTransposeInfo.mapPrimalSpecificParamToReplacementInPropFunc // may be used by write back logic that we are going to insert later. @@ -823,6 +827,7 @@ namespace Slang ParameterBlockTransposeInfo BackwardDiffTranscriberBase::splitAndTransposeParameterBlock( IRBuilder* builder, IRFunc* diffFunc, + SourceLoc primalLoc, bool isResultDifferentiable) { // This method splits transposes the all the parameters for both the primal and propagate computation. @@ -849,6 +854,7 @@ namespace Slang auto nextBlockBuilder = *builder; nextBlockBuilder.setInsertBefore(paramPreludeBlock->getFirstOrdinaryInst()); + SourceLoc returnLoc; IRBlock* firstDiffBlock = nullptr; for (auto block : diffFunc->getBlocks()) { @@ -857,6 +863,12 @@ namespace Slang firstDiffBlock = block; break; } + + auto terminator = block->getTerminator(); + if (as(terminator)) { + returnLoc = terminator->sourceLoc; + break; + } } SLANG_RELEASE_ASSERT(firstDiffBlock); @@ -935,8 +947,6 @@ namespace Slang { // Create dOut param. auto diffParam = builder->emitParam(diffType); - diffParam->sourceLoc = fwdParam->sourceLoc; - copyNameHintAndDebugDecorations(diffParam, fwdParam); result.propagateFuncParams.add(diffParam); primalRefReplacement = builder->emitParam(builder->getOutType(primalType)); @@ -959,6 +969,10 @@ namespace Slang diffWriteRefReplacement = tempVar; diffRefReplacement = tempVar; + + diffParam->sourceLoc = fwdParam->sourceLoc; + tempVar->sourceLoc = fwdParam->sourceLoc; + storeInst->sourceLoc = fwdParam->sourceLoc; } else { @@ -970,6 +984,7 @@ namespace Slang // Create a local var for the out param for the primal part of the prop func. auto tempPrimalVar = nextBlockBuilder.emitVar(outType->getValueType()); tempPrimalVar->sourceLoc = fwdParam->sourceLoc; + copyNameHintAndDebugDecorations(tempPrimalVar, fwdParam); result.mapPrimalSpecificParamToReplacementInPropFunc[primalRefReplacement] = tempPrimalVar; @@ -995,13 +1010,16 @@ namespace Slang // Create a local var for the out param for the primal part of the prop func. auto tempPrimalVar = nextBlockBuilder.emitVar(inoutType->getValueType()); - tempPrimalVar->sourceLoc = fwdParam->sourceLoc; copyNameHintAndDebugDecorations(tempPrimalVar, fwdParam); result.propagateFuncSpecificPrimalInsts.add(tempPrimalVar); auto storeInst = nextBlockBuilder.emitStore(tempPrimalVar, propParam); result.propagateFuncSpecificPrimalInsts.add(storeInst); result.mapPrimalSpecificParamToReplacementInPropFunc[primalRefReplacement] = tempPrimalVar; + + tempPrimalVar->sourceLoc = fwdParam->sourceLoc; + storeInst->sourceLoc = fwdParam->sourceLoc; + propParam->sourceLoc = fwdParam->sourceLoc; } else { @@ -1032,14 +1050,9 @@ namespace Slang copyNameHintAndDebugDecorations(propParam, fwdParam); result.propagateFuncParams.add(propParam); - primalRefReplacement->sourceLoc = fwdParam->sourceLoc; - propParam->sourceLoc = fwdParam->sourceLoc; - // A reference to this parameter from the diff blocks should be replaced with a load // of the differential component of the pair. auto newParamLoad = diffBuilder.emitLoad(propParam); - newParamLoad->sourceLoc = fwdParam->sourceLoc; - diffBuilder.markInstAsDifferential(newParamLoad, primalType); result.propagateFuncSpecificPrimalInsts.add(newParamLoad); @@ -1057,6 +1070,11 @@ namespace Slang result.propagateFuncSpecificPrimalInsts.add(primalVal); result.mapPrimalSpecificParamToReplacementInPropFunc[primalRefReplacement] = primalVal; + propParam->sourceLoc = fwdParam->sourceLoc; + newParamLoad->sourceLoc = fwdParam->sourceLoc; + primalReplacementLoad->sourceLoc = fwdParam->sourceLoc; + primalVal->sourceLoc = fwdParam->sourceLoc; + instsToRemove.add(fwdParam); } else @@ -1072,9 +1090,6 @@ namespace Slang auto diffParam = builder->emitParam(inoutType); copyNameHintAndDebugDecorations(diffParam, fwdParam); result.propagateFuncParams.add(diffParam); - - primalParam->sourceLoc = fwdParam->sourceLoc; - diffParam->sourceLoc = fwdParam->sourceLoc; // Primal references to this param is the new primal param. primalRefReplacement = primalParam; @@ -1084,7 +1099,6 @@ namespace Slang // Load the inital diff value. auto loadedParam = nextBlockBuilder.emitLoad(diffParam); - loadedParam->sourceLoc = fwdParam->sourceLoc; result.propagateFuncSpecificPrimalInsts.add(loadedParam); auto initDiff = nextBlockBuilder.emitDifferentialPairGetDifferential(diffType, loadedParam); @@ -1124,10 +1138,30 @@ namespace Slang result.propagateFuncSpecificPrimalInsts.add(storeInst); result.mapPrimalSpecificParamToReplacementInPropFunc[primalParam] = primalVar; result.outDiffWritebacks[diffParam] = InstPair(initPrimalVal, diffVar); + + primalParam->sourceLoc = fwdParam->sourceLoc; + diffParam->sourceLoc = fwdParam->sourceLoc; + loadedParam->sourceLoc = fwdParam->sourceLoc; + initDiff->sourceLoc = fwdParam->sourceLoc; + diffVar->sourceLoc = fwdParam->sourceLoc; + diffWriteVar->sourceLoc = fwdParam->sourceLoc; + dzero->sourceLoc = fwdParam->sourceLoc; + initDiffStore->sourceLoc = fwdParam->sourceLoc; + writeStore->sourceLoc = fwdParam->sourceLoc; + primalVar->sourceLoc = fwdParam->sourceLoc; + initPrimalVal->sourceLoc = fwdParam->sourceLoc; + storeInst->sourceLoc = fwdParam->sourceLoc; instsToRemove.add(fwdParam); } + if (diffRefReplacement) + diffRefReplacement->sourceLoc = fwdParam->sourceLoc; + if (primalRefReplacement) + primalRefReplacement->sourceLoc = fwdParam->sourceLoc; + if (diffWriteRefReplacement) + diffWriteRefReplacement->sourceLoc = fwdParam->sourceLoc; + // We have emitted all the new parameters and computed the replacements for the original // parameter. Now we perform that replacement. List uses; @@ -1207,6 +1241,7 @@ namespace Slang SLANG_ASSERT(dOutParamType); dOutParam = builder->emitParam(dOutParamType); + dOutParam->sourceLoc = returnLoc; builder->addNameHintDecoration(dOutParam, UnownedStringSlice("_s_dOut")); result.propagateFuncParams.add(dOutParam); } @@ -1217,6 +1252,10 @@ namespace Slang result.primalFuncParams.add(ctxParam); result.propagateFuncParams.add(ctxParam); result.dOutParam = dOutParam; + + diffFunc->sourceLoc = primalLoc; + ctxParam->sourceLoc = primalLoc; + return result; } diff --git a/source/slang/slang-ir-autodiff-rev.h b/source/slang/slang-ir-autodiff-rev.h index 68cb4e0c9a..b65701a7a9 100644 --- a/source/slang/slang-ir-autodiff-rev.h +++ b/source/slang/slang-ir-autodiff-rev.h @@ -105,6 +105,7 @@ struct BackwardDiffTranscriberBase : AutoDiffTranscriberBase ParameterBlockTransposeInfo splitAndTransposeParameterBlock( IRBuilder* builder, IRFunc* diffFunc, + SourceLoc primalLoc, bool isResultDifferentiable); void writeBackDerivativeToInOutParams(ParameterBlockTransposeInfo& info, IRFunc* diffFunc); diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h index 66ed07ad7b..438a17423b 100644 --- a/source/slang/slang-ir-autodiff-transpose.h +++ b/source/slang/slang-ir-autodiff-transpose.h @@ -695,7 +695,9 @@ struct DiffTransposePass SLANG_ASSERT(lastRevBlock->getTerminator() == nullptr); builder.setInsertInto(lastRevBlock); - builder.emitReturn(); + + auto returnVal = builder.emitReturn(); + returnVal->sourceLoc = revDiffFunc->sourceLoc; // Remove fwd-mode blocks. for (auto block : workList) @@ -913,14 +915,16 @@ struct DiffTransposePass auto gradInst = emitAggregateValue( &builder, tryGetPrimalTypeFromDiffInst(param), - gradients); + gradients, + param->sourceLoc); phiParamRevGradInsts.add(gradInst); } else { - phiParamRevGradInsts.add( - emitDZeroOfDiffInstType(&builder, tryGetPrimalTypeFromDiffInst(param))); + auto dzero = emitDZeroOfDiffInstType(&builder, tryGetPrimalTypeFromDiffInst(param)); + dzero->sourceLoc = param->sourceLoc; + phiParamRevGradInsts.add(dzero); } } else @@ -969,7 +973,8 @@ struct DiffTransposePass auto gradInst = emitAggregateValue( &builder, primalType, - gradients); + gradients, + externInst->sourceLoc); builder.emitStore(accVar, gradInst); } @@ -1061,7 +1066,7 @@ struct DiffTransposePass // Emit the aggregate of all the gradients here. // This will form the total derivative for this inst. - auto revValue = emitAggregateValue(builder, primalType, gradients); + auto revValue = emitAggregateValue(builder, primalType, gradients, inst->sourceLoc); auto transposeResult = transposeInst(builder, inst, revValue); @@ -1287,11 +1292,14 @@ struct DiffTransposePass for (auto wb : writebacks) { auto loadedPair = builder->emitLoad(wb.srcTempPairVar); - loadedPair->sourceLoc = fwdCall->sourceLoc; auto diffType = as(wb.destVar->getDataType())->getValueType(); auto loadedDiff = builder->emitDifferentialPairGetDifferential(diffType, loadedPair); - builder->emitStore(wb.destVar, loadedDiff); + auto storeDiff = builder->emitStore(wb.destVar, loadedDiff); + + loadedPair->sourceLoc = fwdCall->sourceLoc; + loadedDiff->sourceLoc = fwdCall->sourceLoc; + storeDiff->sourceLoc = fwdCall->sourceLoc; } List gradients; @@ -1595,7 +1603,8 @@ struct DiffTransposePass auto aggregateGradient = emitAggregateValue( builder, primalType, - gradients); + gradients, + fwdLoad->sourceLoc); if (as(loadType)) { @@ -1604,12 +1613,18 @@ struct DiffTransposePass auto pairVal = builder->emitMakeDifferentialPair(loadType, primalVal, aggregateGradient); - builder->emitStore(revPtr, pairVal); + auto store = builder->emitStore(revPtr, pairVal); + + primalPairVal->sourceLoc = fwdLoad->sourceLoc; + primalVal->sourceLoc = fwdLoad->sourceLoc; + pairVal->sourceLoc = fwdLoad->sourceLoc; + store->sourceLoc = fwdLoad->sourceLoc; } else { // Store this back into the pointer. - builder->emitStore(revPtr, aggregateGradient); + auto store = builder->emitStore(revPtr, aggregateGradient); + store->sourceLoc = fwdLoad->sourceLoc; } return TranspositionResult(List()); @@ -1712,16 +1727,23 @@ struct DiffTransposePass TranspositionResult transposeMakePairUserCode(IRBuilder* builder, IRMakeDifferentialPairUserCode* fwdMakePair, IRInst* revValue) { List gradients; + + auto primalVal = builder->emitDifferentialPairGetPrimalUserCode(revValue); + auto diffVal = builder->emitDifferentialPairGetDifferentialUserCode( + fwdMakePair->getDifferentialValue()->getFullType(), revValue); + + primalVal->sourceLoc = fwdMakePair->sourceLoc; + diffVal->sourceLoc = fwdMakePair->sourceLoc; + gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdMakePair->getPrimalValue(), - builder->emitDifferentialPairGetPrimalUserCode(revValue), + primalVal, fwdMakePair)); gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdMakePair->getDifferentialValue(), - builder->emitDifferentialPairGetDifferentialUserCode( - fwdMakePair->getDifferentialValue()->getFullType(), revValue), + diffVal, fwdMakePair)); return TranspositionResult(gradients); } @@ -1969,6 +1991,9 @@ struct DiffTransposePass field->getFieldType(), revValue, field->getKey()); + + gradAtField->sourceLoc = field->sourceLoc; + SLANG_RELEASE_ASSERT(ii < fwdMakeStruct->getOperandCount()); gradients.add(RevGradient( RevGradient::Flavor::Simple, @@ -2654,7 +2679,7 @@ struct DiffTransposePass return materializeSimpleGradients(builder, aggPrimalType, simpleGradients); } - RevGradient materializeGradientSet(IRBuilder* builder, IRType* aggPrimalType, List gradients) + RevGradient materializeGradientSet(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) { switch (gradients[0].flavor) { @@ -2665,10 +2690,10 @@ struct DiffTransposePass return materializeSwizzleGradients(builder, aggPrimalType, gradients); case RevGradient::Flavor::FieldExtract: - return materializeFieldExtractGradients(builder, aggPrimalType, gradients); + return materializeFieldExtractGradients(builder, aggPrimalType, gradients, fwdLoc); case RevGradient::Flavor::GetElement: - return materializeGetElementGradients(builder, aggPrimalType, gradients); + return materializeGetElementGradients(builder, aggPrimalType, gradients, fwdLoc); case RevGradient::Flavor::DifferentialPairGetElementUserCode: return materializeDifferentialPairUserCodeGetElementGradients(builder, aggPrimalType, gradients); @@ -2678,7 +2703,7 @@ struct DiffTransposePass } } - RevGradient materializeGetElementGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients) + RevGradient materializeGetElementGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) { // Setup a temporary variable to aggregate gradients. // TODO: We can extend this later to grab an existing ptr to allow aggregation of @@ -2686,13 +2711,17 @@ struct DiffTransposePass // Looking up an existing pointer could also allow chained accesses like x.a.b[1] to directly // write into the specific sub-field that is affected without constructing intermediate vars. // - auto revGradVar = builder->emitVar( - (IRType*)diffTypeContext.getDifferentialForType(builder, aggPrimalType)); + printf("materializing get element gradients: (%d)\n", fwdLoc.getRaw()); + auto diffType = diffTypeContext.getDifferentialForType(builder, aggPrimalType); + auto revGradVar = builder->emitVar(as(diffType)); + revGradVar->sourceLoc = fwdLoc; // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); + auto initStore = builder->emitStore(revGradVar, zeroValueInst); - builder->emitStore(revGradVar, zeroValueInst); + zeroValueInst->sourceLoc = fwdLoc; + initStore->sourceLoc = fwdLoc; OrderedDictionary> bucketedGradients; for (auto gradient : gradients) @@ -2732,11 +2761,16 @@ struct DiffTransposePass revGradVar, pair.key); - builder->emitStore(revGradTargetAddress, emitAggregateValue(builder, primalType, subGrads)); + auto aggrVal = emitAggregateValue(builder, primalType, subGrads, fwdLoc); + auto storeAddress = builder->emitStore(revGradTargetAddress, aggrVal); + + revGradTargetAddress->sourceLoc = fwdLoc; + aggrVal->sourceLoc = fwdLoc; + storeAddress->sourceLoc = fwdLoc; } auto loadedRevGradVar = builder->emitLoad(revGradVar); - loadedRevGradVar->sourceLoc = revGradVar->sourceLoc; + loadedRevGradVar->sourceLoc = fwdLoc; // Load the entire var and return it. return RevGradient( @@ -2747,7 +2781,7 @@ struct DiffTransposePass } - RevGradient materializeFieldExtractGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients) + RevGradient materializeFieldExtractGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) { // Setup a temporary variable to aggregate gradients. // TODO: We can extend this later to grab an existing ptr to allow aggregation of @@ -2755,13 +2789,16 @@ struct DiffTransposePass // Looking up an existing pointer could also allow chained accesses like x.a.b[1] to directly // write into the specific sub-field that is affected without constructing intermediate vars. // - auto revGradVar = builder->emitVar( - (IRType*)diffTypeContext.getDifferentialForType(builder, aggPrimalType)); + auto diffType = diffTypeContext.getDifferentialForType(builder, aggPrimalType); + auto revGradVar = builder->emitVar(as(diffType)); + revGradVar->sourceLoc = fwdLoc; // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); + auto initStore = builder->emitStore(revGradVar, zeroValueInst); - builder->emitStore(revGradVar, zeroValueInst); + zeroValueInst->sourceLoc = fwdLoc; + initStore->sourceLoc = fwdLoc; OrderedDictionary> bucketedGradients; for (auto gradient : gradients) @@ -2801,11 +2838,16 @@ struct DiffTransposePass revGradVar, pair.key); - builder->emitStore(revGradTargetAddress, emitAggregateValue(builder, primalType, subGrads)); + auto aggrVal = emitAggregateValue(builder, primalType, subGrads, fwdLoc); + auto store = builder->emitStore(revGradTargetAddress, aggrVal); + + revGradTargetAddress->sourceLoc = fwdLoc; + aggrVal->sourceLoc = fwdLoc; + store->sourceLoc = fwdLoc; } auto loadedRevGradVar = builder->emitLoad(revGradVar); - loadedRevGradVar->sourceLoc = revGradVar->sourceLoc; + loadedRevGradVar->sourceLoc = fwdLoc; // Load the entire var and return it. return RevGradient( @@ -2844,7 +2886,7 @@ struct DiffTransposePass nullptr); } - IRInst* emitAggregateValue(IRBuilder* builder, IRType* aggPrimalType, List gradients) + IRInst* emitAggregateValue(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) { // If we're dealing with the differential-pair types, we need to use a different aggregation method, since // a differential pair is really a 'hybrid' primal-differential type. @@ -2888,7 +2930,7 @@ struct DiffTransposePass } // Turn the set into a simple gradient. - auto simpleGradient = materializeGradientSet(builder, aggPrimalType, gradientsOfFlavor); + auto simpleGradient = materializeGradientSet(builder, aggPrimalType, gradientsOfFlavor, fwdLoc); SLANG_ASSERT(simpleGradient.flavor == RevGradient::Flavor::Simple); simpleGradients.add(simpleGradient); diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp index 8ae8865450..c688fdaad8 100644 --- a/source/slang/slang-ir-autodiff-unzip.cpp +++ b/source/slang/slang-ir-autodiff-unzip.cpp @@ -393,6 +393,9 @@ IRFunc* DiffUnzipPass::extractPrimalFunc( valType, intermediateVar, structKeyDecor->getStructKey()); + + val->sourceLoc = use->getUser()->sourceLoc; + if (use->getUser()->getOp() == kIROp_Load) { use->getUser()->replaceUsesWith(val); @@ -400,16 +403,17 @@ IRFunc* DiffUnzipPass::extractPrimalFunc( } else { - auto tempVar = - builder.emitVar(valType); - builder.emitStore(tempVar, val); + auto tempVar = builder.emitVar(valType); + auto store = builder.emitStore(tempVar, val); + tempVar->sourceLoc = val->sourceLoc; + store->sourceLoc = val->sourceLoc; use->set(tempVar); } } } else { - // Orindary value. + // Ordinary value. // We insert a fieldExtract at each use site instead of before `inst`, // since at this stage of autodiff pass, `inst` does not necessarily // dominate all the use sites if `inst` is defined in partial branch @@ -425,6 +429,9 @@ IRFunc* DiffUnzipPass::extractPrimalFunc( inst->getFullType(), intermediateVar, structKeyDecor->getStructKey()); + + val->sourceLoc = user->sourceLoc; + builder.replaceOperand(iuse, val); } } diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index de8d0014d3..2fdecf7f2e 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -94,12 +94,13 @@ struct DiffUnzipPass auto primalRef = builder->emitPrimalParamRef(primalParam); auto diffRef = builder->emitDiffParamRef((IRType*)diffType, primalParam); - primalRef->sourceLoc = primalParam->sourceLoc; - diffRef->sourceLoc = primalParam->sourceLoc; builder->markInstAsDifferential(diffRef, pairType->getValueType()); primalMap[primalParam] = primalRef; diffMap[primalParam] = diffRef; + + primalRef->sourceLoc = primalParam->sourceLoc; + diffRef->sourceLoc = primalParam->sourceLoc; } } @@ -259,6 +260,7 @@ struct DiffUnzipPass { primalBuilder->addBackwardDerivativePrimalContextDecoration(intermediateVar, intermediateVar); primalFn = primalBuilder->emitBackwardDifferentiatePrimalInst((IRType*)primalFuncType, baseFn); + primalFn->sourceLoc = mixedCall->sourceLoc; } else { @@ -337,6 +339,8 @@ struct DiffUnzipPass auto gradArg = diffBuilder->emitLoadReverseGradient(outDiffType, diffArg); diffBuilder->markInstAsDifferential(gradArg, primalArg->getDataType()); diffArgs.add(gradArg); + + gradArg->sourceLoc = mixedCall->sourceLoc; } else if (const auto inoutType = as(primalParamType)) { @@ -356,11 +360,15 @@ struct DiffUnzipPass // Emit the temp var into the primal blocks since it's holding a primal value. auto tempPrimalVar = primalBuilder->emitVar(primalValueType); - primalBuilder->emitStore(tempPrimalVar, storedVal); + auto storeTemp = primalBuilder->emitStore(tempPrimalVar, storedVal); auto diffPairRef = diffBuilder->emitReverseGradientDiffPairRef(arg->getDataType(), tempPrimalVar, diffArg); diffBuilder->markInstAsDifferential(diffPairRef, primalValueType); diffArgs.add(diffPairRef); + + tempPrimalVar->sourceLoc = mixedCall->sourceLoc; + storeTemp->sourceLoc = mixedCall->sourceLoc; + diffPairRef->sourceLoc = mixedCall->sourceLoc; } else { @@ -374,6 +382,8 @@ struct DiffUnzipPass diffBuilder->markInstAsDifferential(pairArg, primalArg->getDataType()); diffArgs.add(pairArg); + + pairArg->sourceLoc = mixedCall->sourceLoc; } } else @@ -390,9 +400,12 @@ struct DiffUnzipPass auto storeInst = cast(storeUse->getUser()); auto storedVal = storeInst->getVal(); - primalBuilder->emitStore(tempPrimalVar, storedVal); + auto storeTemp = primalBuilder->emitStore(tempPrimalVar, storedVal); diffArgs.add(tempPrimalVar); + + tempPrimalVar->sourceLoc = mixedCall->sourceLoc; + storeTemp->sourceLoc = mixedCall->sourceLoc; } else { @@ -408,6 +421,7 @@ struct DiffUnzipPass } auto newFwdCallee = diffBuilder->emitForwardDifferentiateInst(fwdCalleeType, baseFn); + newFwdCallee->sourceLoc = mixedCall->sourceLoc; diffBuilder->markInstAsDifferential(newFwdCallee); @@ -464,6 +478,9 @@ struct DiffUnzipPass auto primalStore = primalBuilder->emitStore(primalAddr, primalVal); auto diffStore = diffBuilder->emitStore(diffAddr, diffVal); + primalStore->sourceLoc = mixedStore->sourceLoc; + diffStore->sourceLoc = mixedStore->sourceLoc; + diffBuilder->markInstAsDifferential(diffStore, primalVal->getFullType()); return InstPair(primalStore, diffStore); } @@ -475,7 +492,9 @@ struct DiffUnzipPass auto diffType = (IRType*) diffTypeContext.getDifferentialForType(primalBuilder, primalType); auto primalVar = primalBuilder->emitVar(primalType); auto diffVar = diffBuilder->emitVar(diffType); - diffBuilder->markInstAsDifferential(diffVar, diffBuilder->getPtrType(primalType)); + primalVar->sourceLoc = mixedVar->sourceLoc; + diffVar->sourceLoc = mixedVar->sourceLoc; + diffBuilder->markInstAsDifferential(diffVar, diffBuilder->getPtrType(primalType)); return InstPair(primalVar, diffVar); } @@ -501,6 +520,8 @@ struct DiffUnzipPass diffBuilder->markInstAsDifferential(pairVal, primalType); auto returnInst = diffBuilder->emitReturn(pairVal); + returnInst->sourceLoc = mixedReturn->sourceLoc; + diffBuilder->markInstAsDifferential(returnInst, primalType); return InstPair(primalBranch, returnInst); @@ -513,6 +534,8 @@ struct DiffUnzipPass primalBranch, mixedReturn->getVal()); auto returnInst = diffBuilder->emitReturn(); + returnInst->sourceLoc = mixedReturn->sourceLoc; + diffBuilder->markInstAsDifferential(returnInst, nullptr); return InstPair(primalBranch, returnInst); } diff --git a/source/slang/slang-ir-init-local-var.cpp b/source/slang/slang-ir-init-local-var.cpp index 34a0e5ff4c..d9b9d3f499 100644 --- a/source/slang/slang-ir-init-local-var.cpp +++ b/source/slang/slang-ir-init-local-var.cpp @@ -47,11 +47,15 @@ void initializeLocalVariables(IRModule* module, IRGlobalValueWithCode* func) breakLabel:; if (initialized) continue; + builder.setInsertAfter(inst); - builder.emitStore( - inst, - builder.emitDefaultConstruct( - as(inst->getFullType())->getValueType())); + + auto valueType = as(inst->getFullType())->getValueType(); + auto construct = builder.emitDefaultConstruct(valueType); + auto store = builder.emitStore(inst, construct); + + construct->sourceLoc = inst->sourceLoc; + store->sourceLoc = inst->sourceLoc; } } } diff --git a/tests/autodiff/reverse-control-flow-1.slang b/tests/autodiff/reverse-control-flow-1.slang index 7d2f518be9..334de4137e 100644 --- a/tests/autodiff/reverse-control-flow-1.slang +++ b/tests/autodiff/reverse-control-flow-1.slang @@ -1,5 +1,6 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; @@ -40,3 +41,5 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) outputBuffer[1] = dpa.d; // Expect: 1.0 } } + +//CHK: (0): note: no checkpoint contexts to report \ No newline at end of file diff --git a/tests/autodiff/reverse-control-flow-2.slang b/tests/autodiff/reverse-control-flow-2.slang index cde707b4d3..c3790367cf 100644 --- a/tests/autodiff/reverse-control-flow-2.slang +++ b/tests/autodiff/reverse-control-flow-2.slang @@ -1,5 +1,6 @@ //TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj -output-using-type //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer RWStructuredBuffer outputBuffer; @@ -73,3 +74,5 @@ void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) outputBuffer[1] = dpx.d; } } + +//CHK: (0): note: no checkpoint contexts to report \ No newline at end of file diff --git a/tests/autodiff/reverse-control-flow-3.slang b/tests/autodiff/reverse-control-flow-3.slang index 01b5332793..b4fa68e3a3 100644 --- a/tests/autodiff/reverse-control-flow-3.slang +++ b/tests/autodiff/reverse-control-flow-3.slang @@ -1,4 +1,5 @@ //TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj -output-using-type +//TEST:SIMPLE(filecheck=CHK):-target glsl -stage compute -entry computeMain -report-checkpoint-intermediates //TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer @@ -75,7 +76,8 @@ void d_getParam(uint id, MaterialParam.Differential diff) outputBuffer[id] += diff.roughness; } - +//CHK-DAG: note: checkpointing context of 8 bytes associated with function: 'updatePathThroughput' +//CHK-DAG: note: 8 bytes (PathResult_0) used to checkpoint the following item: [BackwardDifferentiable] void updatePathThroughput(inout PathResult path, const float weight) { @@ -122,9 +124,13 @@ bool generateScatterRay(const BSDFSample bs, const MaterialParam bsdfParams, ino \param[in,out] path The path state. \return True if a ray was generated, false otherwise. */ + +//CHK-DAG: note: checkpointing context of 16 bytes associated with function: 'generateScatterRay' [BackwardDifferentiable] bool generateScatterRay(const BSDFSample bs, const MaterialParam bsdfParams, inout PathState path, inout PathResult pathRes) { + //CHK-DAG: note: 8 bytes (s_bwd_prop_updatePathThroughput_Intermediates_0) used to checkpoint the following item: + //CHK-DAG: note: 8 bytes (PathResult_0) used to checkpoint the following item: updatePathThroughput(pathRes, bs.val); return true; } @@ -215,5 +221,6 @@ void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID) var dpx = diffPair(pathRes, pathResD); __bwd_diff(tracePath)(1, dpx); // Expect: 5.0 in outputBuffer[3] } - } + +//CHK-NOT: note \ No newline at end of file From 52f1310ca378e8d737580b5a7ba5043276b6ac70 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 11:44:07 -0700 Subject: [PATCH 21/32] Remove debugging line --- source/slang/slang-ir-autodiff-rev.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index f81ba87728..de967747fc 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -691,7 +691,6 @@ namespace Slang tempBuilder.setInsertBefore(diffPropagateFunc); } - auto hint = primalFunc->findDecoration()->getName().begin(); auto fwdDiffFunc = generateNewForwardDerivativeForFunc(&tempBuilder, primalFunc, diffPropagateFunc); if (!fwdDiffFunc) return; From 8779f24732027782e8252840bb313e7fd6ebabc7 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 12:03:10 -0700 Subject: [PATCH 22/32] Reverting changes to diagnostic sink --- source/compiler-core/slang-diagnostic-sink.cpp | 4 ++-- source/compiler-core/slang-diagnostic-sink.h | 3 --- source/slang/slang-ir-loop-unroll.cpp | 7 +++---- source/slang/slang-ir-ssa.cpp | 6 +++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/source/compiler-core/slang-diagnostic-sink.cpp b/source/compiler-core/slang-diagnostic-sink.cpp index be1618ac09..7e3c286eb2 100644 --- a/source/compiler-core/slang-diagnostic-sink.cpp +++ b/source/compiler-core/slang-diagnostic-sink.cpp @@ -251,7 +251,7 @@ static void _reduceLength(Index startIndex, const UnownedStringSlice& prefix, St ioBuf = buf; } -void sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb) +static void _sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb) { SourceFile* sourceFile = sourceView->getSourceFile(); if (!sourceFile) @@ -461,7 +461,7 @@ static void formatDiagnostic( if (sourceView && sink->isFlagSet(DiagnosticSink::Flag::SourceLocationLine) && diagnostic.loc.isValid()) { - sourceLocationNoteDiagnostic(sink, sourceView, sourceLoc, sb); + _sourceLocationNoteDiagnostic(sink, sourceView, sourceLoc, sb); } if (sourceView && sink->isFlagSet(DiagnosticSink::Flag::VerbosePath)) diff --git a/source/compiler-core/slang-diagnostic-sink.h b/source/compiler-core/slang-diagnostic-sink.h index ec6d43d9c9..38a31752f9 100644 --- a/source/compiler-core/slang-diagnostic-sink.h +++ b/source/compiler-core/slang-diagnostic-sink.h @@ -360,9 +360,6 @@ class DiagnosticsLookup : public RefObject MemoryArena m_arena; }; -// Display source location -void sourceLocationNoteDiagnostic(DiagnosticSink* sink, SourceView* sourceView, SourceLoc sourceLoc, StringBuilder& sb); - } #endif diff --git a/source/slang/slang-ir-loop-unroll.cpp b/source/slang/slang-ir-loop-unroll.cpp index c3aadac0fd..ef05511612 100644 --- a/source/slang/slang-ir-loop-unroll.cpp +++ b/source/slang/slang-ir-loop-unroll.cpp @@ -526,6 +526,7 @@ void eliminateContinueBlocks(IRModule* module, IRLoop* loopInst) // we will now introduce a breakable region for each iteration. IRBuilder builder(module); + IRBuilderSourceLocRAII sourceLocationScope(&builder, loopInst->sourceLoc); auto targetBlock = loopInst->getTargetBlock(); @@ -544,15 +545,13 @@ void eliminateContinueBlocks(IRModule* module, IRLoop* loopInst) moveParams(innerBreakableRegionHeader, targetBlock); builder.setInsertInto(innerBreakableRegionHeader); - auto innerLoop = builder.emitLoop(targetBlock, innerBreakableRegionBreakBlock, targetBlock); - innerLoop->sourceLoc = loopInst->sourceLoc; + builder.emitLoop(targetBlock, innerBreakableRegionBreakBlock, targetBlock); continueBlock->replaceUsesWith(innerBreakableRegionBreakBlock); builder.setInsertInto(innerBreakableRegionBreakBlock); moveParams(innerBreakableRegionBreakBlock, continueBlock); - auto unconditionalBranch = builder.emitBranch(continueBlock); - unconditionalBranch->sourceLoc = loopInst->sourceLoc; + builder.emitBranch(continueBlock); // If the original loop can be executed up to N times, the new loop may be executed // upto N+1 times (although most insts are skipped in the last traversal) diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index bac4d2544e..e699b75219 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -431,7 +431,6 @@ PhiInfo* addPhi( RefPtr phiInfo = new PhiInfo(); context->phiInfos.add(phi, phiInfo); - phi->sourceLoc = var->sourceLoc; phiInfo->phi = phi; phiInfo->var = var; @@ -678,6 +677,8 @@ IRInst* readVarRec( SSABlockInfo* blockInfo, IRVar* var) { + IRBuilderSourceLocRAII sourceLocationScope(&context->builder, var->sourceLoc); + IRInst* val = nullptr; if (!blockInfo->isSealed) { @@ -985,8 +986,7 @@ void IRBuilder::insertBlockAlongEdge( // The edge block should branch (unconditionally) // to the successor block. builder.setInsertInto(edgeBlock); - auto unconditionalBranch = builder.emitBranch(succ); - unconditionalBranch->sourceLoc = edgeUse->getUser()->sourceLoc; + builder.emitBranch(succ); // Insert the new block into the block list // for the function. From c9f1e5bba93ce0940bb48366cd3977dc05aac7c5 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 12:18:45 -0700 Subject: [PATCH 23/32] Simplify address elimination using source location RAII contexts --- .../slang/slang-ir-addr-inst-elimination.cpp | 65 +++++++------------ source/slang/slang-ir-ssa.cpp | 3 +- 2 files changed, 24 insertions(+), 44 deletions(-) diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp index 154cff7cb0..3c8a178823 100644 --- a/source/slang/slang-ir-addr-inst-elimination.cpp +++ b/source/slang/slang-ir-addr-inst-elimination.cpp @@ -16,36 +16,26 @@ struct AddressInstEliminationContext IRModule* module; DiagnosticSink* sink; - IRInst* getValue(IRBuilder& builder, IRInst* addr, SourceLoc loc) + IRInst* getValue(IRBuilder& builder, IRInst* addr) { switch (addr->getOp()) { default: - { - IRInst* load = builder.emitLoad(addr); - load->sourceLoc = loc; - return load; - } + return builder.emitLoad(addr); case kIROp_GetElementPtr: case kIROp_FieldAddress: { - IRInst* first = getValue(builder, addr->getOperand(0), loc); - - IRInst* args[] = { first, addr->getOperand(1) }; - IRInst* value = builder.emitIntrinsicInst( + IRInst* args[] = { getValue(builder, addr->getOperand(0)), addr->getOperand(1) }; + return builder.emitIntrinsicInst( cast(addr->getFullType())->getValueType(), (addr->getOp() == kIROp_GetElementPtr ? kIROp_GetElement : kIROp_FieldExtract), - 2, args); - - first->sourceLoc = loc; - value->sourceLoc = loc; - - return value; + 2, + args); } } } - void storeValue(IRBuilder& builder, IRInst* addr, IRInst* val, SourceLoc loc) + void storeValue(IRBuilder& builder, IRInst* addr, IRInst* val) { List accessChain; @@ -71,43 +61,36 @@ struct AddressInstEliminationContext { auto lastVal = builder.emitLoad(lastAddr); auto update = builder.emitUpdateElement(lastVal, accessChain.getArrayView(), val); - auto store = builder.emitStore(lastAddr, update); - - lastVal->sourceLoc = loc; - update->sourceLoc = loc; - store->sourceLoc = loc; + builder.emitStore(lastAddr, update); } else { - auto store = builder.emitStore(lastAddr, val); - store->sourceLoc = loc; + builder.emitStore(lastAddr, val); } } - void transformLoadAddr(IRUse* use) + void transformLoadAddr(IRBuilder& builder, IRUse* use) { auto addr = use->get(); auto load = as(use->getUser()); - IRBuilder builder(module); builder.setInsertBefore(use->getUser()); - auto value = getValue(builder, addr, load->sourceLoc); + auto value = getValue(builder, addr); load->replaceUsesWith(value); load->removeAndDeallocate(); } - void transformStoreAddr(IRUse* use) + void transformStoreAddr(IRBuilder& builder, IRUse* use) { auto addr = use->get(); auto store = as(use->getUser()); - IRBuilder builder(module); builder.setInsertBefore(use->getUser()); - storeValue(builder, addr, store->getVal(), store->sourceLoc); + storeValue(builder, addr, store->getVal()); store->removeAndDeallocate(); } - void transformCallAddr(IRUse* use) + void transformCallAddr(IRBuilder& builder, IRUse* use) { auto addr = use->get(); auto call = as(use->getUser()); @@ -118,24 +101,19 @@ struct AddressInstEliminationContext return; } - IRBuilder builder(module); builder.setInsertBefore(call); auto tempVar = builder.emitVar(cast(addr->getFullType())->getValueType()); // Store the initial value of the mutable argument into temp var. // If this is an `out` var, the initial value will be undefined, // which will get cleaned up later into a `defaultConstruct`. - auto value = getValue(builder, addr, call->sourceLoc); - auto store = builder.emitStore(tempVar, value); + auto value = getValue(builder, addr); + builder.emitStore(tempVar, value); builder.setInsertAfter(call); auto load = builder.emitLoad(tempVar); - storeValue(builder, addr, load, call->sourceLoc); + storeValue(builder, addr, load); use->set(tempVar); - - tempVar->sourceLoc = addr->sourceLoc; - store->sourceLoc = call->sourceLoc; - load->sourceLoc = call->sourceLoc; } SlangResult eliminateAddressInstsImpl( @@ -177,17 +155,20 @@ struct AddressInstEliminationContext use = nextUse; continue; } + + IRBuilder builder(module); + IRBuilderSourceLocRAII sourceLocationScope(&builder, use->getUser()->sourceLoc); switch (use->getUser()->getOp()) { case kIROp_Load: - transformLoadAddr(use); + transformLoadAddr(builder, use); break; case kIROp_Store: - transformStoreAddr(use); + transformStoreAddr(builder, use); break; case kIROp_Call: - transformCallAddr(use); + transformCallAddr(builder, use); break; case kIROp_GetElementPtr: case kIROp_FieldAddress: diff --git a/source/slang/slang-ir-ssa.cpp b/source/slang/slang-ir-ssa.cpp index e699b75219..506e6a3350 100644 --- a/source/slang/slang-ir-ssa.cpp +++ b/source/slang/slang-ir-ssa.cpp @@ -431,6 +431,7 @@ PhiInfo* addPhi( RefPtr phiInfo = new PhiInfo(); context->phiInfos.add(phi, phiInfo); + phi->sourceLoc = var->sourceLoc; phiInfo->phi = phi; phiInfo->var = var; @@ -677,8 +678,6 @@ IRInst* readVarRec( SSABlockInfo* blockInfo, IRVar* var) { - IRBuilderSourceLocRAII sourceLocationScope(&context->builder, var->sourceLoc); - IRInst* val = nullptr; if (!blockInfo->isSealed) { From 5efd9c8360d96025b98b09c33107ed99b4a33fb5 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 12:30:08 -0700 Subject: [PATCH 24/32] Eliminating manual source loc transfers in forward transcription --- .../slang/slang-ir-addr-inst-elimination.cpp | 17 ++-- source/slang/slang-ir-autodiff-fwd.cpp | 83 +------------------ .../slang-ir-autodiff-transcriber-base.cpp | 8 +- 3 files changed, 12 insertions(+), 96 deletions(-) diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp index 3c8a178823..9d3605c8cf 100644 --- a/source/slang/slang-ir-addr-inst-elimination.cpp +++ b/source/slang/slang-ir-addr-inst-elimination.cpp @@ -107,12 +107,9 @@ struct AddressInstEliminationContext // Store the initial value of the mutable argument into temp var. // If this is an `out` var, the initial value will be undefined, // which will get cleaned up later into a `defaultConstruct`. - auto value = getValue(builder, addr); - builder.emitStore(tempVar, value); - + builder.emitStore(tempVar, getValue(builder, addr)); builder.setInsertAfter(call); - auto load = builder.emitLoad(tempVar); - storeValue(builder, addr, load); + storeValue(builder, addr, builder.emitLoad(tempVar)); use->set(tempVar); } @@ -156,19 +153,19 @@ struct AddressInstEliminationContext continue; } - IRBuilder builder(module); - IRBuilderSourceLocRAII sourceLocationScope(&builder, use->getUser()->sourceLoc); + IRBuilder transformBuilder(module); + IRBuilderSourceLocRAII sourceLocationScope(&transformBuilder, use->getUser()->sourceLoc); switch (use->getUser()->getOp()) { case kIROp_Load: - transformLoadAddr(builder, use); + transformLoadAddr(transformBuilder, use); break; case kIROp_Store: - transformStoreAddr(builder, use); + transformStoreAddr(transformBuilder, use); break; case kIROp_Call: - transformCallAddr(builder, use); + transformCallAddr(transformBuilder, use); break; case kIROp_GetElementPtr: case kIROp_FieldAddress: diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index bffe27abad..ad19d73a6c 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -208,9 +208,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns case kIROp_Add: { auto diffAdd = builder->emitAdd(diffType, diffLeft, diffRight); - diffAdd->sourceLoc = origArith->sourceLoc; builder->markInstAsDifferential(diffAdd, resultType); - return InstPair(primalArith, diffAdd); } @@ -223,20 +221,13 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns auto diffAdd = builder->emitAdd(diffType, diffLeftTimesRight, diffRightTimesLeft); builder->markInstAsDifferential(diffAdd, resultType); - - diffLeftTimesRight->sourceLoc = origArith->sourceLoc; - diffRightTimesLeft->sourceLoc = origArith->sourceLoc; - diffAdd->sourceLoc = origArith->sourceLoc; - return InstPair(primalArith, diffAdd); } case kIROp_Sub: { auto diffSub = builder->emitSub(diffType, diffLeft, diffRight); - diffSub->sourceLoc = origArith->sourceLoc; builder->markInstAsDifferential(diffSub, resultType); - return InstPair(primalArith, diffSub); } case kIROp_Div: @@ -261,7 +252,6 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns builder->markInstAsDifferential(diff, resultType); } - diff->sourceLoc = origArith->sourceLoc; return InstPair(primalArith, diff); } else @@ -280,13 +270,6 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns auto diffDiv = builder->emitDiv(diffType, diffSub, diffMul); builder->markInstAsDifferential(diffDiv, resultType); - - diffLeftTimesRight->sourceLoc = origArith->sourceLoc; - diffRightTimesLeft->sourceLoc = origArith->sourceLoc; - diffSub->sourceLoc = origArith->sourceLoc; - diffMul->sourceLoc = origArith->sourceLoc; - diffDiv->sourceLoc = origArith->sourceLoc; - return InstPair(primalArith, diffDiv); } } @@ -368,10 +351,6 @@ InstPair ForwardDiffTranscriber::transcribeLoad(IRBuilder* builder, IRLoad* orig auto primalElement = builder->emitDifferentialPairGetPrimal(load); auto diffElement = builder->emitDifferentialPairGetDifferential(as(diffType), load); - load->sourceLoc = origLoad->sourceLoc; - primalElement->sourceLoc = origLoad->sourceLoc; - diffElement->sourceLoc = origLoad->sourceLoc; - return InstPair(primalElement, diffElement); } } @@ -382,7 +361,6 @@ InstPair ForwardDiffTranscriber::transcribeLoad(IRBuilder* builder, IRLoad* orig { // Default case, we're loading from a known differential inst. diffLoad = as(builder->emitLoad(diffPtr)); - diffLoad->sourceLoc = origLoad->sourceLoc; } return InstPair(primalLoad, diffLoad); } @@ -407,9 +385,6 @@ InstPair ForwardDiffTranscriber::transcribeStore(IRBuilder* builder, IRStore* or auto store = builder->emitStore(primalStoreLocation, valToStore); builder->markInstAsMixedDifferential(store, diffPairType); - valToStore->sourceLoc = origStore->sourceLoc; - store->sourceLoc = origStore->sourceLoc; - return InstPair(store, nullptr); } } @@ -426,8 +401,6 @@ InstPair ForwardDiffTranscriber::transcribeStore(IRBuilder* builder, IRStore* or { // Default case, storing the entire type (and not a member) diffStore = as(builder->emitStore(diffStoreLocation, diffStoreVal)); - diffStore->sourceLoc = origStore->sourceLoc; - return InstPair(primalStore, diffStore); } @@ -543,7 +516,6 @@ InstPair ForwardDiffTranscriber::transcribeMakeStruct(IRBuilder* builder, IRInst dzero = getDifferentialZeroOfType(builder, as(diffFieldOperandType)); } - dzero->sourceLoc = origMakeStruct->sourceLoc; diffOperands.add(dzero); } ii++; @@ -675,8 +647,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig diffCallee = builder->emitForwardDifferentiateInst( differentiateFunctionType(builder, primalCallee, as(primalCallee->getFullType())), primalCallee); - - diffCallee->sourceLoc = origCall->sourceLoc; } if (!diffCallee) @@ -695,7 +665,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig SLANG_RELEASE_ASSERT(diffCalleeType->getParamCount() == origCall->getArgCount()); auto placeholderCall = builder->emitCallInst(nullptr, builder->emitUndefined(builder->getTypeKind()), 0, nullptr); - placeholderCall->sourceLoc = origCall->sourceLoc; builder->setInsertBefore(placeholderCall); IRBuilder argBuilder = *builder; @@ -733,7 +702,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig { // Create temp var to pass in/out arguments. auto srcVar = argBuilder.emitVar(pairValType); - srcVar->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsMixedDifferential(srcVar, pairValType->getValueType()); @@ -742,7 +710,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig { // Set initial value. auto primalVal = argBuilder.emitLoad(primalArg); - primalVal->sourceLoc = origCall->sourceLoc; auto diffArgVal = diffArg; if (!diffArg) @@ -750,15 +717,12 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig else { diffArgVal = argBuilder.emitLoad(diffArg); - diffArgVal->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsDifferential(diffArgVal, pairValType->getValueType()); } auto initVal = argBuilder.emitMakeDifferentialPair(pairValType, primalVal, diffArgVal); - initVal->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsMixedDifferential(initVal, primalType); auto store = argBuilder.emitStore(srcVar, initVal); - store->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsMixedDifferential(store, primalType); } if (as(ptrParamType)) @@ -766,23 +730,18 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig // Read back new value. auto newVal = afterBuilder.emitLoad(srcVar); afterBuilder.markInstAsMixedDifferential(newVal, pairValType->getValueType()); - newVal->sourceLoc = origCall->sourceLoc; auto newPrimalVal = afterBuilder.emitDifferentialPairGetPrimal(pairValType->getValueType(), newVal); - newPrimalVal->sourceLoc = origCall->sourceLoc; - auto store = afterBuilder.emitStore(primalArg, newPrimalVal); - store->sourceLoc = origCall->sourceLoc; + afterBuilder.emitStore(primalArg, newPrimalVal); if (diffArg) { auto newDiffVal = afterBuilder.emitDifferentialPairGetDifferential((IRType*)diffType, newVal); afterBuilder.markInstAsDifferential(newDiffVal, pairValType->getValueType()); - newDiffVal->sourceLoc = origCall->sourceLoc; auto storeInst = afterBuilder.emitStore(diffArg, newDiffVal); afterBuilder.markInstAsDifferential(storeInst, pairValType->getValueType()); - storeInst->sourceLoc = origCall->sourceLoc; } } args.add(srcVar); @@ -798,7 +757,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig SLANG_RELEASE_ASSERT(diffArg); auto diffPair = argBuilder.emitMakeDifferentialPair(pairType, primalArg, diffArg); - diffPair->sourceLoc = origCall->sourceLoc; argBuilder.markInstAsMixedDifferential(diffPair, pairType); @@ -826,7 +784,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig diffCallee, args); - callInst->sourceLoc = origCall->sourceLoc; placeholderCall->removeAndDeallocate(); argBuilder.markInstAsMixedDifferential(callInst, diffReturnType); argBuilder.addAutoDiffOriginalValueDecoration(callInst, primalCallee); @@ -838,8 +795,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig auto diffType = differentiateType(&afterBuilder, origCall->getFullType()); IRInst* primalResultValue = afterBuilder.emitDifferentialPairGetPrimal(callInst); IRInst* diffResultValue = afterBuilder.emitDifferentialPairGetDifferential(diffType, callInst); - primalResultValue->sourceLoc = origCall->sourceLoc; - diffResultValue->sourceLoc = origCall->sourceLoc; return InstPair(primalResultValue, diffResultValue); } else @@ -1215,7 +1170,6 @@ InstPair ForwardDiffTranscriber::transcribeUpdateElement(IRBuilder* builder, IRI auto primalVal = findOrTranscribePrimalInst(builder, origVal); IRInst* primalUpdateField = builder->emitUpdateElement(primalBase, primalAccessChain.getArrayView(), primalVal); - primalUpdateField->sourceLoc = originalInst->sourceLoc; IRInst* diffUpdateElement = nullptr; List diffAccessChain; @@ -1254,14 +1208,12 @@ InstPair ForwardDiffTranscriber::transcribeUpdateElement(IRBuilder* builder, IRI { auto primalElementType = primalVal->getDataType(); auto zeroElementDiff = getDifferentialZeroOfType(builder, primalElementType); - zeroElementDiff->sourceLoc = originalInst->sourceLoc; diffUpdateElement = builder->emitUpdateElement(diffBase, diffAccessChain.getArrayView(), zeroElementDiff); builder->addPrimalElementTypeDecoration(diffUpdateElement, primalElementType); } } - diffUpdateElement->sourceLoc = originalInst->sourceLoc; return InstPair(primalUpdateField, diffUpdateElement); } @@ -1402,9 +1354,6 @@ InstPair ForwardDiffTranscriber::transcribeDifferentialPairGetElement(IRBuilder* diffResultType = diffValPairType->getValueType(); auto diffResult = builder->emitIntrinsicInst((IRType*)diffResultType, origInst->getOp(), 1, &diffVal); - primalResult->sourceLoc = origInst->sourceLoc; - diffResult->sourceLoc = origInst->sourceLoc; - return InstPair(primalResult, diffResult); } @@ -1676,10 +1625,6 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) value = builder.emitDefaultConstruct(ptrType->getValueType()); store = builder.emitStore(tempVar, value); } - - tempVar->sourceLoc = param->sourceLoc; - store->sourceLoc = param->sourceLoc; - value->sourceLoc = param->sourceLoc; } for (auto block : func->getBlocks()) @@ -1691,9 +1636,7 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) builder.setInsertBefore(inst); for (const auto& [param, var] : mapParamToTempVar) { auto value = builder.emitLoad(var); - auto store = builder.emitStore(param, value); - value->sourceLoc = inst->sourceLoc; - store->sourceLoc = inst->sourceLoc; + builder.emitStore(param, value); } } } @@ -1821,7 +1764,6 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr if (writeBack.value.differential) { auto diffVal = builder.emitLoad(writeBack.value.differential); - diffVal->sourceLoc = writeBack.value.differential->sourceLoc; builder.markInstAsDifferential(diffVal, primalVal->getFullType()); @@ -1840,10 +1782,6 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr { builder.markInstAsMixedDifferential(storeInst, valToStore->getFullType()); } - - primalVal->sourceLoc = writeBack.value.primal->sourceLoc; - valToStore->sourceLoc = inst->sourceLoc; - storeInst->sourceLoc = inst->sourceLoc; } } } @@ -2111,7 +2049,6 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam if (auto diffPairType = tryGetDiffPairType(builder, (IRType*)origParam->getFullType())) { IRInst* diffPairParam = builder->emitParam(diffPairType); - diffPairParam->sourceLoc = origParam->sourceLoc; auto diffPairVarName = makeDiffPairName(origParam); if (diffPairVarName.getLength() > 0) @@ -2126,9 +2063,6 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam (IRType*)differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, pairType), diffPairParam); - primal->sourceLoc = origParam->sourceLoc; - differential->sourceLoc = origParam->sourceLoc; - return InstPair(primal, differential); } else if (auto pairPtrType = as(diffPairType)) @@ -2152,28 +2086,17 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam else { auto initVal = builder->emitLoad(diffPairParam); - initVal->sourceLoc = origParam->sourceLoc; - builder->markInstAsMixedDifferential(initVal, ptrInnerPairType); - primalInitVal = builder->emitDifferentialPairGetPrimal(initVal); diffInitVal = builder->emitDifferentialPairGetDifferential(diffType, initVal); - - primalInitVal->sourceLoc = origParam->sourceLoc; - diffInitVal->sourceLoc = origParam->sourceLoc; } builder->markInstAsDifferential(diffInitVal, ptrInnerPairType->getValueType()); - auto primalStore = builder->emitStore(primal, primalInitVal); + builder->emitStore(primal, primalInitVal); auto diffStore = builder->emitStore(diff, diffInitVal); builder->markInstAsDifferential(diffStore, ptrInnerPairType->getValueType()); mapInOutParamToWriteBackValue[diffPairParam] = InstPair(primal, diff); - primal->sourceLoc = origParam->sourceLoc; - diff->sourceLoc = origParam->sourceLoc; - primalStore->sourceLoc = origParam->sourceLoc; - diffStore->sourceLoc = origParam->sourceLoc; - return InstPair(primal, diff); } } diff --git a/source/slang/slang-ir-autodiff-transcriber-base.cpp b/source/slang/slang-ir-autodiff-transcriber-base.cpp index 41f4bfe3dd..1fa76c7303 100644 --- a/source/slang/slang-ir-autodiff-transcriber-base.cpp +++ b/source/slang/slang-ir-autodiff-transcriber-base.cpp @@ -505,7 +505,6 @@ InstPair AutoDiffTranscriberBase::transcribeParam(IRBuilder* builder, IRParam* o if (IRType* diffType = differentiateType(builder, (IRType*)origParam->getDataType())) { diff = builder->emitParam(diffType); - diff->sourceLoc = origParam->sourceLoc; } return InstPair(primal, diff); } @@ -1034,12 +1033,9 @@ InstPair AutoDiffTranscriberBase::transcribeInst(IRBuilder* builder, IRInst* ori if (as(origInst->getParent()) && !as(origInst)) return InstPair(origInst, nullptr); - auto result = transcribeInstImpl(builder, origInst); - if (result.primal) - result.primal->sourceLoc = origInst->sourceLoc; - if (result.differential) - result.differential->sourceLoc = origInst->sourceLoc; + IRBuilderSourceLocRAII sourceLocationScope(builder, origInst->sourceLoc); + auto result = transcribeInstImpl(builder, origInst); if (result.primal == nullptr && result.differential == nullptr) { if (auto origType = as(origInst)) From 6f82f6ed76769160f14cb7f71508259ef234087b Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 12:45:06 -0700 Subject: [PATCH 25/32] Fix local var adaptation to use RAII location setter --- .../slang/slang-ir-addr-inst-elimination.cpp | 2 +- source/slang/slang-ir-autodiff-fwd.cpp | 47 +++++++------------ .../slang/slang-ir-autodiff-primal-hoist.cpp | 17 +++---- source/slang/slang-ir-init-local-var.cpp | 13 +++-- 4 files changed, 31 insertions(+), 48 deletions(-) diff --git a/source/slang/slang-ir-addr-inst-elimination.cpp b/source/slang/slang-ir-addr-inst-elimination.cpp index 9d3605c8cf..b55f6b93d8 100644 --- a/source/slang/slang-ir-addr-inst-elimination.cpp +++ b/source/slang/slang-ir-addr-inst-elimination.cpp @@ -53,7 +53,7 @@ struct AddressInstEliminationContext break; } } - endLoop: + endLoop:; auto lastAddr = accessChain.getLast(); accessChain.removeLast(); accessChain.reverse(); diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index ad19d73a6c..aa322ab98b 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -209,6 +209,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns { auto diffAdd = builder->emitAdd(diffType, diffLeft, diffRight); builder->markInstAsDifferential(diffAdd, resultType); + return InstPair(primalArith, diffAdd); } @@ -221,6 +222,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns auto diffAdd = builder->emitAdd(diffType, diffLeftTimesRight, diffRightTimesLeft); builder->markInstAsDifferential(diffAdd, resultType); + return InstPair(primalArith, diffAdd); } @@ -228,6 +230,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns { auto diffSub = builder->emitSub(diffType, diffLeft, diffRight); builder->markInstAsDifferential(diffSub, resultType); + return InstPair(primalArith, diffSub); } case kIROp_Div: @@ -251,7 +254,6 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns diff = builder->emitDiv(diffType, diffLeft, primalRight); builder->markInstAsDifferential(diff, resultType); } - return InstPair(primalArith, diff); } else @@ -270,6 +272,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns auto diffDiv = builder->emitDiv(diffType, diffSub, diffMul); builder->markInstAsDifferential(diffDiv, resultType); + return InstPair(primalArith, diffDiv); } } @@ -665,7 +668,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig SLANG_RELEASE_ASSERT(diffCalleeType->getParamCount() == origCall->getArgCount()); auto placeholderCall = builder->emitCallInst(nullptr, builder->emitUndefined(builder->getTypeKind()), 0, nullptr); - builder->setInsertBefore(placeholderCall); IRBuilder argBuilder = *builder; IRBuilder afterBuilder = argBuilder; @@ -702,7 +704,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig { // Create temp var to pass in/out arguments. auto srcVar = argBuilder.emitVar(pairValType); - argBuilder.markInstAsMixedDifferential(srcVar, pairValType->getValueType()); auto diffArg = findOrTranscribeDiffInst(&argBuilder, origArg); @@ -710,7 +711,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig { // Set initial value. auto primalVal = argBuilder.emitLoad(primalArg); - auto diffArgVal = diffArg; if (!diffArg) diffArgVal = getDifferentialZeroOfType(builder, (IRType*)pairValType->getValueType()); @@ -721,7 +721,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig } auto initVal = argBuilder.emitMakeDifferentialPair(pairValType, primalVal, diffArgVal); argBuilder.markInstAsMixedDifferential(initVal, primalType); - auto store = argBuilder.emitStore(srcVar, initVal); argBuilder.markInstAsMixedDifferential(store, primalType); } @@ -730,9 +729,7 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig // Read back new value. auto newVal = afterBuilder.emitLoad(srcVar); afterBuilder.markInstAsMixedDifferential(newVal, pairValType->getValueType()); - auto newPrimalVal = afterBuilder.emitDifferentialPairGetPrimal(pairValType->getValueType(), newVal); - afterBuilder.emitStore(primalArg, newPrimalVal); if (diffArg) @@ -757,7 +754,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig SLANG_RELEASE_ASSERT(diffArg); auto diffPair = argBuilder.emitMakeDifferentialPair(pairType, primalArg, diffArg); - argBuilder.markInstAsMixedDifferential(diffPair, pairType); args.add(diffPair); @@ -783,7 +779,6 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig diffReturnType, diffCallee, args); - placeholderCall->removeAndDeallocate(); argBuilder.markInstAsMixedDifferential(callInst, diffReturnType); argBuilder.addAutoDiffOriginalValueDecoration(callInst, primalCallee); @@ -792,8 +787,8 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig if (diffReturnType->getOp() == kIROp_DifferentialPairType) { - auto diffType = differentiateType(&afterBuilder, origCall->getFullType()); IRInst* primalResultValue = afterBuilder.emitDifferentialPairGetPrimal(callInst); + auto diffType = differentiateType(&afterBuilder, origCall->getFullType()); IRInst* diffResultValue = afterBuilder.emitDifferentialPairGetDifferential(diffType, callInst); return InstPair(primalResultValue, diffResultValue); } @@ -1353,7 +1348,6 @@ InstPair ForwardDiffTranscriber::transcribeDifferentialPairGetElement(IRBuilder* else diffResultType = diffValPairType->getValueType(); auto diffResult = builder->emitIntrinsicInst((IRType*)diffResultType, origInst->getOp(), 1, &diffVal); - return InstPair(primalResult, diffResult); } @@ -1612,18 +1606,13 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) auto tempVar = builder.emitVar(ptrType->getValueType()); param->replaceUsesWith(tempVar); mapParamToTempVar[param] = tempVar; - - IRInst* store; - IRInst* value; if (ptrType->getOp() != kIROp_OutType) { - value = builder.emitLoad(param); - store = builder.emitStore(tempVar, value); + builder.emitStore(tempVar, builder.emitLoad(param)); } else { - value = builder.emitDefaultConstruct(ptrType->getValueType()); - store = builder.emitStore(tempVar, value); + builder.emitStore(tempVar, builder.emitDefaultConstruct(ptrType->getValueType())); } } @@ -1634,10 +1623,8 @@ void insertTempVarForMutableParams(IRModule* module, IRFunc* func) if (inst->getOp() == kIROp_Return) { builder.setInsertBefore(inst); - for (const auto& [param, var] : mapParamToTempVar) { - auto value = builder.emitLoad(var); - builder.emitStore(param, value); - } + for (const auto& [param, var] : mapParamToTempVar) + builder.emitStore(param, builder.emitLoad(var)); } } } @@ -1764,7 +1751,6 @@ InstPair ForwardDiffTranscriber::transcribeFunc(IRBuilder* inBuilder, IRFunc* pr if (writeBack.value.differential) { auto diffVal = builder.emitLoad(writeBack.value.differential); - builder.markInstAsDifferential(diffVal, primalVal->getFullType()); valToStore = builder.emitMakeDifferentialPair(cast(param->getFullType())->getValueType(), @@ -2058,12 +2044,11 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam if (auto pairType = as(diffPairType)) { - auto primal = builder->emitDifferentialPairGetPrimal(diffPairParam); - auto differential = builder->emitDifferentialPairGetDifferential( - (IRType*)differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, pairType), - diffPairParam); - - return InstPair(primal, differential); + return InstPair( + builder->emitDifferentialPairGetPrimal(diffPairParam), + builder->emitDifferentialPairGetDifferential( + (IRType*)differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, pairType), + diffPairParam)); } else if (auto pairPtrType = as(diffPairType)) { @@ -2087,16 +2072,18 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam { auto initVal = builder->emitLoad(diffPairParam); builder->markInstAsMixedDifferential(initVal, ptrInnerPairType); + primalInitVal = builder->emitDifferentialPairGetPrimal(initVal); diffInitVal = builder->emitDifferentialPairGetDifferential(diffType, initVal); } builder->markInstAsDifferential(diffInitVal, ptrInnerPairType->getValueType()); + builder->emitStore(primal, primalInitVal); + auto diffStore = builder->emitStore(diff, diffInitVal); builder->markInstAsDifferential(diffStore, ptrInnerPairType->getValueType()); mapInOutParamToWriteBackValue[diffPairParam] = InstPair(primal, diff); - return InstPair(primal, diff); } } diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index 4171a9bde9..ac2c40a251 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -3,8 +3,9 @@ #include "slang-ir-autodiff-region.h" #include "slang-ir-simplify-cfg.h" #include "slang-ir-util.h" -#include "../core/slang-func-ptr.h" +#include "slang-ir-insts.h" #include "slang-ir.h" +#include "../core/slang-func-ptr.h" namespace Slang { @@ -1102,17 +1103,14 @@ IRVar* emitIndexedLocalVar( SLANG_RELEASE_ASSERT(!as(baseType)); IRBuilder varBuilder(varBlock->getModule()); + IRBuilderSourceLocRAII sourceLocationScope(&varBuilder, location); + varBuilder.setInsertBefore(varBlock->getFirstOrdinaryInst()); IRType* varType = getTypeForLocalStorage(&varBuilder, baseType, defBlockIndices); auto var = varBuilder.emitVar(varType); - auto defaultVal = varBuilder.emitDefaultConstruct(varType); - auto storeInit = varBuilder.emitStore(var, defaultVal); - - var->sourceLoc = location; - defaultVal->sourceLoc = location; - storeInit->sourceLoc = location; + varBuilder.emitStore(var, varBuilder.emitDefaultConstruct(varType)); return var; } @@ -1750,6 +1748,8 @@ static IRBlock* getUpdateBlock(IRLoop* loop) void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalCountParam, IRInst*& diffCountParam) { IRBuilder builder(primalLoop); + IRBuilderSourceLocRAII sourceLocationScope(&builder, primalLoop->sourceLoc); + primalCountParam = nullptr; // Grab first primal block. @@ -1760,7 +1760,6 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC primalInitBlock->getTerminator())->getTargetBlock(); builder.setInsertBefore(primalInitBlock->getTerminator()); - SourceLoc loc = primalLoop->sourceLoc; auto phiCounterArgLoopEntryIndex = addPhiOutputArg( &builder, primalInitBlock, @@ -1776,7 +1775,6 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC builder.addLoopCounterDecoration(primalCountParam); builder.addNameHintDecoration(primalCountParam, UnownedStringSlice("_pc")); builder.markInstAsPrimal(primalCountParam); - primalCountParam->sourceLoc = loc; IRBlock* primalUpdateBlock = getUpdateBlock(primalLoop); IRInst* terminator = primalUpdateBlock->getTerminator(); @@ -1828,7 +1826,6 @@ void lowerIndexedRegion(IRLoop*& primalLoop, IRLoop*& diffLoop, IRInst*& primalC diffCountParam, builder.getIntValue(builder.getIntType(), 1)); builder.markInstAsPrimal(decCounterVal); - // TODO: sourceLoc for _dc here? auto phiCounterArgLoopCycleIndex = addPhiOutputArg(&builder, diffUpdateBlock, terminator, decCounterVal); diff --git a/source/slang/slang-ir-init-local-var.cpp b/source/slang/slang-ir-init-local-var.cpp index d9b9d3f499..fa556bc58e 100644 --- a/source/slang/slang-ir-init-local-var.cpp +++ b/source/slang/slang-ir-init-local-var.cpp @@ -48,14 +48,13 @@ void initializeLocalVariables(IRModule* module, IRGlobalValueWithCode* func) if (initialized) continue; + IRBuilderSourceLocRAII sourceLocationScope(&builder, inst->sourceLoc); + builder.setInsertAfter(inst); - - auto valueType = as(inst->getFullType())->getValueType(); - auto construct = builder.emitDefaultConstruct(valueType); - auto store = builder.emitStore(inst, construct); - - construct->sourceLoc = inst->sourceLoc; - store->sourceLoc = inst->sourceLoc; + builder.emitStore( + inst, + builder.emitDefaultConstruct( + as(inst->getFullType())->getValueType())); } } } From 83c68c1383bf43fded7c6ba5857519152fb605cc Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 13:19:18 -0700 Subject: [PATCH 26/32] Simplify primal hoisting logic for source location transfer --- source/slang/slang-ir-autodiff-fwd.cpp | 47 ++++++++++--------- .../slang/slang-ir-autodiff-primal-hoist.cpp | 31 ++++++------ source/slang/slang-ir-clone.cpp | 1 - 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index aa322ab98b..2bc0e8e9e7 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -209,7 +209,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns { auto diffAdd = builder->emitAdd(diffType, diffLeft, diffRight); builder->markInstAsDifferential(diffAdd, resultType); - + return InstPair(primalArith, diffAdd); } @@ -230,7 +230,7 @@ InstPair ForwardDiffTranscriber::transcribeBinaryArith(IRBuilder* builder, IRIns { auto diffSub = builder->emitSub(diffType, diffLeft, diffRight); builder->markInstAsDifferential(diffSub, resultType); - + return InstPair(primalArith, diffSub); } case kIROp_Div: @@ -350,10 +350,9 @@ InstPair ForwardDiffTranscriber::transcribeLoad(IRBuilder* builder, IRLoad* orig auto load = builder->emitLoad(primalPtr); builder->markInstAsMixedDifferential(load, diffPairType); - auto diffType = differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, diffPairType); auto primalElement = builder->emitDifferentialPairGetPrimal(load); - auto diffElement = builder->emitDifferentialPairGetDifferential(as(diffType), load); - + auto diffElement = builder->emitDifferentialPairGetDifferential( + (IRType*)differentiableTypeConformanceContext.getDiffTypeFromPairType(builder, diffPairType), load); return InstPair(primalElement, diffElement); } } @@ -403,7 +402,9 @@ InstPair ForwardDiffTranscriber::transcribeStore(IRBuilder* builder, IRStore* or if (diffStoreLocation && diffStoreVal) { // Default case, storing the entire type (and not a member) - diffStore = as(builder->emitStore(diffStoreLocation, diffStoreVal)); + diffStore = as( + builder->emitStore(diffStoreLocation, diffStoreVal)); + return InstPair(primalStore, diffStore); } @@ -502,11 +503,10 @@ InstPair ForwardDiffTranscriber::transcribeMakeStruct(IRBuilder* builder, IRInst auto operandDataType = origMakeStruct->getOperand(ii)->getDataType(); auto diffOperandType = differentiateType(builder, operandDataType); - IRInst* dzero; if (diffOperandType) { operandDataType = (IRType*)findOrTranscribePrimalInst(builder, operandDataType); - dzero = getDifferentialZeroOfType(builder, operandDataType); + diffOperands.add(getDifferentialZeroOfType(builder, operandDataType)); } else { @@ -516,21 +516,19 @@ InstPair ForwardDiffTranscriber::transcribeMakeStruct(IRBuilder* builder, IRInst // auto diffFieldOperandType = differentiateType(builder, field->getFieldType()); SLANG_RELEASE_ASSERT(diffFieldOperandType); - dzero = getDifferentialZeroOfType(builder, as(diffFieldOperandType)); + diffOperands.add(getDifferentialZeroOfType(builder, as(diffFieldOperandType))); } - - diffOperands.add(dzero); } ii++; } - auto diffMakeStruct = builder->emitIntrinsicInst( + return InstPair( + primalMakeStruct, + builder->emitIntrinsicInst( diffStructType, kIROp_MakeStruct, diffOperands.getCount(), - diffOperands.getBuffer()); - - return InstPair(primalMakeStruct, diffMakeStruct); + diffOperands.getBuffer())); } else { @@ -648,7 +646,8 @@ InstPair ForwardDiffTranscriber::transcribeCall(IRBuilder* builder, IRCall* orig // If the function is marked for auto-diff, push a `differentiate` inst for a follow up pass // to generate the implementation. diffCallee = builder->emitForwardDifferentiateInst( - differentiateFunctionType(builder, primalCallee, as(primalCallee->getFullType())), + differentiateFunctionType( + builder, primalCallee, as(primalCallee->getFullType())), primalCallee); } @@ -1164,7 +1163,8 @@ InstPair ForwardDiffTranscriber::transcribeUpdateElement(IRBuilder* builder, IRI auto origVal = updateInst->getElementValue(); auto primalVal = findOrTranscribePrimalInst(builder, origVal); - IRInst* primalUpdateField = builder->emitUpdateElement(primalBase, primalAccessChain.getArrayView(), primalVal); + IRInst* primalUpdateField = + builder->emitUpdateElement(primalBase, primalAccessChain.getArrayView(), primalVal); IRInst* diffUpdateElement = nullptr; List diffAccessChain; @@ -1196,19 +1196,20 @@ InstPair ForwardDiffTranscriber::transcribeUpdateElement(IRBuilder* builder, IRI if (auto diffVal = findOrTranscribeDiffInst(builder, origVal)) { auto primalElementType = primalVal->getDataType(); - diffUpdateElement = builder->emitUpdateElement(diffBase, diffAccessChain.getArrayView(), diffVal); + + diffUpdateElement = builder->emitUpdateElement( + diffBase, diffAccessChain.getArrayView(), diffVal); builder->addPrimalElementTypeDecoration(diffUpdateElement, primalElementType); } else { auto primalElementType = primalVal->getDataType(); auto zeroElementDiff = getDifferentialZeroOfType(builder, primalElementType); - - diffUpdateElement = builder->emitUpdateElement(diffBase, diffAccessChain.getArrayView(), zeroElementDiff); + diffUpdateElement = builder->emitUpdateElement( + diffBase, diffAccessChain.getArrayView(), zeroElementDiff); builder->addPrimalElementTypeDecoration(diffUpdateElement, primalElementType); } } - return InstPair(primalUpdateField, diffUpdateElement); } @@ -2072,14 +2073,14 @@ InstPair ForwardDiffTranscriber::transcribeFuncParam(IRBuilder* builder, IRParam { auto initVal = builder->emitLoad(diffPairParam); builder->markInstAsMixedDifferential(initVal, ptrInnerPairType); - + primalInitVal = builder->emitDifferentialPairGetPrimal(initVal); diffInitVal = builder->emitDifferentialPairGetDifferential(diffType, initVal); } builder->markInstAsDifferential(diffInitVal, ptrInnerPairType->getValueType()); builder->emitStore(primal, primalInitVal); - + auto diffStore = builder->emitStore(diff, diffInitVal); builder->markInstAsDifferential(diffStore, ptrInnerPairType->getValueType()); diff --git a/source/slang/slang-ir-autodiff-primal-hoist.cpp b/source/slang/slang-ir-autodiff-primal-hoist.cpp index ac2c40a251..f51178f0fc 100644 --- a/source/slang/slang-ir-autodiff-primal-hoist.cpp +++ b/source/slang/slang-ir-autodiff-primal-hoist.cpp @@ -1118,8 +1118,7 @@ IRVar* emitIndexedLocalVar( IRInst* emitIndexedStoreAddressForVar( IRBuilder* builder, IRVar* localVar, - const List& defBlockIndices, - SourceLoc location) + const List& defBlockIndices) { IRInst* storeAddr = localVar; for (auto& index : defBlockIndices) @@ -1127,8 +1126,6 @@ IRInst* emitIndexedStoreAddressForVar( storeAddr = builder->emitElementAddress( storeAddr, index.primalCountParam); - - storeAddr->sourceLoc = location; } return storeAddr; @@ -1193,11 +1190,9 @@ IRVar* storeIndexedValue( IRInst* addr = emitIndexedStoreAddressForVar(builder, localVar, - defBlockIndices, - instToStore->sourceLoc); + defBlockIndices); - auto store = builder->emitStore(addr, instToStore); - store->sourceLoc = instToStore->sourceLoc; + builder->emitStore(addr, instToStore); return localVar; } @@ -1589,14 +1584,15 @@ RefPtr ensurePrimalAvailability( // defBlockIndices = maybeTrimIndices(defBlockIndices, indexedBlockInfo, outOfScopeUses); - auto load = builder.emitLoad(varToStore); - load->sourceLoc = varToStore->sourceLoc; - - IRVar* localVar = storeIndexedValue( - &builder, - varBlock, - load, - defBlockIndices); + IRVar* localVar = nullptr; + { + IRBuilderSourceLocRAII sourceLocationScope(&builder, varToStore->sourceLoc); + localVar = storeIndexedValue( + &builder, + varBlock, + builder.emitLoad(varToStore), + defBlockIndices); + } for (auto use : outOfScopeUses) { @@ -1643,6 +1639,8 @@ RefPtr ensurePrimalAvailability( } else { + IRBuilderSourceLocRAII sourceLocationScope(&builder, instToStore->sourceLoc); + // Handle the special case of loop counters. // The only case where there will be a reference of primal loop counter from rev blocks // is the start of a loop in the reverse code. Since loop counters are not considered a @@ -1660,7 +1658,6 @@ RefPtr ensurePrimalAvailability( setInsertAfterOrdinaryInst(&builder, instToStore); auto localVar = storeIndexedValue(&builder, varBlock, instToStore, defBlockIndices); - localVar->sourceLoc = instToStore->sourceLoc; if (isLoopCounter) builder.addLoopCounterDecoration(localVar); diff --git a/source/slang/slang-ir-clone.cpp b/source/slang/slang-ir-clone.cpp index c8ab23f83a..a8b9b548e0 100644 --- a/source/slang/slang-ir-clone.cpp +++ b/source/slang/slang-ir-clone.cpp @@ -220,7 +220,6 @@ static void _cloneInstDecorationsAndChildren( auto oldType = oldParam->getFullType(); auto newType = (IRType*)findCloneForOperand(env, oldType); newParam->setFullType(newType); - newParam->sourceLoc = oldParam->sourceLoc; } } From a85fba7a160b7cb1a1162db377ab770241633997 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 13:35:12 -0700 Subject: [PATCH 27/32] Simplify unzipping with RAII location scopes --- source/slang/slang-ir-autodiff-fwd.cpp | 4 +-- source/slang/slang-ir-autodiff-unzip.h | 42 +++----------------------- 2 files changed, 6 insertions(+), 40 deletions(-) diff --git a/source/slang/slang-ir-autodiff-fwd.cpp b/source/slang/slang-ir-autodiff-fwd.cpp index 2bc0e8e9e7..fe7c77ba06 100644 --- a/source/slang/slang-ir-autodiff-fwd.cpp +++ b/source/slang/slang-ir-autodiff-fwd.cpp @@ -404,7 +404,7 @@ InstPair ForwardDiffTranscriber::transcribeStore(IRBuilder* builder, IRStore* or // Default case, storing the entire type (and not a member) diffStore = as( builder->emitStore(diffStoreLocation, diffStoreVal)); - + return InstPair(primalStore, diffStore); } @@ -516,7 +516,7 @@ InstPair ForwardDiffTranscriber::transcribeMakeStruct(IRBuilder* builder, IRInst // auto diffFieldOperandType = differentiateType(builder, field->getFieldType()); SLANG_RELEASE_ASSERT(diffFieldOperandType); - diffOperands.add(getDifferentialZeroOfType(builder, as(diffFieldOperandType))); + diffOperands.add(getDifferentialZeroOfType(builder, (IRType*)diffFieldOperandType)); } } ii++; diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index 2fdecf7f2e..984d4354f6 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -91,16 +91,11 @@ struct DiffUnzipPass IRInst* diffType = diffTypeContext.getDiffTypeFromPairType(builder, pairType); if (as(primalParam->getFullType())) diffType = builder->getPtrType(primalParam->getFullType()->getOp(), (IRType*)diffType); - auto primalRef = builder->emitPrimalParamRef(primalParam); auto diffRef = builder->emitDiffParamRef((IRType*)diffType, primalParam); - builder->markInstAsDifferential(diffRef, pairType->getValueType()); primalMap[primalParam] = primalRef; diffMap[primalParam] = diffRef; - - primalRef->sourceLoc = primalParam->sourceLoc; - diffRef->sourceLoc = primalParam->sourceLoc; } } @@ -251,7 +246,6 @@ struct DiffUnzipPass if (!as(intermediateType)) { intermediateVar = primalBuilder->emitVar((IRType*)intermediateType); - intermediateVar->sourceLoc = mixedCall->sourceLoc; primalBuilder->markInstAsPrimal(intermediateVar); } @@ -260,7 +254,6 @@ struct DiffUnzipPass { primalBuilder->addBackwardDerivativePrimalContextDecoration(intermediateVar, intermediateVar); primalFn = primalBuilder->emitBackwardDifferentiatePrimalInst((IRType*)primalFuncType, baseFn); - primalFn->sourceLoc = mixedCall->sourceLoc; } else { @@ -299,7 +292,6 @@ struct DiffUnzipPass } auto primalVal = primalBuilder->emitCallInst(primalType, primalFn, primalArgs); - primalVal->sourceLoc = mixedCall->sourceLoc; if (intermediateVar) primalBuilder->addBackwardDerivativePrimalContextDecoration(primalVal, intermediateVar); primalBuilder->markInstAsPrimal(primalVal); @@ -339,8 +331,6 @@ struct DiffUnzipPass auto gradArg = diffBuilder->emitLoadReverseGradient(outDiffType, diffArg); diffBuilder->markInstAsDifferential(gradArg, primalArg->getDataType()); diffArgs.add(gradArg); - - gradArg->sourceLoc = mixedCall->sourceLoc; } else if (const auto inoutType = as(primalParamType)) { @@ -360,15 +350,11 @@ struct DiffUnzipPass // Emit the temp var into the primal blocks since it's holding a primal value. auto tempPrimalVar = primalBuilder->emitVar(primalValueType); - auto storeTemp = primalBuilder->emitStore(tempPrimalVar, storedVal); + primalBuilder->emitStore(tempPrimalVar, storedVal); auto diffPairRef = diffBuilder->emitReverseGradientDiffPairRef(arg->getDataType(), tempPrimalVar, diffArg); diffBuilder->markInstAsDifferential(diffPairRef, primalValueType); diffArgs.add(diffPairRef); - - tempPrimalVar->sourceLoc = mixedCall->sourceLoc; - storeTemp->sourceLoc = mixedCall->sourceLoc; - diffPairRef->sourceLoc = mixedCall->sourceLoc; } else { @@ -382,8 +368,6 @@ struct DiffUnzipPass diffBuilder->markInstAsDifferential(pairArg, primalArg->getDataType()); diffArgs.add(pairArg); - - pairArg->sourceLoc = mixedCall->sourceLoc; } } else @@ -403,9 +387,6 @@ struct DiffUnzipPass auto storeTemp = primalBuilder->emitStore(tempPrimalVar, storedVal); diffArgs.add(tempPrimalVar); - - tempPrimalVar->sourceLoc = mixedCall->sourceLoc; - storeTemp->sourceLoc = mixedCall->sourceLoc; } else { @@ -421,7 +402,6 @@ struct DiffUnzipPass } auto newFwdCallee = diffBuilder->emitForwardDifferentiateInst(fwdCalleeType, baseFn); - newFwdCallee->sourceLoc = mixedCall->sourceLoc; diffBuilder->markInstAsDifferential(newFwdCallee); @@ -430,7 +410,6 @@ struct DiffUnzipPass newFwdCallee, diffArgs); - callInst->sourceLoc = mixedCall->sourceLoc; diffBuilder->markInstAsDifferential(callInst, primalType); if (intermediateVar) @@ -445,7 +424,6 @@ struct DiffUnzipPass { diffVal = diffBuilder->emitDifferentialPairGetDifferential(diffType, callInst); diffBuilder->markInstAsDifferential(diffVal, primalType); - diffVal->sourceLoc = callInst->sourceLoc; } return InstPair(primalVal, diffVal); } @@ -461,8 +439,6 @@ struct DiffUnzipPass auto diffPtr = lookupDiffInst(mixedLoad->getPtr()); auto primalVal = primalBuilder->emitLoad(primalPtr); auto diffVal = diffBuilder->emitLoad(diffPtr); - primalVal->sourceLoc = mixedLoad->sourceLoc; - diffVal->sourceLoc = mixedLoad->sourceLoc; diffBuilder->markInstAsDifferential(diffVal, primalVal->getFullType()); return InstPair(primalVal, diffVal); } @@ -478,9 +454,6 @@ struct DiffUnzipPass auto primalStore = primalBuilder->emitStore(primalAddr, primalVal); auto diffStore = diffBuilder->emitStore(diffAddr, diffVal); - primalStore->sourceLoc = mixedStore->sourceLoc; - diffStore->sourceLoc = mixedStore->sourceLoc; - diffBuilder->markInstAsDifferential(diffStore, primalVal->getFullType()); return InstPair(primalStore, diffStore); } @@ -492,8 +465,6 @@ struct DiffUnzipPass auto diffType = (IRType*) diffTypeContext.getDifferentialForType(primalBuilder, primalType); auto primalVar = primalBuilder->emitVar(primalType); auto diffVar = diffBuilder->emitVar(diffType); - primalVar->sourceLoc = mixedVar->sourceLoc; - diffVar->sourceLoc = mixedVar->sourceLoc; diffBuilder->markInstAsDifferential(diffVar, diffBuilder->getPtrType(primalType)); return InstPair(primalVar, diffVar); } @@ -520,7 +491,6 @@ struct DiffUnzipPass diffBuilder->markInstAsDifferential(pairVal, primalType); auto returnInst = diffBuilder->emitReturn(pairVal); - returnInst->sourceLoc = mixedReturn->sourceLoc; diffBuilder->markInstAsDifferential(returnInst, primalType); @@ -534,7 +504,6 @@ struct DiffUnzipPass primalBranch, mixedReturn->getVal()); auto returnInst = diffBuilder->emitReturn(); - returnInst->sourceLoc = mixedReturn->sourceLoc; diffBuilder->markInstAsDifferential(returnInst, nullptr); return InstPair(primalBranch, returnInst); @@ -590,9 +559,6 @@ struct DiffUnzipPass diffBuilder->addLoopMaxItersDecoration(diffLoop, maxItersDecoration->getMaxIters()); } - primalLoop->sourceLoc = mixedLoop->sourceLoc; - diffLoop->sourceLoc = mixedLoop->sourceLoc; - return InstPair(primalLoop, diffLoop); } @@ -627,9 +593,6 @@ struct DiffUnzipPass diffArgs.getCount(), diffArgs.getBuffer()); - primalBranch->sourceLoc = branchInst->sourceLoc; - diffBranch->sourceLoc = branchInst->sourceLoc; - return InstPair(primalBranch, diffBranch); } @@ -752,6 +715,9 @@ struct DiffUnzipPass void splitMixedInst(IRBuilder* primalBuilder, IRBuilder* diffBuilder, IRInst* inst) { + IRBuilderSourceLocRAII primalLocationScope(primalBuilder, inst->sourceLoc); + IRBuilderSourceLocRAII diffLocationScope(primalBuilder, inst->sourceLoc); + auto instPair = _splitMixedInst(primalBuilder, diffBuilder, inst); primalMap[inst] = instPair.primal; From e876019ce7641d427135b431ff488b671f98531e Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 14:07:30 -0700 Subject: [PATCH 28/32] Simplify transpose logic --- source/slang/slang-ir-autodiff-transpose.h | 148 ++++++--------------- source/slang/slang-ir-autodiff-unzip.cpp | 11 +- source/slang/slang-ir-autodiff-unzip.h | 28 ++-- 3 files changed, 54 insertions(+), 133 deletions(-) diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h index 438a17423b..2575d2b01c 100644 --- a/source/slang/slang-ir-autodiff-transpose.h +++ b/source/slang/slang-ir-autodiff-transpose.h @@ -609,6 +609,8 @@ struct DiffTransposePass auto nextInst = inst->getNextInst(); if (auto varInst = as(inst)) { + IRBuilderSourceLocRAII sourceLocationScope(&builder, varInst->sourceLoc); + if (isDifferentialInst(varInst) && tryGetPrimalTypeFromDiffInst(varInst)) { if (auto ptrPrimalType = as(tryGetPrimalTypeFromDiffInst(varInst))) @@ -616,10 +618,7 @@ struct DiffTransposePass varInst->insertAtEnd(firstRevDiffBlock); auto dzero = emitDZeroOfDiffInstType(&builder, ptrPrimalType->getValueType()); - auto store = builder.emitStore(varInst, dzero); - - dzero->sourceLoc = varInst->sourceLoc; - store->sourceLoc = varInst->sourceLoc; + builder.emitStore(varInst, dzero); } else { @@ -695,9 +694,7 @@ struct DiffTransposePass SLANG_ASSERT(lastRevBlock->getTerminator() == nullptr); builder.setInsertInto(lastRevBlock); - - auto returnVal = builder.emitReturn(); - returnVal->sourceLoc = revDiffFunc->sourceLoc; + builder.emitReturn()->sourceLoc = revDiffFunc->sourceLoc; // Remove fwd-mode blocks. for (auto block : workList) @@ -708,11 +705,11 @@ struct DiffTransposePass IRInst* extractAccumulatorVarGradient(IRBuilder* builder, IRInst* fwdInst) { + IRBuilderSourceLocRAII sourceLocationScope(builder, fwdInst->sourceLoc); + if (auto accVar = getOrCreateAccumulatorVar(fwdInst)) { auto gradValue = builder->emitLoad(accVar); - gradValue->sourceLoc = fwdInst->sourceLoc; - builder->emitStore( accVar, emitDZeroOfDiffInstType( @@ -738,6 +735,7 @@ struct DiffTransposePass return revAccumulatorVarMap[fwdInst]; IRBuilder tempVarBuilder(autodiffContext->moduleInst->getModule()); + IRBuilderSourceLocRAII sourceLocationSCope(&tempVarBuilder, fwdInst->sourceLoc); IRBlock* firstDiffBlock = firstRevDiffBlockMap[as(fwdInst->getParent()->getParent())]; @@ -754,12 +752,9 @@ struct DiffTransposePass // Emit a var in the top-level differential block to hold the gradient, // and initialize it. auto tempRevVar = tempVarBuilder.emitVar(diffType); - auto tempRevStore = tempVarBuilder.emitStore(tempRevVar, zero); + tempVarBuilder.emitStore(tempRevVar, zero); revAccumulatorVarMap[fwdInst] = tempRevVar; - tempRevVar->sourceLoc = fwdInst->sourceLoc; - tempRevStore->sourceLoc = fwdInst->sourceLoc; - return tempRevVar; } @@ -795,6 +790,8 @@ struct DiffTransposePass for (UIndex ii = 0; ii < branchInst->getArgCount(); ii++) { auto arg = branchInst->getArg(ii); + + IRBuilderSourceLocRAII sourceLocationScope(&builder, arg->sourceLoc); if (isDifferentialInst(arg)) { // If the arg is a differential, emit a parameter @@ -803,7 +800,6 @@ struct DiffTransposePass auto diffType = arg->getDataType(); auto revParam = builder.emitParam(diffType); - revParam->sourceLoc = arg->sourceLoc; addRevGradientForFwdInst( arg, @@ -896,6 +892,8 @@ struct DiffTransposePass List phiParamRevGradInsts; for (IRParam* param = fwdBlock->getFirstParam(); param; param = param->getNextParam()) { + IRBuilderSourceLocRAII sourceLocationScope(&builder, param->sourceLoc); + if (isDifferentialInst(param)) { // This param might be used outside this block. @@ -915,16 +913,14 @@ struct DiffTransposePass auto gradInst = emitAggregateValue( &builder, tryGetPrimalTypeFromDiffInst(param), - gradients, - param->sourceLoc); + gradients); phiParamRevGradInsts.add(gradInst); } else { - auto dzero = emitDZeroOfDiffInstType(&builder, tryGetPrimalTypeFromDiffInst(param)); - dzero->sourceLoc = param->sourceLoc; - phiParamRevGradInsts.add(dzero); + phiParamRevGradInsts.add( + emitDZeroOfDiffInstType(&builder, tryGetPrimalTypeFromDiffInst(param))); } } else @@ -962,19 +958,19 @@ struct DiffTransposePass if (auto accVar = getOrCreateAccumulatorVar(externInst)) { + IRBuilderSourceLocRAII sourceLocationScope(&builder, externInst->sourceLoc); + // Accumulate all gradients, including our accumulator variable, // into one inst. // auto gradients = popRevGradients(externInst); auto loaded = builder.emitLoad(accVar); - loaded->sourceLoc = externInst->sourceLoc; gradients.add(RevGradient(externInst, loaded, nullptr)); auto gradInst = emitAggregateValue( &builder, primalType, - gradients, - externInst->sourceLoc); + gradients); builder.emitStore(accVar, gradInst); } @@ -1066,8 +1062,8 @@ struct DiffTransposePass // Emit the aggregate of all the gradients here. // This will form the total derivative for this inst. - auto revValue = emitAggregateValue(builder, primalType, gradients, inst->sourceLoc); - + IRBuilderSourceLocRAII sourceLocationScope(builder, inst->sourceLoc); + auto revValue = emitAggregateValue(builder, primalType, gradients); auto transposeResult = transposeInst(builder, inst, revValue); if (auto fwdNameHint = inst->findDecoration()) @@ -1161,13 +1157,7 @@ struct DiffTransposePass auto diffVal = builder->emitLoad(instPair->getDiff()); auto pairVal = builder->emitMakeDifferentialPair(pairType, primalVal, diffVal); - auto store = builder->emitStore(tempVar, pairVal); - - tempVar->sourceLoc = fwdCall->sourceLoc; - primalVal->sourceLoc = fwdCall->sourceLoc; - diffVal->sourceLoc = fwdCall->sourceLoc; - pairVal->sourceLoc = fwdCall->sourceLoc; - store->sourceLoc = fwdCall->sourceLoc; + builder->emitStore(tempVar, pairVal); args.add(tempVar); argTypes.add(builder->getInOutType(pairType)); @@ -1194,12 +1184,7 @@ struct DiffTransposePass makePairArg->getPrimalValue(), diffZero); - auto storeInit = builder->emitStore(var, diffPair); - - var->sourceLoc = fwdCall->sourceLoc; - diffZero->sourceLoc = fwdCall->sourceLoc; - diffPair->sourceLoc = fwdCall->sourceLoc; - storeInit->sourceLoc = fwdCall->sourceLoc; + builder->emitStore(var, diffPair); args.add(var); argTypes.add(builder->getInOutType(pairType)); @@ -1243,7 +1228,6 @@ struct DiffTransposePass auto primalContextVar = primalContextDecor->getBackwardDerivativePrimalContextVar(); auto contextLoad = builder->emitLoad(primalContextVar); - contextLoad->sourceLoc = fwdCall->sourceLoc; args.add(contextLoad); argTypes.add(as(primalContextVar->getDataType())->getValueType()); @@ -1295,11 +1279,7 @@ struct DiffTransposePass auto diffType = as(wb.destVar->getDataType())->getValueType(); auto loadedDiff = builder->emitDifferentialPairGetDifferential(diffType, loadedPair); - auto storeDiff = builder->emitStore(wb.destVar, loadedDiff); - - loadedPair->sourceLoc = fwdCall->sourceLoc; - loadedDiff->sourceLoc = fwdCall->sourceLoc; - storeDiff->sourceLoc = fwdCall->sourceLoc; + builder->emitStore(wb.destVar, loadedDiff); } List gradients; @@ -1321,10 +1301,7 @@ struct DiffTransposePass diffPairType->getValueType()); auto loaded = builder->emitLoad(args[ii]); - loaded->sourceLoc = fwdCall->sourceLoc; - auto diffPairGet = builder->emitDifferentialPairGetDifferential(diffArgType, loaded); - diffPairGet->sourceLoc = fwdCall->sourceLoc; gradients.add(RevGradient( RevGradient::Flavor::Simple, @@ -1586,7 +1563,6 @@ struct DiffTransposePass { // Re-emit a load to get the _current_ value of revPtr. auto revCurrGrad = builder->emitLoad(revPtr); - revCurrGrad->sourceLoc = fwdLoad->sourceLoc; // Add the current value to the aggregation list. gradients.add(RevGradient( @@ -1603,8 +1579,7 @@ struct DiffTransposePass auto aggregateGradient = emitAggregateValue( builder, primalType, - gradients, - fwdLoad->sourceLoc); + gradients); if (as(loadType)) { @@ -1613,18 +1588,12 @@ struct DiffTransposePass auto pairVal = builder->emitMakeDifferentialPair(loadType, primalVal, aggregateGradient); - auto store = builder->emitStore(revPtr, pairVal); - - primalPairVal->sourceLoc = fwdLoad->sourceLoc; - primalVal->sourceLoc = fwdLoad->sourceLoc; - pairVal->sourceLoc = fwdLoad->sourceLoc; - store->sourceLoc = fwdLoad->sourceLoc; + builder->emitStore(revPtr, pairVal); } else { // Store this back into the pointer. - auto store = builder->emitStore(revPtr, aggregateGradient); - store->sourceLoc = fwdLoad->sourceLoc; + builder->emitStore(revPtr, aggregateGradient); } return TranspositionResult(List()); @@ -1641,10 +1610,6 @@ struct DiffTransposePass IRInst* emptyVal = emitDZeroOfDiffInstType(builder, primalType); IRInst* storeInst = builder->emitStore(fwdStore->getPtr(), emptyVal); - revVal->sourceLoc = fwdStore->sourceLoc; - emptyVal->sourceLoc = fwdStore->sourceLoc; - storeInst->sourceLoc = fwdStore->sourceLoc; - if (auto diffPairType = as(revVal->getDataType())) { revVal = builder->emitDifferentialPairGetDifferential( @@ -1732,9 +1697,6 @@ struct DiffTransposePass auto diffVal = builder->emitDifferentialPairGetDifferentialUserCode( fwdMakePair->getDifferentialValue()->getFullType(), revValue); - primalVal->sourceLoc = fwdMakePair->sourceLoc; - diffVal->sourceLoc = fwdMakePair->sourceLoc; - gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdMakePair->getPrimalValue(), @@ -1992,8 +1954,6 @@ struct DiffTransposePass revValue, field->getKey()); - gradAtField->sourceLoc = field->sourceLoc; - SLANG_RELEASE_ASSERT(ii < fwdMakeStruct->getOperandCount()); gradients.add(RevGradient( RevGradient::Flavor::Simple, @@ -2078,9 +2038,6 @@ struct DiffTransposePass accessChain.getArrayView(), diffZero); - diffZero->sourceLoc = fwdUpdate->sourceLoc; - revRest->sourceLoc = fwdUpdate->sourceLoc; - gradients.add(RevGradient( RevGradient::Flavor::Simple, updateInst->getOldValue(), @@ -2379,11 +2336,6 @@ struct DiffTransposePass kIROp_Select, 3, List(primalCondition, rightZero, revValue).getBuffer()); - - leftZero->sourceLoc = fwdInst->sourceLoc; - leftGradientInst->sourceLoc = fwdInst->sourceLoc; - rightZero->sourceLoc = fwdInst->sourceLoc; - rightGradientInst->sourceLoc = fwdInst->sourceLoc; return TranspositionResult( List( @@ -2679,7 +2631,7 @@ struct DiffTransposePass return materializeSimpleGradients(builder, aggPrimalType, simpleGradients); } - RevGradient materializeGradientSet(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) + RevGradient materializeGradientSet(IRBuilder* builder, IRType* aggPrimalType, List gradients) { switch (gradients[0].flavor) { @@ -2690,10 +2642,10 @@ struct DiffTransposePass return materializeSwizzleGradients(builder, aggPrimalType, gradients); case RevGradient::Flavor::FieldExtract: - return materializeFieldExtractGradients(builder, aggPrimalType, gradients, fwdLoc); + return materializeFieldExtractGradients(builder, aggPrimalType, gradients); case RevGradient::Flavor::GetElement: - return materializeGetElementGradients(builder, aggPrimalType, gradients, fwdLoc); + return materializeGetElementGradients(builder, aggPrimalType, gradients); case RevGradient::Flavor::DifferentialPairGetElementUserCode: return materializeDifferentialPairUserCodeGetElementGradients(builder, aggPrimalType, gradients); @@ -2703,7 +2655,7 @@ struct DiffTransposePass } } - RevGradient materializeGetElementGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) + RevGradient materializeGetElementGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients) { // Setup a temporary variable to aggregate gradients. // TODO: We can extend this later to grab an existing ptr to allow aggregation of @@ -2711,18 +2663,13 @@ struct DiffTransposePass // Looking up an existing pointer could also allow chained accesses like x.a.b[1] to directly // write into the specific sub-field that is affected without constructing intermediate vars. // - printf("materializing get element gradients: (%d)\n", fwdLoc.getRaw()); auto diffType = diffTypeContext.getDifferentialForType(builder, aggPrimalType); auto revGradVar = builder->emitVar(as(diffType)); - revGradVar->sourceLoc = fwdLoc; // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); auto initStore = builder->emitStore(revGradVar, zeroValueInst); - zeroValueInst->sourceLoc = fwdLoc; - initStore->sourceLoc = fwdLoc; - OrderedDictionary> bucketedGradients; for (auto gradient : gradients) { @@ -2761,27 +2708,20 @@ struct DiffTransposePass revGradVar, pair.key); - auto aggrVal = emitAggregateValue(builder, primalType, subGrads, fwdLoc); - auto storeAddress = builder->emitStore(revGradTargetAddress, aggrVal); - - revGradTargetAddress->sourceLoc = fwdLoc; - aggrVal->sourceLoc = fwdLoc; - storeAddress->sourceLoc = fwdLoc; + auto aggrVal = emitAggregateValue(builder, primalType, subGrads); + builder->emitStore(revGradTargetAddress, aggrVal); } - auto loadedRevGradVar = builder->emitLoad(revGradVar); - loadedRevGradVar->sourceLoc = fwdLoc; - // Load the entire var and return it. return RevGradient( RevGradient::Flavor::Simple, gradients[0].targetInst, - loadedRevGradVar, + builder->emitLoad(revGradVar), nullptr); } - RevGradient materializeFieldExtractGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) + RevGradient materializeFieldExtractGradients(IRBuilder* builder, IRType* aggPrimalType, List gradients) { // Setup a temporary variable to aggregate gradients. // TODO: We can extend this later to grab an existing ptr to allow aggregation of @@ -2791,15 +2731,11 @@ struct DiffTransposePass // auto diffType = diffTypeContext.getDifferentialForType(builder, aggPrimalType); auto revGradVar = builder->emitVar(as(diffType)); - revGradVar->sourceLoc = fwdLoc; // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); auto initStore = builder->emitStore(revGradVar, zeroValueInst); - zeroValueInst->sourceLoc = fwdLoc; - initStore->sourceLoc = fwdLoc; - OrderedDictionary> bucketedGradients; for (auto gradient : gradients) { @@ -2838,22 +2774,16 @@ struct DiffTransposePass revGradVar, pair.key); - auto aggrVal = emitAggregateValue(builder, primalType, subGrads, fwdLoc); - auto store = builder->emitStore(revGradTargetAddress, aggrVal); - - revGradTargetAddress->sourceLoc = fwdLoc; - aggrVal->sourceLoc = fwdLoc; - store->sourceLoc = fwdLoc; + auto aggrVal = emitAggregateValue(builder, primalType, subGrads); + builder->emitStore(revGradTargetAddress, aggrVal); } - auto loadedRevGradVar = builder->emitLoad(revGradVar); - loadedRevGradVar->sourceLoc = fwdLoc; // Load the entire var and return it. return RevGradient( RevGradient::Flavor::Simple, gradients[0].targetInst, - loadedRevGradVar, + builder->emitLoad(revGradVar), nullptr); } @@ -2886,7 +2816,7 @@ struct DiffTransposePass nullptr); } - IRInst* emitAggregateValue(IRBuilder* builder, IRType* aggPrimalType, List gradients, SourceLoc fwdLoc) + IRInst* emitAggregateValue(IRBuilder* builder, IRType* aggPrimalType, List gradients) { // If we're dealing with the differential-pair types, we need to use a different aggregation method, since // a differential pair is really a 'hybrid' primal-differential type. @@ -2930,7 +2860,7 @@ struct DiffTransposePass } // Turn the set into a simple gradient. - auto simpleGradient = materializeGradientSet(builder, aggPrimalType, gradientsOfFlavor, fwdLoc); + auto simpleGradient = materializeGradientSet(builder, aggPrimalType, gradientsOfFlavor); SLANG_ASSERT(simpleGradient.flavor == RevGradient::Flavor::Simple); simpleGradients.add(simpleGradient); diff --git a/source/slang/slang-ir-autodiff-unzip.cpp b/source/slang/slang-ir-autodiff-unzip.cpp index c688fdaad8..0953c535a5 100644 --- a/source/slang/slang-ir-autodiff-unzip.cpp +++ b/source/slang/slang-ir-autodiff-unzip.cpp @@ -387,6 +387,9 @@ IRFunc* DiffUnzipPass::extractPrimalFunc( use->set(builder.getVoidValue()); continue; } + + IRBuilderSourceLocRAII sourceLocationScope(&builder, use->getUser()->sourceLoc); + builder.setInsertBefore(use->getUser()); auto valType = cast(inst->getFullType())->getValueType(); auto val = builder.emitFieldExtract( @@ -394,8 +397,6 @@ IRFunc* DiffUnzipPass::extractPrimalFunc( intermediateVar, structKeyDecor->getStructKey()); - val->sourceLoc = use->getUser()->sourceLoc; - if (use->getUser()->getOp() == kIROp_Load) { use->getUser()->replaceUsesWith(val); @@ -404,9 +405,7 @@ IRFunc* DiffUnzipPass::extractPrimalFunc( else { auto tempVar = builder.emitVar(valType); - auto store = builder.emitStore(tempVar, val); - tempVar->sourceLoc = val->sourceLoc; - store->sourceLoc = val->sourceLoc; + builder.emitStore(tempVar, val); use->set(tempVar); } } @@ -429,9 +428,7 @@ IRFunc* DiffUnzipPass::extractPrimalFunc( inst->getFullType(), intermediateVar, structKeyDecor->getStructKey()); - val->sourceLoc = user->sourceLoc; - builder.replaceOperand(iuse, val); } } diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index 984d4354f6..a3a0a62d94 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -384,7 +384,7 @@ struct DiffUnzipPass auto storeInst = cast(storeUse->getUser()); auto storedVal = storeInst->getVal(); - auto storeTemp = primalBuilder->emitStore(tempPrimalVar, storedVal); + primalBuilder->emitStore(tempPrimalVar, storedVal); diffArgs.add(tempPrimalVar); } @@ -409,7 +409,6 @@ struct DiffUnzipPass resultType, newFwdCallee, diffArgs); - diffBuilder->markInstAsDifferential(callInst, primalType); if (intermediateVar) @@ -465,7 +464,7 @@ struct DiffUnzipPass auto diffType = (IRType*) diffTypeContext.getDifferentialForType(primalBuilder, primalType); auto primalVar = primalBuilder->emitVar(primalType); auto diffVar = diffBuilder->emitVar(diffType); - diffBuilder->markInstAsDifferential(diffVar, diffBuilder->getPtrType(primalType)); + diffBuilder->markInstAsDifferential(diffVar, diffBuilder->getPtrType(primalType)); return InstPair(primalVar, diffVar); } @@ -491,7 +490,6 @@ struct DiffUnzipPass diffBuilder->markInstAsDifferential(pairVal, primalType); auto returnInst = diffBuilder->emitReturn(pairVal); - diffBuilder->markInstAsDifferential(returnInst, primalType); return InstPair(primalBranch, returnInst); @@ -504,7 +502,6 @@ struct DiffUnzipPass primalBranch, mixedReturn->getVal()); auto returnInst = diffBuilder->emitReturn(); - diffBuilder->markInstAsDifferential(returnInst, nullptr); return InstPair(primalBranch, returnInst); } @@ -564,7 +561,6 @@ struct DiffUnzipPass InstPair splitControlFlow(IRBuilder* primalBuilder, IRBuilder* diffBuilder, IRInst* branchInst) { - // TODO: put the instructions here, then assign source loc at the end switch (branchInst->getOp()) { case kIROp_unconditionalBranch: @@ -583,17 +579,15 @@ struct DiffUnzipPass primalArgs.add(uncondBranchInst->getArg(ii)); } - auto primalBranch = primalBuilder->emitBranch( - as(primalMap[targetBlock]), - primalArgs.getCount(), - primalArgs.getBuffer()); - - auto diffBranch = diffBuilder->emitBranch( - as(diffMap[targetBlock]), - diffArgs.getCount(), - diffArgs.getBuffer()); - - return InstPair(primalBranch, diffBranch); + return InstPair( + primalBuilder->emitBranch( + as(primalMap[targetBlock]), + primalArgs.getCount(), + primalArgs.getBuffer()), + diffBuilder->emitBranch( + as(diffMap[targetBlock]), + diffArgs.getCount(), + diffArgs.getBuffer())); } case kIROp_conditionalBranch: From e4ab41756ffed7e85b3ba3b9b9cc35ab69075a62 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 14:22:54 -0700 Subject: [PATCH 29/32] Cleaning up for rev.cpp --- source/slang/slang-ir-autodiff-rev.cpp | 52 +++---------------- source/slang/slang-ir-autodiff-transpose.h | 60 +++++++++------------- 2 files changed, 33 insertions(+), 79 deletions(-) diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index de967747fc..9a34a97979 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -406,13 +406,13 @@ namespace Slang IRParam *currentParam = origFunc->getFirstParam(); for (UInt i = 0; i < origFuncType->getParamCount(); i++) { + IRBuilderSourceLocRAII sourceLocationScope(&builder, currentParam->sourceLoc); + auto primalParamType = transcribeParamTypeForPrimalFunc(&builder, origFuncType->getParamType(i)); auto propagateParamType = transcribeParamTypeForPropagateFunc(&builder, origFuncType->getParamType(i)); if (propagateParamType) { auto param = builder.emitParam(propagateParamType); - param->sourceLoc = currentParam->sourceLoc; - propagateTypes.add(propagateParamType); propagateArgs.add(param); @@ -435,12 +435,10 @@ namespace Slang { // If primal parameter is mutable, we need to pass in a temp var. auto tempVar = builder.emitVar(primalParamPtrType->getValueType()); - tempVar->sourceLoc = currentParam->sourceLoc; if (primalParamPtrType->getOp() == kIROp_InOutType) { // If the primal parameter is inout, we need to set the initial value. - auto store = builder.emitStore(tempVar, primalArg); - store->sourceLoc = currentParam->sourceLoc; + builder.emitStore(tempVar, primalArg); } primalArgs.add(tempVar); } @@ -455,7 +453,6 @@ namespace Slang SLANG_RELEASE_ASSERT(primalPtrType); auto primalValueType = primalPtrType->getValueType(); auto var = builder.emitVar(primalValueType); - var->sourceLoc = currentParam->sourceLoc; primalArgs.add(var); } primalTypes.add(primalParamType); @@ -589,7 +586,7 @@ namespace Slang // reversible. if (SLANG_FAILED(prepareFuncForBackwardDiff(primalFunc))) return diffPropagateFunc; - + // Forward transcribe the clone of the original func. ForwardDiffTranscriber& fwdTranscriber = *static_cast( autoDiffSharedContext->transcriberSet.forwardTranscriber); @@ -690,7 +687,7 @@ namespace Slang { tempBuilder.setInsertBefore(diffPropagateFunc); } - + auto fwdDiffFunc = generateNewForwardDerivativeForFunc(&tempBuilder, primalFunc, diffPropagateFunc); if (!fwdDiffFunc) return; @@ -914,6 +911,8 @@ namespace Slang // from the primal compuation logic in the future propagate function be replaced to. for (auto fwdParam : fwdParams) { + IRBuilderSourceLocRAII sourceLocationScope(builder, fwdParam->sourceLoc); + // Define the replacement insts that we are going to fill in for each case. IRInst* diffRefReplacement = nullptr; IRInst* primalRefReplacement = nullptr; @@ -968,10 +967,6 @@ namespace Slang diffWriteRefReplacement = tempVar; diffRefReplacement = tempVar; - - diffParam->sourceLoc = fwdParam->sourceLoc; - tempVar->sourceLoc = fwdParam->sourceLoc; - storeInst->sourceLoc = fwdParam->sourceLoc; } else { @@ -982,8 +977,6 @@ namespace Slang // Create a local var for the out param for the primal part of the prop func. auto tempPrimalVar = nextBlockBuilder.emitVar(outType->getValueType()); - tempPrimalVar->sourceLoc = fwdParam->sourceLoc; - copyNameHintAndDebugDecorations(tempPrimalVar, fwdParam); result.mapPrimalSpecificParamToReplacementInPropFunc[primalRefReplacement] = tempPrimalVar; @@ -1015,10 +1008,6 @@ namespace Slang auto storeInst = nextBlockBuilder.emitStore(tempPrimalVar, propParam); result.propagateFuncSpecificPrimalInsts.add(storeInst); result.mapPrimalSpecificParamToReplacementInPropFunc[primalRefReplacement] = tempPrimalVar; - - tempPrimalVar->sourceLoc = fwdParam->sourceLoc; - storeInst->sourceLoc = fwdParam->sourceLoc; - propParam->sourceLoc = fwdParam->sourceLoc; } else { @@ -1048,7 +1037,7 @@ namespace Slang auto propParam = builder->emitParam(inoutDiffPairType); copyNameHintAndDebugDecorations(propParam, fwdParam); result.propagateFuncParams.add(propParam); - + // A reference to this parameter from the diff blocks should be replaced with a load // of the differential component of the pair. auto newParamLoad = diffBuilder.emitLoad(propParam); @@ -1069,11 +1058,6 @@ namespace Slang result.propagateFuncSpecificPrimalInsts.add(primalVal); result.mapPrimalSpecificParamToReplacementInPropFunc[primalRefReplacement] = primalVal; - propParam->sourceLoc = fwdParam->sourceLoc; - newParamLoad->sourceLoc = fwdParam->sourceLoc; - primalReplacementLoad->sourceLoc = fwdParam->sourceLoc; - primalVal->sourceLoc = fwdParam->sourceLoc; - instsToRemove.add(fwdParam); } else @@ -1137,30 +1121,10 @@ namespace Slang result.propagateFuncSpecificPrimalInsts.add(storeInst); result.mapPrimalSpecificParamToReplacementInPropFunc[primalParam] = primalVar; result.outDiffWritebacks[diffParam] = InstPair(initPrimalVal, diffVar); - - primalParam->sourceLoc = fwdParam->sourceLoc; - diffParam->sourceLoc = fwdParam->sourceLoc; - loadedParam->sourceLoc = fwdParam->sourceLoc; - initDiff->sourceLoc = fwdParam->sourceLoc; - diffVar->sourceLoc = fwdParam->sourceLoc; - diffWriteVar->sourceLoc = fwdParam->sourceLoc; - dzero->sourceLoc = fwdParam->sourceLoc; - initDiffStore->sourceLoc = fwdParam->sourceLoc; - writeStore->sourceLoc = fwdParam->sourceLoc; - primalVar->sourceLoc = fwdParam->sourceLoc; - initPrimalVal->sourceLoc = fwdParam->sourceLoc; - storeInst->sourceLoc = fwdParam->sourceLoc; instsToRemove.add(fwdParam); } - if (diffRefReplacement) - diffRefReplacement->sourceLoc = fwdParam->sourceLoc; - if (primalRefReplacement) - primalRefReplacement->sourceLoc = fwdParam->sourceLoc; - if (diffWriteRefReplacement) - diffWriteRefReplacement->sourceLoc = fwdParam->sourceLoc; - // We have emitted all the new parameters and computed the replacements for the original // parameter. Now we perform that replacement. List uses; diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h index 2575d2b01c..a33a6a722c 100644 --- a/source/slang/slang-ir-autodiff-transpose.h +++ b/source/slang/slang-ir-autodiff-transpose.h @@ -964,8 +964,7 @@ struct DiffTransposePass // into one inst. // auto gradients = popRevGradients(externInst); - auto loaded = builder.emitLoad(accVar); - gradients.add(RevGradient(externInst, loaded, nullptr)); + gradients.add(RevGradient(externInst, builder.emitLoad(accVar), nullptr)); auto gradInst = emitAggregateValue( &builder, @@ -1064,6 +1063,7 @@ struct DiffTransposePass // This will form the total derivative for this inst. IRBuilderSourceLocRAII sourceLocationScope(builder, inst->sourceLoc); auto revValue = emitAggregateValue(builder, primalType, gradients); + auto transposeResult = transposeInst(builder, inst, revValue); if (auto fwdNameHint = inst->findDecoration()) @@ -1158,7 +1158,6 @@ struct DiffTransposePass auto diffVal = builder->emitLoad(instPair->getDiff()); auto pairVal = builder->emitMakeDifferentialPair(pairType, primalVal, diffVal); builder->emitStore(tempVar, pairVal); - args.add(tempVar); argTypes.add(builder->getInOutType(pairType)); argRequiresLoad.add(false); @@ -1176,15 +1175,16 @@ struct DiffTransposePass auto pairType = as(arg->getDataType()); auto var = builder->emitVar(arg->getDataType()); + auto diffZero = emitDZeroOfDiffInstType(builder, pairType->getValueType()); // Initialize this var to (arg.primal, 0). - auto diffPair = builder->emitMakeDifferentialPair( + builder->emitStore( + var, + builder->emitMakeDifferentialPair( arg->getDataType(), makePairArg->getPrimalValue(), - diffZero); - - builder->emitStore(var, diffPair); + diffZero)); args.add(var); argTypes.add(builder->getInOutType(pairType)); @@ -1230,7 +1230,9 @@ struct DiffTransposePass auto contextLoad = builder->emitLoad(primalContextVar); args.add(contextLoad); - argTypes.add(as(primalContextVar->getDataType())->getValueType()); + argTypes.add(as( + primalContextVar->getDataType()) + ->getValueType()); argRequiresLoad.add(false); } @@ -1276,7 +1278,6 @@ struct DiffTransposePass for (auto wb : writebacks) { auto loadedPair = builder->emitLoad(wb.srcTempPairVar); - auto diffType = as(wb.destVar->getDataType())->getValueType(); auto loadedDiff = builder->emitDifferentialPairGetDifferential(diffType, loadedPair); builder->emitStore(wb.destVar, loadedDiff); @@ -1300,13 +1301,11 @@ struct DiffTransposePass builder, diffPairType->getValueType()); - auto loaded = builder->emitLoad(args[ii]); - auto diffPairGet = builder->emitDifferentialPairGetDifferential(diffArgType, loaded); - gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdCall->getArg(ii), - diffPairGet, + builder->emitDifferentialPairGetDifferential( + diffArgType, builder->emitLoad(args[ii])), nullptr)); } } @@ -1608,7 +1607,7 @@ struct DiffTransposePass // Clear the value at the differential address, by setting to 0. IRInst* emptyVal = emitDZeroOfDiffInstType(builder, primalType); - IRInst* storeInst = builder->emitStore(fwdStore->getPtr(), emptyVal); + builder->emitStore(fwdStore->getPtr(), emptyVal); if (auto diffPairType = as(revVal->getDataType())) { @@ -1692,20 +1691,16 @@ struct DiffTransposePass TranspositionResult transposeMakePairUserCode(IRBuilder* builder, IRMakeDifferentialPairUserCode* fwdMakePair, IRInst* revValue) { List gradients; - - auto primalVal = builder->emitDifferentialPairGetPrimalUserCode(revValue); - auto diffVal = builder->emitDifferentialPairGetDifferentialUserCode( - fwdMakePair->getDifferentialValue()->getFullType(), revValue); - gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdMakePair->getPrimalValue(), - primalVal, + builder->emitDifferentialPairGetPrimalUserCode(revValue), fwdMakePair)); gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdMakePair->getDifferentialValue(), - diffVal, + builder->emitDifferentialPairGetDifferentialUserCode( + fwdMakePair->getDifferentialValue()->getFullType(), revValue), fwdMakePair)); return TranspositionResult(gradients); } @@ -1953,7 +1948,6 @@ struct DiffTransposePass field->getFieldType(), revValue, field->getKey()); - SLANG_RELEASE_ASSERT(ii < fwdMakeStruct->getOperandCount()); gradients.add(RevGradient( RevGradient::Flavor::Simple, @@ -2037,7 +2031,6 @@ struct DiffTransposePass revValue, accessChain.getArrayView(), diffZero); - gradients.add(RevGradient( RevGradient::Flavor::Simple, updateInst->getOldValue(), @@ -2663,12 +2656,12 @@ struct DiffTransposePass // Looking up an existing pointer could also allow chained accesses like x.a.b[1] to directly // write into the specific sub-field that is affected without constructing intermediate vars. // - auto diffType = diffTypeContext.getDifferentialForType(builder, aggPrimalType); - auto revGradVar = builder->emitVar(as(diffType)); + auto revGradVar = builder->emitVar( + (IRType*) diffTypeContext.getDifferentialForType(builder, aggPrimalType)); // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); - auto initStore = builder->emitStore(revGradVar, zeroValueInst); + builder->emitStore(revGradVar, zeroValueInst); OrderedDictionary> bucketedGradients; for (auto gradient : gradients) @@ -2708,8 +2701,7 @@ struct DiffTransposePass revGradVar, pair.key); - auto aggrVal = emitAggregateValue(builder, primalType, subGrads); - builder->emitStore(revGradTargetAddress, aggrVal); + builder->emitStore(revGradTargetAddress, emitAggregateValue(builder, primalType, subGrads)); } // Load the entire var and return it. @@ -2729,12 +2721,13 @@ struct DiffTransposePass // Looking up an existing pointer could also allow chained accesses like x.a.b[1] to directly // write into the specific sub-field that is affected without constructing intermediate vars. // - auto diffType = diffTypeContext.getDifferentialForType(builder, aggPrimalType); - auto revGradVar = builder->emitVar(as(diffType)); + auto revGradVar = builder->emitVar( + (IRType*) diffTypeContext.getDifferentialForType(builder, aggPrimalType)); // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); - auto initStore = builder->emitStore(revGradVar, zeroValueInst); + + builder->emitStore(revGradVar, zeroValueInst); OrderedDictionary> bucketedGradients; for (auto gradient : gradients) @@ -2757,7 +2750,6 @@ struct DiffTransposePass gradient.revGradInst, gradient.fwdGradInst )); - } for (auto pair : bucketedGradients) @@ -2774,10 +2766,8 @@ struct DiffTransposePass revGradVar, pair.key); - auto aggrVal = emitAggregateValue(builder, primalType, subGrads); - builder->emitStore(revGradTargetAddress, aggrVal); + builder->emitStore(revGradTargetAddress, emitAggregateValue(builder, primalType, subGrads)); } - // Load the entire var and return it. return RevGradient( From bc1587e6f39e8bd7153dd1e86aca24e92ba68ba1 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 14:35:24 -0700 Subject: [PATCH 30/32] Reverting spacing changes --- source/slang/slang-ir-autodiff-transpose.h | 10 +++++----- source/slang/slang-ir-autodiff-unzip.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h index a33a6a722c..67ae179cae 100644 --- a/source/slang/slang-ir-autodiff-transpose.h +++ b/source/slang/slang-ir-autodiff-transpose.h @@ -1063,7 +1063,7 @@ struct DiffTransposePass // This will form the total derivative for this inst. IRBuilderSourceLocRAII sourceLocationScope(builder, inst->sourceLoc); auto revValue = emitAggregateValue(builder, primalType, gradients); - + auto transposeResult = transposeInst(builder, inst, revValue); if (auto fwdNameHint = inst->findDecoration()) @@ -1300,7 +1300,6 @@ struct DiffTransposePass auto diffArgType = (IRType*)diffTypeContext.getDifferentialForType( builder, diffPairType->getValueType()); - gradients.add(RevGradient( RevGradient::Flavor::Simple, fwdCall->getArg(ii), @@ -2657,10 +2656,11 @@ struct DiffTransposePass // write into the specific sub-field that is affected without constructing intermediate vars. // auto revGradVar = builder->emitVar( - (IRType*) diffTypeContext.getDifferentialForType(builder, aggPrimalType)); + (IRType*)diffTypeContext.getDifferentialForType(builder, aggPrimalType)); // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); + builder->emitStore(revGradVar, zeroValueInst); OrderedDictionary> bucketedGradients; @@ -2722,11 +2722,11 @@ struct DiffTransposePass // write into the specific sub-field that is affected without constructing intermediate vars. // auto revGradVar = builder->emitVar( - (IRType*) diffTypeContext.getDifferentialForType(builder, aggPrimalType)); + (IRType*)diffTypeContext.getDifferentialForType(builder, aggPrimalType)); // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); - + builder->emitStore(revGradVar, zeroValueInst); OrderedDictionary> bucketedGradients; diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index a3a0a62d94..ca5b1494d4 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -578,7 +578,7 @@ struct DiffUnzipPass else primalArgs.add(uncondBranchInst->getArg(ii)); } - + return InstPair( primalBuilder->emitBranch( as(primalMap[targetBlock]), From ca83b4b6bde62b067502e754fe7669a15558f7f4 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 15:15:12 -0700 Subject: [PATCH 31/32] Fix mistake with source loc RAII instantiation --- source/slang/slang-ir-autodiff-unzip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/slang/slang-ir-autodiff-unzip.h b/source/slang/slang-ir-autodiff-unzip.h index ca5b1494d4..6ae5126f9b 100644 --- a/source/slang/slang-ir-autodiff-unzip.h +++ b/source/slang/slang-ir-autodiff-unzip.h @@ -710,7 +710,7 @@ struct DiffUnzipPass void splitMixedInst(IRBuilder* primalBuilder, IRBuilder* diffBuilder, IRInst* inst) { IRBuilderSourceLocRAII primalLocationScope(primalBuilder, inst->sourceLoc); - IRBuilderSourceLocRAII diffLocationScope(primalBuilder, inst->sourceLoc); + IRBuilderSourceLocRAII diffLocationScope(diffBuilder, inst->sourceLoc); auto instPair = _splitMixedInst(primalBuilder, diffBuilder, inst); From 1960e23d50416c709ffcecfc9600467f607b4be1 Mon Sep 17 00:00:00 2001 From: Venkataram Sivaram Date: Wed, 18 Sep 2024 15:31:15 -0700 Subject: [PATCH 32/32] Fix formatting issues --- source/slang/slang-ir-autodiff-rev.cpp | 3 ++- source/slang/slang-ir-autodiff-transpose.h | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/slang/slang-ir-autodiff-rev.cpp b/source/slang/slang-ir-autodiff-rev.cpp index 9a34a97979..2fb73c4ac9 100644 --- a/source/slang/slang-ir-autodiff-rev.cpp +++ b/source/slang/slang-ir-autodiff-rev.cpp @@ -861,7 +861,8 @@ namespace Slang } auto terminator = block->getTerminator(); - if (as(terminator)) { + if (as(terminator)) + { returnLoc = terminator->sourceLoc; break; } diff --git a/source/slang/slang-ir-autodiff-transpose.h b/source/slang/slang-ir-autodiff-transpose.h index 67ae179cae..1f8c3052ed 100644 --- a/source/slang/slang-ir-autodiff-transpose.h +++ b/source/slang/slang-ir-autodiff-transpose.h @@ -694,7 +694,11 @@ struct DiffTransposePass SLANG_ASSERT(lastRevBlock->getTerminator() == nullptr); builder.setInsertInto(lastRevBlock); - builder.emitReturn()->sourceLoc = revDiffFunc->sourceLoc; + + { + IRBuilderSourceLocRAII sourceLocationScope(&builder, revDiffFunc->sourceLoc); + builder.emitReturn(); + } // Remove fwd-mode blocks. for (auto block : workList) @@ -2660,7 +2664,7 @@ struct DiffTransposePass // Initialize with T.dzero() auto zeroValueInst = emitDZeroOfDiffInstType(builder, aggPrimalType); - + builder->emitStore(revGradVar, zeroValueInst); OrderedDictionary> bucketedGradients;