Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions TrkQual/scripts/CreateInference.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// \file
/// \ingroup tutorial_tmva
/// \notebook -nodraw
/// This macro parses a .onnx file
/// into RModel object and further generating the .hxx header files for inference.
///
/// \macro_code
/// \macro_output
/// \author Sanjiban Sengupta
/// modified by A. Edmonds (2025)

#include "TMVA/RModel.hxx"
#include "TMVA/RModelParser_ONNX.hxx"
#include <iostream>

using namespace TMVA::Experimental;

//bname is the base name the model saved as
void CreateInference(const char* bname,const char* suffix=""){
std::string modelname = std::string("model/") + std::string(bname) + std::string(".onnx");
std::string infername = std::string("code/") + std::string(bname) +std::string(suffix) + std::string(".hxx");

SOFIE::RModelParser_ONNX parser;
SOFIE::RModel model = parser.Parse(modelname, true);

//Generating inference code
model.Generate();
// write the code in a file (by default Linear_16.hxx and Linear_16.dat
model.OutputGenerated(infername);
}