feat: apply autodiff macro twice to inner function

Verify that the expanded `inline` and `rustc_autodiff` macros are not
duplicated.
This commit is contained in:
HaeNoe 2025-04-01 07:25:04 +02:00
parent 72091edcc4
commit 63e825e52a
No known key found for this signature in database
2 changed files with 11 additions and 2 deletions

View File

@ -164,9 +164,17 @@ pub fn f9() {
#[rustc_autodiff]
#[inline(never)]
fn inner(x: f32) -> f32 { x * x }
#[rustc_autodiff(Forward, 1, Dual, Dual)]
#[inline(never)]
fn d_inner_2(x: f32, bx_0: f32) -> (f32, f32) {
unsafe { asm!("NOP", options(pure, nomem)); };
::core::hint::black_box(inner(x));
::core::hint::black_box((bx_0,));
::core::hint::black_box(<(f32, f32)>::default())
}
#[rustc_autodiff(Forward, 1, Dual, DualOnly)]
#[inline(never)]
fn d_inner(x: f32, bx_0: f32) -> f32 {
fn d_inner_1(x: f32, bx_0: f32) -> f32 {
unsafe { asm!("NOP", options(pure, nomem)); };
::core::hint::black_box(inner(x));
::core::hint::black_box((bx_0,));

View File

@ -56,7 +56,8 @@ fn f8(x: &f32) -> f32 {
// We want to make sure that we can use the macro for functions defined inside of functions
pub fn f9() {
#[autodiff(d_inner, Forward, Dual, DualOnly)]
#[autodiff(d_inner_1, Forward, Dual, DualOnly)]
#[autodiff(d_inner_2, Forward, Dual, Dual)]
fn inner(x: f32) -> f32 {
x * x
}