18
18
// but each shadow argument is `width` times larger (thus 16 and 20 elements here).
19
19
// `d_square3` instead takes `width` (4) shadow arguments, which are all the same size as the
20
20
// 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.
26
21
27
22
#![ feature( autodiff) ]
28
23
29
24
use std:: autodiff:: autodiff;
30
25
31
26
#[ no_mangle]
32
- // #[autodiff(d_square1, Forward, Dual, Dual)]
27
+ #[ autodiff( d_square1, Forward , Dual , Dual ) ]
33
28
#[ autodiff( d_square2, Forward , 4 , Dualv , Dualv ) ]
34
29
#[ autodiff( d_square3, Forward , 4 , Dual , Dual ) ]
35
30
fn square ( x : & [ f32 ] , y : & mut [ f32 ] ) {
@@ -42,6 +37,9 @@ fn square(x: &[f32], y: &mut [f32]) {
42
37
y[ 4 ] = 1.0 * x[ 0 ] + 2.0 * x[ 1 ] + 3.0 * x[ 2 ] + 4.0 * x[ 3 ] ;
43
38
}
44
39
40
+ // FIXME
41
+ // CHECK: start:
42
+
45
43
fn main ( ) {
46
44
let x1 = std:: hint:: black_box ( vec ! [ 0.0 , 1.0 , 2.0 , 3.0 ] ) ;
47
45
@@ -78,25 +76,25 @@ fn main() {
78
76
let mut dy3_4 = std:: hint:: black_box ( vec ! [ 0.0 ; 5 ] ) ;
79
77
80
78
// 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) ;
85
83
86
84
// 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
+ }
92
90
93
91
// batch mode A)
94
92
d_square2 ( & x1, & z5, & mut y5, & mut dy2) ;
95
93
96
94
// 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
+ }
100
98
101
99
// batch mode B)
102
100
d_square3 ( & x1, & z1, & z2, & z3, & z4, & mut y6, & mut dy3_1, & mut dy3_2, & mut dy3_3, & mut dy3_4) ;
0 commit comments