feat: add test to validate autodiff macro expansion
This commit is contained in:
parent
13bf79cd87
commit
72091edcc4
2 changed files with 23 additions and 0 deletions
|
@ -29,6 +29,8 @@ pub fn f1(x: &[f64], y: f64) -> f64 {
|
|||
// Make sure, that we add the None for the default return.
|
||||
|
||||
|
||||
// We want to make sure that we can use the macro for functions defined inside of functions
|
||||
|
||||
::core::panicking::panic("not implemented")
|
||||
}
|
||||
#[rustc_autodiff(Forward, 1, Dual, Const, Dual)]
|
||||
|
@ -158,4 +160,17 @@ fn f8_1(x: &f32, bx_0: &f32) -> f32 {
|
|||
::core::hint::black_box((bx_0,));
|
||||
::core::hint::black_box(<f32>::default())
|
||||
}
|
||||
pub fn f9() {
|
||||
#[rustc_autodiff]
|
||||
#[inline(never)]
|
||||
fn inner(x: f32) -> f32 { x * x }
|
||||
#[rustc_autodiff(Forward, 1, Dual, DualOnly)]
|
||||
#[inline(never)]
|
||||
fn d_inner(x: f32, bx_0: 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>::default())
|
||||
}
|
||||
}
|
||||
fn main() {}
|
||||
|
|
|
@ -54,4 +54,12 @@ fn f8(x: &f32) -> f32 {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
// 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)]
|
||||
fn inner(x: f32) -> f32 {
|
||||
x * x
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue