Skip to content

Commit 7f0aca5

Browse files
committed
Add expansion example to intrinsic docs
1 parent c56d57f commit 7f0aca5

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
@@ -3174,6 +3174,29 @@ pub const unsafe fn copysignf128(x: f128, y: f128) -> f128;
31743174
/// - `G`: The derivative function. Must be a function item.
31753175
/// - `T`: A tuple of arguments passed to `df`.
31763176
/// - `R`: The return type of the derivative function.
3177+
///
3178+
/// This shows where the `enzyme_autodiff` intrinsic is used during macro expansion:
3179+
///
3180+
/// ```rust,ignore (macro example)
3181+
/// #[autodiff_forward(df1, Dual, Const, Dual)]
3182+
/// pub fn f1(x: &[f64], y: f64) -> f64 {
3183+
/// unimplemented!()
3184+
/// }
3185+
/// ```
3186+
///
3187+
/// expands to:
3188+
///
3189+
/// ```rust,ignore (macro example)
3190+
/// #[rustc_autodiff]
3191+
/// #[inline(never)]
3192+
/// pub fn f1(x: &[f64], y: f64) -> f64 {
3193+
/// ::core::panicking::panic("not implemented")
3194+
/// }
3195+
/// #[rustc_autodiff(Forward, 1, Dual, Const, Dual)]
3196+
/// pub fn df1(x: &[f64], bx_0: &[f64], y: f64) -> (f64, f64) {
3197+
/// ::core::intrinsics::enzyme_autodiff(f1::<>, df1::<>, (x, bx_0, y))
3198+
/// }
3199+
/// ```
31773200
#[rustc_nounwind]
31783201
#[rustc_intrinsic]
31793202
pub const fn enzyme_autodiff<F, G, T: crate::marker::Tuple, R>(f: F, df: G, args: T) -> R;

0 commit comments

Comments
 (0)