pub const fn autodiff<F, G, T, R>(f: F, df: G, args: T) -> Rwhere
T: Tuple,
core_intrinsics)
Generates the LLVM body for the automatic differentiation of f using Enzyme, with df as the derivative function and args as its arguments.
Used internally as the body of df when expanding the #[autodiff_forward] and #[autodiff_reverse] attribute macros.
Type Parameters:
F: The original function to differentiate. Must be a function item.G: The derivative function. Must be a function item.T: A tuple of arguments passed to df.R: The return type of the derivative function.This shows where the autodiff intrinsic is used during macro expansion:
#[autodiff_forward(df1, Dual, Const, Dual)]
pub fn f1(x: &[f64], y: f64) -> f64 {
unimplemented!()
}
expands to:
#[rustc_autodiff]
#[inline(never)]
pub fn f1(x: &[f64], y: f64) -> f64 {
::core::panicking::panic("not implemented")
}
#[rustc_autodiff(Forward, 1, Dual, Const, Dual)]
pub fn df1(x: &[f64], bx_0: &[f64], y: f64) -> (f64, f64) {
::core::intrinsics::autodiff(f1::<>, df1::<>, (x, bx_0, y))
}
© 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 or the MIT license, at your option.
https://doc.rust-lang.org/std/intrinsics/fn.autodiff.html