Skip to content

[tmva][sofie] Remove protobuf dependency from ONNX parser - #22936

Open
guitargeek wants to merge 3 commits into
root-project:masterfrom
guitargeek:sofie_protobuf
Open

[tmva][sofie] Remove protobuf dependency from ONNX parser#22936
guitargeek wants to merge 3 commits into
root-project:masterfrom
guitargeek:sofie_protobuf

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

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 guitargeek self-assigned this Jul 27, 2026
@guitargeek
guitargeek requested a review from bellenot as a code owner July 27, 2026 13:58
@guitargeek
guitargeek requested a review from lmoneta as a code owner July 27, 2026 13:58
@guitargeek guitargeek changed the title [tmva-sofie] Remove protobuf dependency from ONNX parser [tmva][sofie] Remove protobuf dependency from ONNX parser Jul 27, 2026
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).
@github-actions

Copy link
Copy Markdown

Test Results

    21 files      21 suites   3d 10h 0m 52s ⏱️
 3 852 tests  3 851 ✅ 0 💤 1 ❌
72 795 runs  72 793 ✅ 1 💤 1 ❌

For more details on these failures, see this check.

Results for commit 117a00e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant