diff options
| author | HaeNoe <git@haenoe.party> | 2025-03-22 00:26:11 +0100 |
|---|---|---|
| committer | HaeNoe <git@haenoe.party> | 2025-04-06 21:27:39 +0200 |
| commit | 72091edcc46601b0fc10c8d71349449d86718d5e (patch) | |
| tree | ca3898783c6fb8910bd40299a72786dc6a70f766 /tests/pretty | |
| parent | 13bf79cd879023ae4434ed4c6b287159bef32b48 (diff) | |
| download | rust-72091edcc46601b0fc10c8d71349449d86718d5e.tar.gz rust-72091edcc46601b0fc10c8d71349449d86718d5e.zip | |
feat: add test to validate autodiff macro expansion
Diffstat (limited to 'tests/pretty')
| -rw-r--r-- | tests/pretty/autodiff_forward.pp | 15 | ||||
| -rw-r--r-- | tests/pretty/autodiff_forward.rs | 8 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/pretty/autodiff_forward.pp b/tests/pretty/autodiff_forward.pp index 4b2fb6166ff..a62ced56dc4 100644 --- a/tests/pretty/autodiff_forward.pp +++ b/tests/pretty/autodiff_forward.pp @@ -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() {} diff --git a/tests/pretty/autodiff_forward.rs b/tests/pretty/autodiff_forward.rs index a765738c2a8..e61d1ec3617 100644 --- a/tests/pretty/autodiff_forward.rs +++ b/tests/pretty/autodiff_forward.rs @@ -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() {} |
