ChufanSuki / read-paper-and-code

0 stars 0 forks source link

Open Neural Network Exchange(ONNX) #149

Closed ChufanSuki closed 1 week ago

ChufanSuki commented 1 week ago

https://onnx.ai/onnx/index.html

Open Neural Network eXchange (ONNX) is an open standard format for representing machine learning models.

ChufanSuki commented 1 week ago

ProtoBuf

ONNX uses protobuf to serialize the graph into one single block.

https://github.com/onnx/onnx/blob/main/onnx/onnx.in.proto

message ModelProto {
    optional GraphProto graph = 7;
}
message GraphProto {
  // The nodes in the graph, sorted topologically.
  repeated NodeProto node = 1;
  repeated TensorProto initializer = 5;
  repeated ValueInfoProto input = 11;
  repeated ValueInfoProto output = 12;
}
message NodeProto {
  repeated string input = 1;   
  repeated string output = 2;
  optional string op_type = 4;
  repeated AttributeProto attribute = 5;
}

AttributeProto is used to define an attribute of an operator defined itself by a NodeProto. For example, Conv node has attributes like group, pad, strides(https://github.com/onnx/onnx/blob/main/docs/Operators.md#Conv).