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
2924use std:: autodiff:: autodiff;
3025
3126#[ no_mangle]
32- // #[autodiff(d_square1, Forward, Dual, Dual)]
27+ #[ autodiff( d_square1, Forward , Dual , Dual ) ]
3328#[ autodiff( d_square2, Forward , 4 , Dualv , Dualv ) ]
3429#[ autodiff( d_square3, Forward , 4 , Dual , Dual ) ]
3530fn square ( x : & [ f32 ] , y : & mut [ f32 ] ) {
@@ -42,6 +37,9 @@ fn square(x: &[f32], y: &mut [f32]) {
4237 y[ 4 ] = 1.0 * x[ 0 ] + 2.0 * x[ 1 ] + 3.0 * x[ 2 ] + 4.0 * x[ 3 ] ;
4338}
4439
40+ // FIXME
41+ // CHECK: start:
42+
4543fn main ( ) {
4644 let x1 = std:: hint:: black_box ( vec ! [ 0.0 , 1.0 , 2.0 , 3.0 ] ) ;
4745
@@ -78,25 +76,25 @@ fn main() {
7876 let mut dy3_4 = std:: hint:: black_box ( vec ! [ 0.0 ; 5 ] ) ;
7977
8078 // scalar.
81- // d_square1(&x1, &z1, &mut y1, &mut dy1_1);
82- // d_square1(&x1, &z2, &mut y2, &mut dy1_2);
83- // d_square1(&x1, &z3, &mut y3, &mut dy1_3);
84- // d_square1(&x1, &z4, &mut y4, &mut dy1_4);
79+ d_square1 ( & x1, & z1, & mut y1, & mut dy1_1) ;
80+ d_square1 ( & x1, & z2, & mut y2, & mut dy1_2) ;
81+ d_square1 ( & x1, & z3, & mut y3, & mut dy1_3) ;
82+ d_square1 ( & x1, & z4, & mut y4, & mut dy1_4) ;
8583
8684 // assert y1 == y2 == y3 == y4
87- // for i in 0..5 {
88- // assert_eq!(y1[i], y2[i]);
89- // assert_eq!(y1[i], y3[i]);
90- // assert_eq!(y1[i], y4[i]);
91- // }
85+ for i in 0 ..5 {
86+ assert_eq ! ( y1[ i] , y2[ i] ) ;
87+ assert_eq ! ( y1[ i] , y3[ i] ) ;
88+ assert_eq ! ( y1[ i] , y4[ i] ) ;
89+ }
9290
9391 // batch mode A)
9492 d_square2 ( & x1, & z5, & mut y5, & mut dy2) ;
9593
9694 // assert y1 == y2 == y3 == y4 == y5
97- // for i in 0..5 {
98- // assert_eq!(y1[i], y5[i]);
99- // }
95+ for i in 0 ..5 {
96+ assert_eq ! ( y1[ i] , y5[ i] ) ;
97+ }
10098
10199 // batch mode B)
102100 d_square3 ( & x1, & z1, & z2, & z3, & z4, & mut y6, & mut dy3_1, & mut dy3_2, & mut dy3_3, & mut dy3_4) ;
0 commit comments