Skip to main content

read_model_binary

Function read_model_binary 

Source
pub fn read_model_binary(path: impl AsRef<Path>) -> Result<Vec<u8>, LoaderError>
Expand description

Read a model file into the binary protobuf bytes of its ModelProto.

Detection is by filename suffix: a path ending in .textproto is parsed as ONNX protobuf TextFormat and converted to the binary wire encoding (see proto::textproto_to_binary); any other path is read verbatim as an already-binary .onnx model. This is the single seam that lets every path-based loader entry accept git-friendly textproto fixtures while keeping binary .onnx loading unchanged.

Note: textproto has no model-directory context for external weights, so textproto fixtures must inline all initializer data.