Skip to content

Commit 0c8983d

Browse files
committed
Added example for non differential variable.
1 parent e1ab97b commit 0c8983d

File tree

6 files changed

+664
-512
lines changed

6 files changed

+664
-512
lines changed

regression-tests/pure2-autodiff.cpp2

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ ad_test: @autodiff @print type = {
8888

8989
r = t;
9090
}
91+
92+
intermediate_passive_var: (x: double, y: double) -> (r: double) = {
93+
i: int = (); // TODO: Handle as passive when type information on call side is available.
94+
r = x + y;
95+
i = 2;
96+
97+
_ = i;
98+
}
9199
}
92100

93101
write_output: (func: std::string, x: double, x_d: double, y: double, y_d: double, ret) = {
@@ -119,4 +127,5 @@ main: () = {
119127
write_output("if else branch", x, x_d, y, y_d, ad_test::if_else_branch_diff(x, x_d, y, y_d));
120128
write_output("direct return", x, x_d, y, y_d, ad_test::direct_return_diff(x, x_d, y, y_d));
121129
write_output("intermediate var", x, x_d, y, y_d, ad_test::intermediate_var_diff(x, x_d, y, y_d));
130+
write_output("intermediate passive var", x, x_d, y, y_d, ad_test::intermediate_passive_var_diff(x, x_d, y, y_d));
122131
}

regression-tests/test-results/gcc-13-c++2b/pure2-autodiff.cpp.execution

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ diff(if branch) at (x = 2.000000, x_d = 1.000000, y = 3.000000, y_d = 2.000000)
1616
diff(if else branch) at (x = 2.000000, x_d = 1.000000, y = 3.000000, y_d = 2.000000) = (r = 2.000000, r_d = 1.000000)
1717
diff(direct return) at (x = 2.000000, x_d = 1.000000, y = 3.000000, y_d = 2.000000) = (r = 5.000000, r_d = 3.000000)
1818
diff(intermediate var) at (x = 2.000000, x_d = 1.000000, y = 3.000000, y_d = 2.000000) = (r = 5.000000, r_d = 3.000000)
19+
diff(intermediate passive var) at (x = 2.000000, x_d = 1.000000, y = 3.000000, y_d = 2.000000) = (r = 5.000000, r_d = 3.000000)

0 commit comments

Comments
 (0)