File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ error: using the autodiff feature requires setting `lto="fat"` in your Cargo.toml
2+
3+ error: aborting due to 1 previous error
4+
Original file line number Diff line number Diff line change 1+ //@ needs-enzyme
2+ //@ no-prefer-dynamic
3+ //@ revisions: with_lto no_lto
4+ //@[with_lto] compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=fat
5+ //@[no_lto] compile-flags: -Zautodiff=Enable -C opt-level=3 -Clto=thin
6+
7+ #![ feature( autodiff) ]
8+ //@[no_lto] build-fail
9+ //@[with_lto] build-pass
10+
11+ // Autodiff requires users to enable lto=fat (for now).
12+ // In the past, autodiff did not run if users forget to enable fat-lto, which caused functions to
13+ // returning zero-derivatives. That's obviously wrong and confusing to users. We now added a check
14+ // which will abort compilation instead.
15+
16+ use std:: autodiff:: autodiff_reverse;
17+ //[no_lto]~? ERROR using the autodiff feature requires setting `lto="fat"` in your Cargo.toml
18+
19+ #[ autodiff_reverse( d_square, Duplicated , Active ) ]
20+ fn square ( x : & f64 ) -> f64 {
21+ * x * * x
22+ }
23+
24+ fn main ( ) {
25+ let xf64: f64 = std:: hint:: black_box ( 3.0 ) ;
26+
27+ let mut df_dxf64: f64 = std:: hint:: black_box ( 0.0 ) ;
28+
29+ let _output_f64 = d_square ( & xf64, & mut df_dxf64, 1.0 ) ;
30+ assert_eq ! ( 6.0 , df_dxf64) ;
31+ }
You can’t perform that action at this time.
0 commit comments