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:
parent
72091edcc4
commit
63e825e52a
2 changed files with 11 additions and 2 deletions
|
@ -164,9 +164,17 @@ pub fn f9() {
|
||||||
#[rustc_autodiff]
|
#[rustc_autodiff]
|
||||||
#[inline(never)]
|
#[inline(never)]
|
||||||
fn inner(x: f32) -> f32 { x * x }
|
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)]
|
#[rustc_autodiff(Forward, 1, Dual, DualOnly)]
|
||||||
#[inline(never)]
|
#[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)); };
|
unsafe { asm!("NOP", options(pure, nomem)); };
|
||||||
::core::hint::black_box(inner(x));
|
::core::hint::black_box(inner(x));
|
||||||
::core::hint::black_box((bx_0,));
|
::core::hint::black_box((bx_0,));
|
||||||
|
|
|
@ -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
|
// We want to make sure that we can use the macro for functions defined inside of functions
|
||||||
pub fn f9() {
|
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 {
|
fn inner(x: f32) -> f32 {
|
||||||
x * x
|
x * x
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue