Expand description
Automatic differentiation APIs for tenferro.
This crate is the explicit opt-in boundary for traced and eager automatic
differentiation. Primal graph construction and execution live in
tenferro-runtime; tensor storage lives in tenferro-tensor, and CPU
execution lives in tenferro-cpu.
Use EagerRuntime and EagerTensor for PyTorch-style immediate
execution where tracked variables accumulate gradients after backward().
Use TracedTensorAdExt or AdContext for JAX-style graph transforms
such as grad, vjp, and jvp on tenferro_runtime::TracedTensor
values. AdContext is the explicit place to add extension AD rule sets for
operation-family crates such as tenferro-linalg.
User-facing guides live at https://tensor4all.org/tenferro-rs/guides/autodiff.html and https://tensor4all.org/tenferro-rs/guides/choosing-an-api.html.
§Examples
use tenferro_ad::AdContext;
use tenferro_runtime::TracedTensor;
let ad = AdContext::builder().build().unwrap();
let x = TracedTensor::from_vec_col_major(vec![], vec![3.0_f64]).unwrap();
let loss = (&x * &x).unwrap();
let dx = ad.grad(&loss, &x).unwrap();
assert_eq!(dx.rank, 0);Re-exports§
pub use traced::TracedTensorAdExt;
Modules§
Structs§
- AdContext
- Explicit automatic-differentiation context.
- AdContext
Builder - Builder for
AdContext. - Context
Id - Opaque identifier for an eager AD runtime, used in
Error::ContextMismatch. - DotGeneral
Config - DotGeneral dimension configuration.
- Eager
Runtime - Shared eager execution context for tensors on a backend.
- Eager
Runtime Cache Stats - Stats for caches owned by an
EagerRuntime. - Eager
Tensor - Eager tensor with reverse-mode autodiff over concrete tensor values.
- Gather
Config - StableHLO gather dimension configuration.
- PadConfig
- StableHLO pad configuration.
- Scatter
Config - StableHLO scatter dimension configuration.
- Slice
Config - Slice configuration.
Enums§
- Compare
Dir - Comparison direction.
- DType
- Runtime scalar dtype tag.
- Eager
Backend - Error
- Errors produced by einsum, eval, and other tenferro operations.
- Tensor
- Dynamic tensor enum over the supported scalar types.
Type Aliases§
- Result
- Result type alias for tenferro operations.