Crate aegir

source ·
Expand description

Strongly-typed, compile-time autodifferentiation in Rust.

aegir is an experimental autodifferentiation framework designed to leverage the powerful type-system in Rust and avoid runtime as much as humanly possible. The approach taken resembles that of expression templates, as commonly used in linear-algebra libraries written in C++, and indeed mirrors (in many ways) the concept of Iterator in std.

A key distinction of aegir from existing autodiff frameworks is that it does not rely on a monolithic Tensor type that handles shape transformations at runtime. This would be equivalent to using the ndarray crate to handle all numerical computations and data-storage/layouts. While this has its advantages - like simplicity and ease of use - our approach is a strict generalisation and allows for much greater flexibility. By incorporating both dynamic and fixed-size data structures, we also have the advantage of the various compile-time optimisations that come from using arrays, tuples, and scalars.

Key Features

  • Built-in arithmetic, linear-algebraic, trigonometric and special operators.
  • Infinitely differentiable: Jacobian, Hessian, etc…
  • Decoupled/generic tensor type.
  • Monadic runtime optimisation.
  • Custom DSL for operator expansion.

Modules

Module for tensor abstractions and their implementations.
Module for helper error types.
Module containing formatting logic.
Quality-of-life shortcuts for commonly-used identifiers.
Module containing meta operators.
Module for concrete operator implementations.

Macros

Helper macro for creating anonymous Context types.
Helper macro for defining simple, auto-magical Context types.
Helper macro to construct a Dual variable.

Structs

Dual variable for forward-mode autodifferentiation over aegir buffers.

Traits

Trait for operator Nodes that can assert their symbolic contents.
Trait for types that store data buffers.
Trait for operator Nodes with a well-defined adjoint.
Trait for operator Nodes that can be evaluated against a Context.
Interface for type-level identifiers.
Base trait for operator nodes.
Trait for reading entries out of a Context.

Type Definitions

Alias for the adjoint of a function.
Alias for the result type associated with a function.
Alias for the dual associated with a function.
Alias for the error type associated with a function.
Alias for the value type associated with a function.