Skip to main content

openinfer_simulator/
lib.rs

1//! # OpenInfer
2//!
3//! OpenInfer is an inference graph and execution framework for machine-learning
4//! workloads. It provides a graph model, a runtime, and tensor utilities that
5//! can execute on CPU (and optionally Vulkan) backends.
6//!
7//! ## Quick start
8//! ```no_run
9//! use openinfer::{graph, Device, ModelLoader, Simulator};
10//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
11//! let model = ModelLoader::default();
12//! let g = graph! {
13//!     block main {
14//!         // ... graph nodes ...
15//!     }
16//! };
17//! let sim = Simulator::new(&model, &g, Device::Cpu)?;
18//! let _executor = sim.with_trace().make_executor()?;
19//! # Ok(()) }
20//! ```
21//!
22//! ## Key concepts
23//! - `Graph` and `Node` describe the computation structure.
24//! - `Tensor` and `TensorValue` hold data with explicit shapes and dtypes.
25//! - `Simulator` and `Executor` manage validation and execution.
26//! - `ModelLoader` provides external state and parameters.
27//!
28//! ## Module map
29//! - `graph`: graph nodes, blocks, and serialization.
30//! - `runtime`: executor, validation, and tracing.
31//! - `tensor`: tensor containers and dtype utilities.
32//! - `ops`: op registry and kernel dispatch.
33pub use openinfer_dsl::graph;
34
35mod simulator;
36mod graph;
37mod op_defs;
38mod runtime;
39mod macros;
40mod tensor;
41mod types;
42mod timer;
43mod formatting;
44mod random;
45mod ops;
46pub mod logging;
47
48pub use simulator::{Device, Executor, Fetchable, Simulator, TraceEvent, TraceEventKind};
49pub use graph::{
50    AttrValue, Block, CacheAccess, CacheIndexExpr, CacheIndexValue, Graph, GraphDeserialize,
51    GraphSerialize, MemoryKind, Node, NodeKind, OpAttr, OpAttrs, OpKind, VarDecl,
52};
53pub use op_defs::{op_schema, TypeRule};
54pub use runtime::ModelLoader;
55pub use tensor::{
56    BF16, Bitset, DType, F16, F8, I1, I2, I4, ScalarValue, T1, T2, U1, U2, U4, Tensor,
57    TensorElement, TensorOptions, TensorValue,
58};
59pub use types::VarInfo;
60pub use timer::Timer;
61pub use formatting::{format_truncated, FormatValue};
62pub use random::Random;
63