summaryrefslogtreecommitdiff
path: root/tests/autodiff
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-02-20 10:17:00 -0800
committerGitHub <noreply@github.com>2023-02-20 10:17:00 -0800
commit8b05df4187117d61491f2fdbeb7d744146ad73f7 (patch)
treecfb17b26e9db313d0b6ce1a07efe85b35d6d1638 /tests/autodiff
parenta8da735ca4e0ed49796dda164c39e21aea4a7bc6 (diff)
Add static for loop iteration inference. (#2659)
Diffstat (limited to 'tests/autodiff')
-rw-r--r--tests/autodiff/generic-impl-jvp.slang10
-rw-r--r--tests/autodiff/reverse-loop.slang1
2 files changed, 9 insertions, 2 deletions
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<T : IDFloat, let N : int>
myvector<T, N> operator +(myvector<T, N> a, myvector<T, N> b)
{
myvector<T, N> output;
+ [ForceUnroll]
for (int i = 0; i < N; i++)
{
output.values[i] = a.values[i] + b.values[i];
@@ -85,6 +87,7 @@ __generic<T : IDFloat, let N : int>
myvector<T, N> operator *(myvector<T, N> a, myvector<T, N> b)
{
myvector<T, N> output;
+ [ForceUnroll]
for (int i = 0; i < N; i++)
{
output.values[i] = a.values[i] * b.values[i];
@@ -97,6 +100,7 @@ __generic<T : IDFloat, let N : int>
myvector<T, N> operator *(T a, myvector<T, N> b)
{
myvector<T, N> output;
+ [ForceUnroll]
for (int i = 0; i < N; i++)
{
output.values[i] = a * b.values[i];
@@ -109,6 +113,7 @@ __generic<T : IDFloat, let N : int>
T dot(myvector<T, N> a, myvector<T, N> 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<T> dot_jvp(dpvector<T, N> a, dpvector<T, N> 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<Real.Differential, N> 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<Real, N> 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;