Skip to content

Onnxruntime for TrkPID#5

Draft
sophiemiddleton wants to merge 2 commits intoMu2e:mainfrom
sophiemiddleton:onnxruntime
Draft

Onnxruntime for TrkPID#5
sophiemiddleton wants to merge 2 commits intoMu2e:mainfrom
sophiemiddleton:onnxruntime

Conversation

@sophiemiddleton
Copy link
Copy Markdown

@sophiemiddleton sophiemiddleton commented Apr 30, 2026

This pull request adds ONNX Runtime support for neural network inference to the TrackPID and TrackQuality modules, enabling them to run models exported to ONNX format in addition to the existing TMVA/SOFIE-based evaluation. It also introduces a new script for converting .dat weight files to ONNX models and updates the build system to link against ONNX Runtime. The changes allow for direct comparison of outputs from the traditional and ONNX-based inference within the same event loop.

The most important changes are:

ONNX Runtime Integration in C++ Modules:

  • Added ONNX Runtime member variables and initialization to both TrackPID and TrackQuality modules, including model loading, input/output tensor preparation, and inference execution. The code now runs both the TMVA/SOFIE and ONNX models in parallel for each event, and prints both outputs for debugging. (TrkDiag/src/TrackPID_module.cc, TrkDiag/src/TrackQuality_module.cc) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Build System Updates:

  • Updated SCons build configuration to link against the ONNX Runtime library for both main and plugin targets. (TrkDiag/src/SConscript) [1] [2]

ONNX Model Conversion Script:

  • Added a new script, convert_trackpid_to_onnx.py, which parses .dat neural network weight files and exports them as ONNX models. The script supports both TensorFlow/Keras-based and pure ONNX export paths, handling the architecture and weight reshaping to match the expected input/output of the C++ modules. (TrkDiag/scripts/convert_trackpid_to_onnx.py)

Development

  • Inherits from @AndrewEdmonds11 TrkQual code
  • Note I will do some further work on this to fully test before making a "real" PR

@sophiemiddleton sophiemiddleton marked this pull request as draft April 30, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants