[tmva][sofie] Emit self-contained inference code from SOFIE#22920
Open
guitargeek wants to merge 1 commit into
Open
[tmva][sofie] Emit self-contained inference code from SOFIE#22920guitargeek wants to merge 1 commit into
guitargeek wants to merge 1 commit into
Conversation
The C++ that TMVA SOFIE generates used to call helper functions defined in TMVA/SOFIE_common.hxx, so the generated header was not truly standalone: it required the ROOT/TMVA headers to compile. This makes the generated inference code self-contained. - New src/SOFIE_common_helpers.cxx provides GenerateHelperFunctionsCode(), which returns standalone copies of only the helpers a given model needs (Gemm_Call, Copy, Fill, Relu, Im2col/Im2col_3d/col2im, the broadcast helpers, ReadTensorFromStream, the input-dim and dynamic-memory helpers). RModel records the needed helpers via RModel_Base::AddNeededHelperFunction() and dumps them into the generated model namespace; the generated header no longer includes TMVA/SOFIE_common.hxx. - Clad autodiff: the custom-derivative pullbacks (Gemm_Call/Copy/Fill/Relu) are moved out of Math/CladDerivator.h and emitted alongside the generated helpers, into clad::custom_derivatives::<model namespace> where Clad looks them up. The generated code can therefore be differentiated with Clad without depending on SOFIE_common.hxx or CladDerivator.h. - Remove the now generated-code-only helpers from SOFIE_common.hxx/.cxx and the SOFIE custom-derivative block from CladDerivator.h. Helpers still used at generation time (ConvertShapeTo*, the broadcast helpers, GNN_Data, ...) are kept. - TestGemmDerivative now exercises the emitted helper + pullback via GenerateHelperFunctionsCode instead of the library helper + CladDerivator.h. - GNN / GraphIndependent keep the shared TMVA::Experimental::SOFIE::GNN_Data as the inference boundary type (emit a using-alias, not a per-model struct) so the type stays compatible with the callers that build and chain it. - Avoid declaring the BLAS sgemm_ routine twice in generated headers (the fNeededBlasRoutines block and the Gemm_Call helper no longer both emit it). - Fix a latent double-broadcast in the buffer-filling UnidirectionalBroadcast overload (missing return after the shape-prepend branch). 🤖 Done with the help of AI.
Test Results 23 files 23 suites 3d 18h 22m 49s ⏱️ For more details on these failures, see this check. Results for commit 4551adf. ♻️ This comment has been updated with latest results. |
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.
The C++ that TMVA SOFIE generates used to call helper functions defined in TMVA/SOFIE_common.hxx, so the generated header was not truly standalone: it required the ROOT/TMVA headers to compile. This makes the generated inference code self-contained.
New src/SOFIE_common_helpers.cxx provides GenerateHelperFunctionsCode(), which returns standalone copies of only the helpers a given model needs (Gemm_Call, Copy, Fill, Relu, Im2col/Im2col_3d/col2im, the broadcast helpers, ReadTensorFromStream, the input-dim and dynamic-memory helpers). RModel records the needed helpers via RModel_Base::AddNeededHelperFunction() and dumps them into the generated model namespace; the generated header no longer includes TMVA/SOFIE_common.hxx.
Clad autodiff: the custom-derivative pullbacks (Gemm_Call/Copy/Fill/Relu) are moved out of Math/CladDerivator.h and emitted alongside the generated helpers, into clad::custom_derivatives:: where Clad looks them up. The generated code can therefore be differentiated with Clad without depending on SOFIE_common.hxx or CladDerivator.h.
Remove the now generated-code-only helpers from SOFIE_common.hxx/.cxx and the SOFIE custom-derivative block from CladDerivator.h. Helpers still used at generation time (ConvertShapeTo*, the broadcast helpers, GNN_Data, ...) are kept.
TestGemmDerivative now exercises the emitted helper + pullback via GenerateHelperFunctionsCode instead of the library helper + CladDerivator.h.
GNN / GraphIndependent keep the shared TMVA::Experimental::SOFIE::GNN_Data as the inference boundary type (emit a using-alias, not a per-model struct) so the type stays compatible with the callers that build and chain it.
Avoid declaring the BLAS sgemm_ routine twice in generated headers (the fNeededBlasRoutines block and the Gemm_Call helper no longer both emit it).
Fix a latent double-broadcast in the buffer-filling UnidirectionalBroadcast overload (missing return after the shape-prepend branch).
🤖 Done with the help of AI.