Improve compatiblity with proto3 and enable reading attributes#2288
Improve compatiblity with proto3 and enable reading attributes#2288gramalingam merged 2 commits intoonnx:masterfrom
Conversation
with type default values even though they are not in the stream.
houseroad
left a comment
There was a problem hiding this comment.
I am wondering whether we can add a new CI or change an existing CI to proto3
5dc806f to
4682fea
Compare
|
It would help other users if we could document our guidelines for ensuring proto2 and proto3 compatibility (as well as compatibility across different languages in case it makes a difference). My understanding (for this PR) is the following, is this correct? DO NOT use the has_foo() method for any field "foo" of primitive or enum types; it is treated as being present with a default value (if absent in the serialized representation). However, for all the non-primitive types (which are always declared optional in ONNX) as well as oneof fields, it is safe to use the "has_foo" method. Is this correct? |
To be a little more specific. The reason we are able not to use We also do not want to use Otherwise, we can use |
wschin
left a comment
There was a problem hiding this comment.
Thank you! This change helps frameworks relying on proto3.
|
@houseroad Can you, please, be a bit more specific as to what you mean to change existing CI to proto3? Current code will not compile with proto3 interfaces, mostly because of the extensive use of |
…2288) with type default values even though they are not in the stream.
Proto3 does not output primitive types into a stream if they match type default.
This presents a problem when C# protobuf generated code creates a model where type default are omitted. Our proto files are compatible with proto3 and in some cases special provisions exist such as AttributeType enum which actually indicate whether the Attribute was really set by the user.
Thus we remove has_i(), has_f() and has_s() checks if the corresponding enum is set.
This allows proto2 code to read models serialized by proto3 code.