[tmva][sofie] Remove protobuf dependency from ONNX parser - #22936
Merged
Conversation
guitargeek
force-pushed
the
sofie_protobuf
branch
from
July 27, 2026 14:30
54aae85 to
dcd5b77
Compare
guitargeek
force-pushed
the
sofie_protobuf
branch
from
July 27, 2026 15:28
dcd5b77 to
ad85ba7
Compare
Test Results 23 files 23 suites 3d 15h 27m 51s ⏱️ Results for commit 2e49387. ♻️ This comment has been updated with latest results. |
guitargeek
force-pushed
the
sofie_protobuf
branch
2 times, most recently
from
July 28, 2026 14:48
6d1211f to
9dc8669
Compare
guitargeek
force-pushed
the
sofie_protobuf
branch
from
August 4, 2026 20:38
9dc8669 to
aa8b8a8
Compare
SOFIE's ONNX importer was the only part of TMVA-SOFIE that depended on protobuf: it linked libprotobuf and ran protoc on onnx_proto3 at build time to read ONNX model files (which are protobuf messages). Core SOFIE never used protobuf. Replace this with a small self-contained protobuf wire-format decoder in tmva/sofie_parsers/src/onnx.hxx. It provides the subset of the onnx:: message API that the parser actually uses (7 message types), with the same accessor signatures as the protoc-generated code, so the operator parsers (Parse*.cxx) are unchanged apart from the include. With this, TMVA-SOFIE has no external dependencies and the tmva-sofie build option no longer requires protobuf 3. Details: - onnx.hxx: hand-written wire reader (varint / 32- / 64-bit / length delimited), handling packed and unpacked repeated fields. Fixed-width fields are read byte-wise little-endian so the result is correct on big-endian hosts too. Unknown/future fields are skipped by wire type. - RModelParser_ONNX.cxx: ExtractDataFromTP now copies from the typed data vectors instead of RepeatedField::ExtractSubrange; dropped the GOOGLE_PROTOBUF_VERIFY_VERSION / ShutdownProtobufLibrary calls. - CMake: drop protobuf_generate_cpp, protobuf::libprotobuf and the Protobuf discovery/version checks; remove the generated onnx_proto3 schema. The C++ ONNX binary format is the only ONNX serialization SOFIE ever read; text/JSON ONNX and unused messages (sparse tensor, training info) are intentionally not handled. 🤖 Done with the help of AI.
Now that SOFIE no longer depends on protobuf (the ONNX parser uses a self-contained wire-format decoder), it has no special dependency and there is no reason to keep it behind a separate build option. Make all of SOFIE - the ROOTTMVASofie library, the ONNX parser, the tests, and the R__HAS_TMVASOFIE-guarded Clad derivatives - conditional on the existing tmva flag instead. The sofie_parsers subdirectory and the SOFIE test subdirectory are now built unconditionally within the tmva-gated tree, hastmvasofie follows tmva in the generated RConfigure.h, and the tmva-sofie=... lines are dropped from the CI build configs (SOFIE is now built wherever tmva is on).
Most of the SOFIE tests require BLAS as a runtime dependency. We need to make it possible to toggle the TMVA SOFIE tests, so you can switch them off on platforms where no BLAS is installed or available.
guitargeek
force-pushed
the
sofie_protobuf
branch
from
August 9, 2026 20:12
aa8b8a8 to
2e49387
Compare
lmoneta
reviewed
Aug 11, 2026
lmoneta
left a comment
Member
There was a problem hiding this comment.
LGTM!
Thank you Jonas for this improvement!
Collaborator
|
Thanks!! After merging one should remove protobuf from root-ci-images |
Contributor
Author
That's something we can't do: the older release branches still rely on it. |
lmoneta
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SOFIE's ONNX importer was the only part of TMVA-SOFIE that depended on protobuf: it linked libprotobuf and ran protoc on onnx_proto3 at build time to read ONNX model files (which are protobuf messages). Core SOFIE never used protobuf.
Replace this with a small self-contained protobuf wire-format decoder in tmva/sofie_parsers/src/onnx.hxx. It provides the subset of the onnx:: message API that the parser actually uses (7 message types), with the same accessor signatures as the protoc-generated code, so the operator parsers (Parse*.cxx) are unchanged apart from the include.
With this, TMVA-SOFIE has no external dependencies and the tmva-sofie build option no longer requires protobuf 3.
Details:
The C++ ONNX binary format is the only ONNX serialization SOFIE ever read; text/JSON ONNX and unused messages (sparse tensor, training info) are intentionally not handled.
🤖 Done with the help of AI.