ONNX(Open Neural Network Exchange Intermediate Representation)是一种神经网络的格式,采用Protobuf二进制形式进行序列化模型。
Protobuf 全称叫做Protocal Buffer。是Google提出来的一套表示和序列化数据的机制。
Protobuf会根据用于定义的数据结构来进行序列化存储同理,我们可以根据官方提供的数据结构信息,去修改或者创建onnx。
Protobuf的编译以及序列化流程
在onnx.in.proto定义了所有onnx的Proto。
# Onnx 中的组织架构
# - ModelProto(整个模型的信息)
# --- GraphProto(网络信息)
# ------ NodeProto(计算节点信息)
# --------- TensorProto(包含Weights)
# ------------ ValueInfoProto(input/output 信息)
TensorProto
定义一个权重,比如Conv的w和b。
// The shape of the tensor.
repeated int64 dims = 1;
// The data type of the tensor.
// This field MUST have a valid TensorProt