Skip to content

Commit 56ab39c

Browse files
committed
Add expansion example to intrinsic docs
1 parent 99e9147 commit 56ab39c

File tree

1 file changed

+23
-0
lines changed
  • library/core/src/intrinsics

1 file changed

+23
-0
lines changed

library/core/src/intrinsics/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3168,6 +3168,29 @@ pub const unsafe fn copysignf128(x: f128, y: f128) -> f128;
31683168
/// - `G`: The derivative function. Must be a function item.
31693169
/// - `T`: A tuple of arguments passed to `df`.
31703170
/// - `R`: The return type of the derivative function.
3171+
///
3172+
/// This shows where the `enzyme_autodiff` intrinsic is used during macro expansion:
3173+
///
3174+
/// ```rust,ignore (macro example)
3175+
/// #[autodiff_forward(df1, Dual, Const, Dual)]
3176+
/// pub fn f1(x: &[f64], y: f64) -> f64 {
3177+
/// unimplemented!()
3178+
/// }
3179+
/// ```
3180+
///
3181+
/// expands to:
3182+
///
3183+
/// ```rust,ignore (macro example)
3184+
/// #[rustc_autodiff]
3185+
/// #[inline(never)]
3186+
/// pub fn f1(x: &[f64], y: f64) -> f64 {
3187+
/// ::core::panicking::panic("not implemented")
3188+
/// }
3189+
/// #[rustc_autodiff(Forward, 1, Dual, Const, Dual)]
3190+
/// pub fn df1(x: &[f64], bx_0: &[f64], y: f64) -> (f64, f64) {
3191+
/// ::core::intrinsics::enzyme_autodiff(f1::<>, df1::<>, (x, bx_0, y))
3192+
/// }
3193+
/// ```
31713194
#[rustc_nounwind]
31723195
#[rustc_intrinsic]
31733196
pub const fn enzyme_autodiff<F, G, T: crate::marker::Tuple, R>(f: F, df: G, args: T) -> R;

0 commit comments

Comments
 (0)