[tmva][sofie] Remove protobuf dependency from ONNX parser - #22936
Open
guitargeek wants to merge 3 commits into
Open
[tmva][sofie] Remove protobuf dependency from ONNX parser#22936guitargeek wants to merge 3 commits into
guitargeek wants to merge 3 commits into
Conversation
guitargeek
force-pushed
the
sofie_protobuf
branch
from
July 27, 2026 14:30
54aae85 to
dcd5b77
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.
guitargeek
force-pushed
the
sofie_protobuf
branch
from
July 27, 2026 15:28
dcd5b77 to
ad85ba7
Compare
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).
Test Results 21 files 21 suites 3d 10h 0m 52s ⏱️ For more details on these failures, see this check. Results for commit 117a00e. |
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.