aad - Automatic Adjoint Differentiation Library
A pure Rust automatic differentiation library using reverse-mode adjoint differentiation.
Features
- Supports both f32 and f64: Generic implementation works with any floating-point type implementing
num_traits::Float. - Reverse-mode autodiff: Efficiently compute gradients for scalar-valued functions with many inputs.
- Operator overloading: Use standard mathematical operators with variables.
- High Performance: Optimized for minimal runtime overhead.
- Benchmarks show competitive performance, often outperforming alternatives in gradient computation ( see Benchmarks).
- Type-agnostic functions: Write generic mathematical code using the
FloatLiketrait. - Derive macros: Automatically generate differentiable functions with
#[autodiff]macro (requiresderivefeature).
Installation
Add to your Cargo.toml:
[]
= { = "0.8.0", = ["derive"] }
Usage
Basic Example
use Tape;
Using Macros for Automatic Differentiation
Enable the derive feature and use #[autodiff] to automatically differentiate functions:
use ;
Benchmarks
Run benchmarks with:
License
MIT License - see LICENSE