From 8b05df4187117d61491f2fdbeb7d744146ad73f7 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 20 Feb 2023 10:17:00 -0800 Subject: Add static for loop iteration inference. (#2659) --- tests/autodiff/generic-impl-jvp.slang | 10 +++++++++- tests/autodiff/reverse-loop.slang | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'tests/autodiff') diff --git a/tests/autodiff/generic-impl-jvp.slang b/tests/autodiff/generic-impl-jvp.slang index 332833fff..98adc4a7c 100644 --- a/tests/autodiff/generic-impl-jvp.slang +++ b/tests/autodiff/generic-impl-jvp.slang @@ -24,6 +24,7 @@ struct myvector : IDifferentiable __init(T c) { + [ForceUnroll] for (int i = 0; i < N; i++) { values[i] = c; @@ -46,7 +47,7 @@ struct myvector : IDifferentiable static Differential dmul(This a, Differential b) { Differential output; - + for (int i = 0; i < N; i++) { output.values[i] = T.dmul(a.values[i], b.values[i]); @@ -73,6 +74,7 @@ __generic myvector operator +(myvector a, myvector b) { myvector output; + [ForceUnroll] for (int i = 0; i < N; i++) { output.values[i] = a.values[i] + b.values[i]; @@ -85,6 +87,7 @@ __generic myvector operator *(myvector a, myvector b) { myvector output; + [ForceUnroll] for (int i = 0; i < N; i++) { output.values[i] = a.values[i] * b.values[i]; @@ -97,6 +100,7 @@ __generic myvector operator *(T a, myvector b) { myvector output; + [ForceUnroll] for (int i = 0; i < N; i++) { output.values[i] = a * b.values[i]; @@ -109,6 +113,7 @@ __generic T dot(myvector a, myvector b) { T curr = (T)0.0; + [ForceUnroll] for (int i = 0; i < N; i++) { curr = curr + (a.values[i] * b.values[i]); @@ -125,6 +130,7 @@ DifferentialPair dot_jvp(dpvector a, dpvector b) { T.Differential curr_d = (T.dzero()); T curr_p = (T)0.0; + [ForceUnroll] for (int i = 0; i < N; i++) { curr_p = curr_p + (a.p.values[i] * b.p.values[i]); @@ -145,6 +151,7 @@ struct lineardvector : IDifferentiable __init(vector a) { + [ForceUnroll] for (int i = 0; i < N; i++) { val.values[i] = a[i]; @@ -204,6 +211,7 @@ struct linearvector : MyLinearArithmeticType, IDifferentiable [ForwardDifferentiable] __init(vector a) { + [ForceUnroll] for (int i = 0; i < N; i++) { val.values[i] = a[i]; diff --git a/tests/autodiff/reverse-loop.slang b/tests/autodiff/reverse-loop.slang index 828a06185..5598f6b71 100644 --- a/tests/autodiff/reverse-loop.slang +++ b/tests/autodiff/reverse-loop.slang @@ -13,7 +13,6 @@ float test_simple_loop(float y) { float t = y; - [MaxIters(3)] for (int i = 0; i < 3; i++) { t = t * t; -- cgit v1.2.3