Skip to main content

textproto_to_binary

Function textproto_to_binary 

Source
pub fn textproto_to_binary(text: &str) -> Result<Vec<u8>, LoaderError>
Expand description

Convert an ONNX protobuf TextFormat (.textproto) document into the binary protobuf wire encoding of a ModelProto.

Parsing is descriptor-driven from the exact vendored ONNX schema (via FILE_DESCRIPTOR_SET), so every bound message, field, oneof, and enum is covered — the same source of truth used to generate the prost types. The returned bytes are byte-for-byte loadable by decode_model and the weight/graph build path, so a textproto fixture flows through the identical binary-decode pipeline as a real .onnx model.

Because this yields a self-contained binary buffer with no model-directory context, textproto fixtures must inline all weights (no external .onnx.data).