kn_graph/
lib.rs

1#![warn(missing_debug_implementations)]
2#![allow(clippy::new_without_default)]
3
4//! A neural network inference graph intermediate representation, with surrounding utilities.
5//!
6//! The core type of this crate is [Graph](graph::Graph),
7//! see its documentation for how to manually build and compose graphs.
8//!
9//! An example demonstrating some of the features of this crate:
10//! ```no_run
11//! # use kn_graph::dot::graph_to_svg;
12//! # use kn_graph::onnx::load_graph_from_onnx_path;
13//! # use kn_graph::optimizer::optimize_graph;
14//! # use kn_graph::cpu::cpu_eval_graph;
15//! # use ndarray::{IxDyn, Array};
16//! # use kn_graph::dtype::{DTensor, Tensor};
17//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
18//! // load an onnx file
19//! let graph = load_graph_from_onnx_path("test.onnx", false)?;
20//!
21//! // optimize the graph
22//! let graph = optimize_graph(&graph, Default::default());
23//!
24//! // render the graph as an svg file
25//! graph_to_svg("test.svg", &graph, false, false)?;
26//!
27//! // execute the graph on the CPU
28//! let batch_size = 8;
29//! let inputs = [DTensor::F32(Tensor::zeros(IxDyn(&[batch_size, 16])))];
30//! let outputs = cpu_eval_graph(&graph, batch_size, &inputs);
31//! # Ok(())
32//! # }
33//! ```
34//!
35//! This crate is part of the [Kyanite](https://github.com/KarelPeeters/Kyanite) project, see its readme for more information.
36
37// TODO write onnx load, optimize, run example
38
39/// The [ndarray] crate is used for constant storage and CPU execution, and re-exported for convenience.
40pub use ndarray;
41
42/// The [DType](dtype::DType) enum.
43pub mod dtype;
44/// The core graph datastructure.
45pub mod graph;
46/// Graph optimization.
47pub mod optimizer;
48/// The [Shape](shape::Shape) type and utilities.
49pub mod shape;
50
51/// CPU graph execution.
52pub mod cpu;
53/// Graph visualization as a `dot` or `svg` file.
54pub mod dot;
55/// Onnx file loading.
56pub mod onnx;
57/// Hidden activations visualization.
58pub mod visualize;
59
60pub mod wrap_debug;