Skip to content

[tmva][sofie] Make all ROperator headers private implementation details and remove custom operator support - #23443

Merged
guitargeek merged 2 commits into
root-project:masterfrom
guitargeek:sofie-public-interface
Sep 22, 2026
Merged

guitargeek merged 2 commits into
root-project:masterfrom
guitargeek:sofie-public-interface

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

All these ROperator*.hxx headers are implementation details of the one feature that we expect SOFIE to provide: rock-solid emission of CPU C++ code for ONNX models. Therefore, these numerous headers should not be part of the public interface.

That also means that the feature to add custom operators goes away. There are no custom operator extensions in ONNX, so if we stick to what SOFIE in ROOT should provide it's not needed anyway.

The custom-operator feature (ROperator_Custom and RSofieReader::
AddCustomOperator, originally from root-project#11065
— thanks for the nice work!) let users splice a hand-written C++ header
into the generated inference code.

It is not needed anymore and kept alive as dead weight:

- An ONNX model containing an op SOFIE does not know cannot be rescued
  this way: the ONNX parser throws unconditionally on unknown op types,
  and there is no dispatch from the parser to ROperator_Custom. The only
  possible use was appending an op to a model that already parsed.

- Nothing in the repository uses it anymore: the Keras-parser test that
  motivated it was removed together with that parser, and no test or
  tutorial covers the surviving RSofieReader hook.

- With the SOFIE ROperator headers made private implementation details,
  the feature cannot work in an installed ROOT at all, since the
  interpreted code it generates needs ROperator_Custom.hxx.

Missing ONNX operators should be implemented in SOFIE itself instead.

RModel_Base::AddNeededCustomHeader stays: it is general code-generation
plumbing also used by the Random and Softmax operators.
None of the ROperator*.hxx headers (including ROperator.hxx itself) are
copied to the build tree include directory or installed anymore. This
greatly reduces the public API contract of SOFIE: the operator layer is
an implementation detail of the code generation that downstream code
should not depend on.

The CMake change requires NO_GLOB_HEADERS, because otherwise all headers
under inc/ are globbed and installed regardless of the HEADERS list.

RModel.hxx can no longer include ROperator.hxx, so ROperator is now only
forward-declared in the public header. Two things follow from this:

- The std::unique_ptr<ROperator> storage needs the out-of-line deleter
  ROperatorDeleter, and RModel destructor/move operations are defined
  out-of-line in RModel.cxx. Without this, every translation unit
  destroying an RModel (and the rootcling dictionary) would need the
  complete ROperator type.

Since the operator headers are resolved via the build-interface include
directory of the library targets, only sources of ROOTTMVASofie and
ROOTTMVASofieParser see them. RModelParser_ONNX.cxx now includes
TMVA/ROperator.hxx explicitly.
@guitargeek
guitargeek requested a review from dpiparo September 21, 2026 15:54
@guitargeek guitargeek self-assigned this Sep 21, 2026
@guitargeek
guitargeek requested a review from lmoneta as a code owner September 21, 2026 15:54
@github-actions

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 16h 10m 35s ⏱️
 3 875 tests  3 875 ✅ 0 💤 0 ❌
80 068 runs  80 068 ✅ 0 💤 0 ❌

Results for commit 3d672ba.

@guitargeek
guitargeek merged commit 74d2538 into root-project:master Sep 22, 2026
34 of 35 checks passed
@guitargeek
guitargeek deleted the sofie-public-interface branch September 22, 2026 11:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants