Skip to content

Commit bae926d

Browse files
authored
Rollup merge of #147364 - ZuseZ4:update-autodiff-tests, r=jieyouxu
update autodiff testcases unblock EnzymeAD/Enzyme#2430 (again). Just as I landed a fix for the last test, this one broke. The test should now be fine if the name mangling hash changes again. Also removed an outdated fixme that's not needed since moving autodiff to an intrinsic. The test currently just checks that it compiles, I'll add more precise checks once we actually run this in CI. r? compiler
2 parents 6fef758 + 7c8fe29 commit bae926d

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

tests/codegen-llvm/autodiff/autodiffv2.rs

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,14 @@
1818
// but each shadow argument is `width` times larger (thus 16 and 20 elements here).
1919
// `d_square3` instead takes `width` (4) shadow arguments, which are all the same size as the
2020
// original function arguments.
21-
//
22-
// FIXME(autodiff): We currently can't test `d_square1` and `d_square3` in the same file, since they
23-
// generate the same dummy functions which get merged by LLVM, breaking pieces of our pipeline which
24-
// try to rewrite the dummy functions later. We should consider to change to pure declarations both
25-
// in our frontend and in the llvm backend to avoid these issues.
2621

2722
#![feature(autodiff)]
2823

2924
use std::autodiff::autodiff_forward;
3025

3126
// CHECK: ;
3227
#[no_mangle]
33-
//#[autodiff(d_square1, Forward, Dual, Dual)]
28+
#[autodiff_forward(d_square1, Dual, Dual)]
3429
#[autodiff_forward(d_square2, 4, Dualv, Dualv)]
3530
#[autodiff_forward(d_square3, 4, Dual, Dual)]
3631
fn square(x: &[f32], y: &mut [f32]) {
@@ -79,25 +74,25 @@ fn main() {
7974
let mut dy3_4 = std::hint::black_box(vec![0.0; 5]);
8075

8176
// scalar.
82-
//d_square1(&x1, &z1, &mut y1, &mut dy1_1);
83-
//d_square1(&x1, &z2, &mut y2, &mut dy1_2);
84-
//d_square1(&x1, &z3, &mut y3, &mut dy1_3);
85-
//d_square1(&x1, &z4, &mut y4, &mut dy1_4);
77+
d_square1(&x1, &z1, &mut y1, &mut dy1_1);
78+
d_square1(&x1, &z2, &mut y2, &mut dy1_2);
79+
d_square1(&x1, &z3, &mut y3, &mut dy1_3);
80+
d_square1(&x1, &z4, &mut y4, &mut dy1_4);
8681

8782
// assert y1 == y2 == y3 == y4
88-
//for i in 0..5 {
89-
// assert_eq!(y1[i], y2[i]);
90-
// assert_eq!(y1[i], y3[i]);
91-
// assert_eq!(y1[i], y4[i]);
92-
//}
83+
for i in 0..5 {
84+
assert_eq!(y1[i], y2[i]);
85+
assert_eq!(y1[i], y3[i]);
86+
assert_eq!(y1[i], y4[i]);
87+
}
9388

9489
// batch mode A)
9590
d_square2(&x1, &z5, &mut y5, &mut dy2);
9691

9792
// assert y1 == y2 == y3 == y4 == y5
98-
//for i in 0..5 {
99-
// assert_eq!(y1[i], y5[i]);
100-
//}
93+
for i in 0..5 {
94+
assert_eq!(y1[i], y5[i]);
95+
}
10196

10297
// batch mode B)
10398
d_square3(&x1, &z1, &z2, &z3, &z4, &mut y6, &mut dy3_1, &mut dy3_2, &mut dy3_3, &mut dy3_4);

tests/codegen-llvm/autodiff/identical_fnc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ fn square2(x: &f64) -> f64 {
3232
// CHECK-NOT:br
3333
// CHECK-NOT:ret
3434
// CHECK:; call identical_fnc::d_square
35-
// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square17hcb5768e95528c35fE(double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx1)
35+
// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square[[HASH:.+]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx1)
3636
// CHECK:; call identical_fnc::d_square
37-
// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square17hcb5768e95528c35fE(double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx2)
37+
// CHECK-NEXT:call fastcc void @_ZN13identical_fnc8d_square[[HASH]](double %x.val, ptr noalias noundef align 8 dereferenceable(8) %dx2)
3838

3939
fn main() {
4040
let x = std::hint::black_box(3.0);

0 commit comments

Comments
 (0)