1
- //@ compile-flags: -Zautodiff=Enable -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat -g
1
+ //@ compile-flags: -Zautodiff=Enable,PrintTAFn=callee -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat -g
2
2
//@ no-prefer-dynamic
3
3
//@ needs-enzyme
4
4
#![ feature( autodiff) ]
5
5
6
6
use std:: autodiff:: autodiff_reverse;
7
7
8
+ // CHECK-LABEL: callee
9
+ // CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
10
+ // CHECK: ptr %x: {[-1]:Pointer, [-1,0]:Float@float}
11
+ // CHECK: start
12
+ // CHECK: %_2 = load float, ptr %x, align 4, !noundef !3: {[-1]:Float@float}
13
+ // CHECK: %_0 = fmul float %_2, %_2: {[-1]:Float@float}
14
+ // CHECK: ret float %_0: {}
15
+
8
16
#[ autodiff_reverse( d_square, Duplicated , Active ) ]
9
17
#[ no_mangle]
10
18
fn callee ( x : & f32 ) -> f32 {
@@ -14,22 +22,9 @@ fn callee(x: &f32) -> f32 {
14
22
fn main ( ) {
15
23
let x: f32 = 7.0 ;
16
24
let mut df_dx: f32 = 0.0 ;
17
- d_square ( & x, & mut df_dx, 1.0 ) ;
18
- }
19
-
20
- // CHECK: define float @callee(ptr align 4 {{.*}}) {{.*}} !dbg {
21
- // CHECK-NEXT: start:
22
- // CHECK: #dbg_value
23
- // CHECK: load float
24
- // CHECK: fmul float
25
- // CHECK: ret float
26
-
27
- // CHECK: define void @_ZN9f32_debug8d_square{{.*}}(ptr align 4 {{.*}}, ptr align 4 {{.*}}, float {{.*}}) {{.*}} {
28
- // CHECK: call {{.*}} @diffecallee
29
- // CHECK: ret void
25
+ let out = callee ( & x) ;
26
+ let out_ = d_square ( & x, & mut df_dx, 1.0 ) ;
30
27
31
- // CHECK: define {{.*}} @diffecallee(ptr {{.*}} align 4 {{.*}}, ptr {{.*}} align 4 {{.*}}, float {{.*}}) {{.*}} {
32
- // CHECK: load float
33
- // CHECK: fmul float
34
- // CHECK: store float
35
- // CHECK: ret {{.*}}
28
+ assert_eq ! ( out, out_) ;
29
+ assert_eq ! ( 14.0 , df_dx) ;
30
+ }
0 commit comments