Skip to main content

oxfuse_core/
lib.rs

1//! Typed tensor-graph IR: types, shape inference, builder and verifier, plus
2//! the exact optimization passes (constant folding, common-subexpression
3//! elimination, dead-code elimination).
4//!
5//! Part of [oxfuse](https://github.com/sara-star-quant/oxfuse), a small tensor
6//! graph compiler whose CPU backends return identical bits. Start here to
7//! build and check a graph; `oxfuse-runtime` runs it.
8//!
9//! ```
10//! use oxfuse_core::{GraphBuilder, Limits, Op};
11//!
12//! # fn main() -> Result<(), oxfuse_core::Error> {
13//! let mut b = GraphBuilder::new(Limits::default());
14//! let x = b.input("x", vec![2, 3])?;
15//! let w = b.constant("w", vec![3, 2], vec![0.5, -1.0, 1.5, 2.0, -0.5, 1.0])?;
16//! let m = b.node("m", Op::MatMul, &[x, w])?;
17//! let y = b.node("y", Op::Relu, &[m])?;
18//! // `finish` runs the verifier: shapes and types are re-checked here.
19//! let graph = b.finish(&[y])?;
20//! assert_eq!(graph.outputs().len(), 1);
21//! # Ok(())
22//! # }
23//! ```
24//!
25//! Not for: general ML work. The op set is seven float32 ops.
26
27mod builder;
28mod dump;
29mod error;
30mod graph;
31mod limits;
32mod op;
33pub mod passes;
34pub mod shape;
35mod types;
36mod verify;
37
38pub use builder::GraphBuilder;
39pub use error::Error;
40pub use graph::{Graph, Source, Value};
41pub use limits::Limits;
42pub use op::Op;
43pub use types::{DType, TensorType, ValueId};