This macro provides a simple example for the parsing of ONNX files into RModel object and further generating the .hxx header files for inference.
void TMVA_SOFIE_ONNX(std::string inputFile = ""){
if (inputFile.empty() )
inputFile = std::string(
gROOT->GetTutorialsDir()) +
"/machine_learning/Linear_16.onnx";
model.Generate();
model.OutputGenerated();
model.PrintRequiredInputTensors();
std::cout<<"\n\n";
model.PrintInitializedTensors();
std::cout<<"\n\n";
model.PrintIntermediateTensors();
std::cout<<"\n\nTensor \"16weight\" already exist: "<<std::boolalpha<<model.CheckIfTensorAlreadyExist("16weight")<<"\n\n";
std::vector<size_t> tensorShape = model.GetTensorShape("16weight");
std::cout<<"Shape of tensor \"16weight\": ";
for(auto& it:tensorShape){
std::cout<<it<<",";
}
std::cout<<"\n\nData type of tensor \"16weight\": ";
std::cout<<"\n\n";
model.PrintGenerated();
}
RModel Parse(std::string const &filename, bool verbose=false)
std::string ConvertTypeToString(ETensorType type)
- Author
- Sanjiban Sengupta
Definition in file TMVA_SOFIE_ONNX.C.