Skip to content

Commit a05accd

Browse files
committed
Handling of statement parameters for loops in forward mode.
1 parent 9726000 commit a05accd

File tree

5 files changed

+714
-569
lines changed

5 files changed

+714
-569
lines changed

regression-tests/pure2-autodiff.cpp2

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ ad_test: @autodiff @print type = {
114114
}
115115

116116
intermediate_passive_var: (x: double, y: double) -> (r: double) = {
117-
i: int = (); // TODO: Handle as passive when type information on call side is available.
117+
i: int = ();
118118
r = x + y;
119119
i = 2;
120120

@@ -143,18 +143,19 @@ ad_test: @autodiff @print type = {
143143
}
144144

145145
while_loop: (x: double, y: double) -> (r: double) = {
146-
i: int = 0;
147-
148146
r = x;
147+
148+
(copy i: int = 0, copy t: double = 0.0)
149149
while i < 2 next (i += 1) {
150-
r = r + y ;
150+
t = y;
151+
r = r + t;
151152
}
152153
}
153154

154155
do_while_loop: (x: double, y: double) -> (r: double) = {
155-
i: int = 0;
156-
157156
r = x;
157+
158+
(copy i: = 0)
158159
do {
159160
r = r + y ;
160161
}

0 commit comments

Comments
 (0)