Skip to content

Commit d7d617f

Browse files
committed
add inline test for attribute addition to __enzyme methods
1 parent 530b565 commit d7d617f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/codegen/autodiff/inline.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ compile-flags: -Zautodiff=Enable -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat
2+
//@ no-prefer-dynamic
3+
//@ needs-enzyme
4+
5+
#![feature(autodiff)]
6+
7+
use std::autodiff::autodiff;
8+
9+
#[autodiff(d_square, Reverse, Duplicated, Active)]
10+
fn square(x: &f64) -> f64 {
11+
x * x
12+
}
13+
// CHECK: ; Function Attrs: alwaysinline noinline
14+
// CHECK-NEXT: declare double @__enzyme_autodiff_ZN6inline8d_square17h021c74e92c259cdeE(...) local_unnamed_addr #8
15+
fn main() {
16+
let x = std::hint::black_box(3.0);
17+
let mut dx1 = std::hint::black_box(1.0);
18+
let _ = d_square(&x, &mut dx1, 1.0);
19+
assert_eq!(dx1, 6.0);
20+
}

0 commit comments

Comments
 (0)