aad 0.3.0

Automatic adjoint differentiation library
Documentation

AAD

CI Crates.io Docs.rs

This crate provides tools for implementing adjoint(a.k.a. reverse-mode) automatic differentiation in Rust. It enables gradient computation for scalar values through a flexible and extensible API.

  • User-Friendly Design: Equations can be manipulated as seamlessly as primitive floating-point types.
  • High Performance: The library is designed to be both efficient and scalable, with minimal overhead.
    • Benchmarks show it is as fast or faster compared to RustQuant_autodiff.
    • Note: RustQuant_autodiff includes extra dependencies, which may require additional system setup when installing on Linux.
  • No Dependencies: The library is self-contained and does not rely on any external dependencies.

Quick Start

Here's an example of how to use the library:

use aad::Tape;

fn main() {
    let tape = Tape::default();

    let x = tape.crate_variable(2.0);
    let y = tape.crate_variable(3.0);

    let z = (x + y) * x.sin();

    println!("{}", z.value());

    let grads = z.compute_gradients();
    println!("Gradients are: {:?}", grads.get_gradients(&[x, y]));
}

Benchmarks

Benchmark results can be viewed here.

License

This project is licensed under the MIT License.