Skip to content

TMVA_SOFIE_ONNX.C tutorial fails with modern PyTorch due to tensor name mismatch #21545

@Neeraj-x0

Description

@Neeraj-x0

Check duplicate issues.

  • Checked for duplicates

Description

The tutorial TMVA_SOFIE_ONNX.C hardcodes a lookup for a tensor named "16weight"
(line 39), but the companion script TMVA_SOFIE_ONNX.py generates an ONNX model
where tensors are named "0weight", "2weight", "4weight" etc. (PyTorch default
Sequential module naming). This causes a runtime_error when running the C++ tutorial.

Expected behavior: The tutorial should run end-to-end without manually providing
a pre-existing ONNX file.

Workaround: Copy tmva/sofie/test/input_models/Linear_16.onnx into the build
tutorials directory manually.

Reproducer

  1. Run the Python script to generate the ONNX model:
    cd $ROOTSYS/tutorials/machine_learning
    python3 TMVA_SOFIE_ONNX.py

  2. Run the C++ tutorial:
    root -l TMVA_SOFIE_ONNX.C

Error:
TMVA SOFIE tensor [16weight] for which the shape is requested is not found
terminate called after throwing an instance of 'std::runtime_error'

The Python script generates tensors named "0weight", "2weight", "4weight"
but the C++ tutorial looks up "16weight" which does not exist in the model.

ROOT version

6.39.01

Installation method

Built from source

Operating system

Ubuntu 24.04

Additional context

PyTorch version: 2.10.0+cu128
The correct Linear_16.onnx already exists in tmva/sofie/test/input_models/
and works correctly when copied manually to the build directory. The tutorial
and the Python script appear to be out of sync.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions