Convert torchscript model to .xml files

I have a pytorch model trained in python without ROOT. Now I wish to load the model in C++ using ROOT for event-by-event inference. The C++ ROOT version which I am going to use comes with the ATLAS analysis release and it does not support pytorch interface.

I wonder if I could convert the torchscript model to a .xml file so I can load it with RReader? Are there any code examples which convert a pretrained torchscript model to .xml files?

May be @moneta can help you.


We don’t have a way to convert to a XML file yet, but we have a way to convert to a ROOT format or to create an header file that can be compiled and used for evaluation of the model using a new functionality introduced in the ROOT master.
The tutorial shows an example on how to convert the model.
If you have any questions or feedback in using this new feature, please let me know

Best regards


Thanks for your reply. The tool does not seem to support Selu function, so I opened a pull request for this Selu activation function for PyTorch Parser by tong-qiu · Pull Request #8958 · root-project/root (

Thank you a lot for the PR. I will review it as soon as possible