Expand description
ONNX format reader (GH-238)
Lightweight ONNX protobuf parser that extracts tensor initializers
(weights) from .onnx files without requiring the prost crate.
§ONNX Protobuf Layout (simplified)
ModelProto {
ir_version: int64 (field 1)
graph: GraphProto (field 7)
initializer: [TensorProto] (field 5, repeated)
dims: [int64] (field 1, repeated/packed)
data_type: int32 (field 2)
name: string (field 8)
raw_data: bytes (field 13)
float_data: [float] (field 4, packed)
}§Example
ⓘ
use aprender::format::onnx::OnnxReader;
let reader = OnnxReader::from_file("model.onnx")?;
for tensor in reader.tensors() {
println!("{}: {:?} ({:?})", tensor.name, tensor.shape, tensor.data_type);
}Structs§
- Onnx
Metadata - ONNX model metadata
- Onnx
Reader - ONNX file reader
- Onnx
Tensor - A tensor extracted from an ONNX file
Enums§
- Onnx
Data Type - ONNX data types (from onnx.proto3 TensorProto.DataType)
Functions§
- is_
nemo_ file - Check if a file is a NeMo archive (.nemo = tar.gz)
- is_
onnx_ file - Check if a file is an ONNX model by reading the first few bytes