Skip to main content

oxfuse_runtime/
lib.rs

1//! Tensors, execution plans and the CPU backends: a plain reference backend
2//! and a fast backend that returns exactly the same bits (the `parallel`
3//! feature adds threads and still does not change a bit).
4//!
5//! Part of [oxfuse](https://github.com/sara-star-quant/oxfuse). Build a graph
6//! with `oxfuse-core`, then compile and run it:
7//!
8//! ```
9//! use oxfuse_core::{GraphBuilder, Limits, Op};
10//! use oxfuse_runtime::{Backend, CpuBackend, Tensor};
11//!
12//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
13//! let mut b = GraphBuilder::new(Limits::default());
14//! let x = b.input("x", vec![2])?;
15//! let y = b.node("y", Op::Relu, &[x])?;
16//! let graph = b.finish(&[y])?;
17//!
18//! let input = Tensor::new(vec![2], vec![-1.0, 2.0])?;
19//! let out = CpuBackend.compile(&graph)?.run(&[input])?;
20//! assert_eq!(out[0].data(), &[0.0, 2.0]);
21//! # Ok(())
22//! # }
23//! ```
24
25mod backend;
26mod cpu;
27mod evaluator;
28mod kernels;
29mod math;
30mod plan;
31mod reference;
32mod tensor;
33
34pub use backend::{Backend, Executable};
35pub use cpu::CpuBackend;
36pub use evaluator::ReferenceEvaluator;
37pub use math::sigmoid;
38pub use plan::{InputBinding, Plan, Step};
39pub use reference::ReferenceBackend;
40pub use tensor::Tensor;