onnx-extractor 0.5.0

Minimal ONNX model loader for extracting weights, tensors, operations, and graph structure
Documentation
//! # onnx-extractor
//!
//! A minimal ONNX model loader for extracting weights, tensors, operations, and graph structure.
//!
//! This crate provides a simple interface to load ONNX models and extract:
//! - Tensor weights & raw data (zero-copy slices, owned buffers, external files)
//! - Tensor shapes, dimensions, and data types
//! - Operations and attributes (nodes, inputs/outputs, subgraphs)
//! - Graph topology and execution order
//!
//! ## Zero-Copy Design
//!
//! `Tensor::data()` returns a `TensorDataRef` which borrows tensor data without copying:
//! - Raw variant uses shared ownership (`Bytes`)
//! - Numeric variants borrow directly (`&[T]`)
//! - Strings variant borrows elements (`&[Bytes]`)
//!
//! `Tensor::into_data()` returns owned `TensorData` without copying:
//! - Raw variant returns shared ownership (`Bytes`)
//! - Numeric variants return owned vectors (`Vec<T>`)
//! - Strings variant returns owned vectors of shared elements (`Vec<Bytes>`)
//!
//! Endianness: Raw tensor data uses little-endian byte order as defined in the ONNX specification. Typed fields use native host representation.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use onnx_extractor::Model;
//!
//! let model = Model::load_from_file("model.onnx")?;
//! println!("{}", model);
//!
//! // Access tensor shape and data
//! if let Some(tensor) = model.graph().tensors().get("weight_1") {
//!     println!("Weight shape: {:?}", tensor.shape());
//!     let data = tensor.data()?;
//!     if let Some(bytes) = data.as_slice() {
//!         println!("Data size: {} bytes", bytes.len());
//!     }
//! }
//! # Ok::<(), onnx_extractor::Error>(())
//! ```

// include generated protobuf code inside a small module so we can silence
// lints and doc warnings originating from the generated file only.
#[allow(clippy::all, clippy::pedantic, rustdoc::all)]
mod onnx_generated {
    include!(concat!(env!("OUT_DIR"), "/onnx.rs"));
}

pub(crate) mod proto_adapter;
pub(crate) use onnx_generated::*;

pub mod attribute_value;
pub mod data_type;
pub mod error;
mod external_data;
pub mod graph;
pub mod model;
pub mod operation;
pub mod tensor;

pub use attribute_value::AttributeValue;
pub use data_type::DataType;
pub use error::Error;
pub use graph::Graph;
pub use model::Model;
pub use operation::Operation;
pub use prost::bytes::Bytes;
pub use tensor::{Tensor, TensorData, TensorDataRef};