Skip to main content

Crate tidu

Crate tidu 

Source
Expand description

Automatic-differentiation transforms for primitive computation graphs.

tidu is for downstream crates that define primitive operations, local AD rules, graph runtimes, or eager tensor frontends. It does not define tensor operations itself. Instead, downstream primitive sets implement Primitive, then call the graph transforms here to build new primitive computation graphs.

The main transforms are:

  • linearize, which builds a graph for a Jacobian-vector product (JVP) of selected outputs with respect to selected inputs.
  • linear_transpose, which transposes a linearized graph so cotangents can flow backward through the corresponding linear map.
  • eager::backward, which supports downstream eager frontends that record graph invocations and want a reverse-mode backward() workflow.

These transforms propagate ADRuleError for missing primitive or extension AD rules.

See the repository docs/ tree for the terminology guide, tutorials, and implementer guides.

§Examples

use computegraph::resolve::resolve;
use tidu::{linear_transpose, linearize};

let view = resolve(vec![source_graph]);
let mut ctx = ();
let aliases = std::collections::HashMap::new();
let linear = linearize(&view, &[output_key], &[input_key], 1, &mut ctx, &aliases)?;
let _transposed = linear_transpose(&linear, &mut ctx)?;

Re-exports§

pub use rules::ADKey;
pub use rules::ADRuleError;
pub use rules::ADRuleKind;
pub use rules::ADRuleResult;
pub use rules::DiffPassId;
pub use rules::Primitive;
pub use rules::PrimitiveBuilder;
pub use rules::PrimitiveValue;

Modules§

eager
Generic eager reverse-mode recording for Primitive frontends.
rules
Primitive AD rule contract consumed by tidu.

Structs§

LinearizedGraph
Graph produced by linearizing a primitive computation graph.
PrimitiveGraph
Borrowed primitive computation graph passed to downstream executors.

Functions§

linear_transpose
Transpose a linearized graph, reversing linear flow.
linear_transpose_with_builder
Execute the transpose of a linearized graph using a caller-provided builder.
linearize
Linearize a resolved computation graph, producing a linear graph.