From ba89fc84267bfd09f1c8abf10a5b85d09bbc79de Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Wed, 26 Jul 2023 17:15:21 -0400 Subject: Refactor `dmul(This, Differential)` to `dmul(T, Differential)` (#3029) * Refactor `dmul(This, Differential)` to `dmul(T, Differential)` - Add AST synthesis support for generic containers - Refactor relevant tests * Merge dmul synthesis with dadd and dzero, and disambiguate using an enum * Fix trailing spaces --- tests/autodiff/generic-impl-jvp.slang | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tests/autodiff/generic-impl-jvp.slang') diff --git a/tests/autodiff/generic-impl-jvp.slang b/tests/autodiff/generic-impl-jvp.slang index 98adc4a7c..674d5c5ca 100644 --- a/tests/autodiff/generic-impl-jvp.slang +++ b/tests/autodiff/generic-impl-jvp.slang @@ -6,7 +6,7 @@ RWStructuredBuffer outputBuffer; typedef float Real; -typealias IDFloat = IFloat & IDifferentiable; +typealias IDFloat = __BuiltinRealType & IDifferentiable; __generic struct dvector : IDifferentiable @@ -44,13 +44,13 @@ struct myvector : IDifferentiable } - static Differential dmul(This a, Differential b) + static Differential dmul(U a, Differential b) { Differential output; for (int i = 0; i < N; i++) { - output.values[i] = T.dmul(a.values[i], b.values[i]); + output.values[i] = T.dmul(a, b.values[i]); } return output; @@ -112,7 +112,7 @@ __generic [ForwardDerivative(dot_jvp)] T dot(myvector a, myvector b) { - T curr = (T)0.0; + T curr = __realCast(0.f); [ForceUnroll] for (int i = 0; i < N; i++) { @@ -129,7 +129,7 @@ __generic DifferentialPair dot_jvp(dpvector a, dpvector b) { T.Differential curr_d = (T.dzero()); - T curr_p = (T)0.0; + T curr_p = __realCast(0.f); [ForceUnroll] for (int i = 0; i < N; i++) { @@ -137,8 +137,8 @@ DifferentialPair dot_jvp(dpvector a, dpvector b) curr_d = T.dadd( curr_d, T.dadd( - T.dmul(a.p.values[i], b.d.values[i]), - T.dmul(b.p.values[i], a.d.values[i]))); + T.dmul(a.p.values[i], b.d.values[i]), + T.dmul(b.p.values[i], a.d.values[i]))); } return DifferentialPair(curr_p, curr_d); @@ -203,9 +203,9 @@ struct linearvector : MyLinearArithmeticType, IDifferentiable return { myvector.dadd(a.val, b.val) }; } - static Differential dmul(This a, Differential b) + static Differential dmul(T a, Differential b) { - return { myvector.dmul(a.val, b.val) }; + return { myvector.dmul(a, b.val) }; } [ForwardDifferentiable] -- cgit v1.2.3