Expand description
Typed tensor-graph IR: types, shape inference, builder and verifier, plus the exact optimization passes (constant folding, common-subexpression elimination, dead-code elimination).
Part of oxfuse, a small tensor
graph compiler whose CPU backends return identical bits. Start here to
build and check a graph; oxfuse-runtime runs it.
use oxfuse_core::{GraphBuilder, Limits, Op};
let mut b = GraphBuilder::new(Limits::default());
let x = b.input("x", vec![2, 3])?;
let w = b.constant("w", vec![3, 2], vec![0.5, -1.0, 1.5, 2.0, -0.5, 1.0])?;
let m = b.node("m", Op::MatMul, &[x, w])?;
let y = b.node("y", Op::Relu, &[m])?;
// `finish` runs the verifier: shapes and types are re-checked here.
let graph = b.finish(&[y])?;
assert_eq!(graph.outputs().len(), 1);Not for: general ML work. The op set is seven float32 ops.
Modules§
- passes
- Graph-to-graph passes and the manager that runs them. A pass never mutates its input: it returns a new graph, so before and after are both intact for dumps and equivalence tests, and no stale ids can exist.
- shape
- Shape rules: one function per concern, all arithmetic checked.
Structs§
- Graph
- A graph is only constructed through
GraphBuilder::finish, which verifies it. - Graph
Builder - Limits
- Tensor
Type - Value
- ValueId
- Index of a value in a graph. Values are stored in definition order, so a node’s inputs always have smaller ids than the node itself.