# TMVA::SOFIE Operator type Constant

**URL:** <https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599>\
**Category:** TMVA\
**Created:** [June 9, 2024, 8:44pm UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599 "2024-06-09T20:44:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pedro\_Silva](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pedro_silva/32/33176_2.png) [@Pedro\_Silva](https://root-forum.cern.ch/u/Pedro_Silva)\
**Post date:** [June 9, 2024, 8:44pm UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/1 "2024-06-09T20:44:38Z")

</div>

Dear all,  
I’m having trouble importing a model using TMVA::SOFIE.  
The model was been trained with pytorch and I exported it to onnx following the recommendations found in the examples/forum.  
However when I try to parse it with SOFIE I get the error below [1]  
I’m using a standard LCG view (similar to the current default in swan) [2]  
I put the original torch and onnx files here, if needed [3].  
Any help is appreciated,  
thanks a lot,  
Pedro

* * *

[1]

```auto
Fill RModel with operators...
	0 0 parsing operator Constant
Parsing an operator Constant
Traceback (most recent call last):
  File "/eos/home-p/psilva/SWAN_projects/sdanalysis/notebooks/trainPzRegression.py", line 59, in <module>
    main()
  File "/eos/home-p/psilva/SWAN_projects/sdanalysis/notebooks/trainPzRegression.py", line 47, in main
    onnx2sofie(onnxfile)
  File "/eos/home-p/psilva/SWAN_projects/sdanalysis/notebooks/trainPzRegression.py", line 23, in onnx2sofie
    model=parser.Parse(onnxfile,True)
cppyy.gbl.std.runtime_error: TMVA::Experimental::SOFIE::RModel TMVA::Experimental::SOFIE::RModelParser_ONNX::Parse(string filename, bool verbose = false) =>
    runtime_error: TMVA::SOFIE Operator type Constant is not yet supported

```

[2] /cvmfs/sft.cern.ch/lcg/views/LCG\_105\_cuda/x86\_64-el9-gcc11-opt/setup.sh

[3] /afs/cern.ch/user/p/psilva/public/torch\_model/semiparametric\_model\_default.torch

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 10, 2024, 7:14am UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/2 "2024-06-10T07:14:13Z")

</div>

Dear Pedro,

I am sorry to read you are experiencing this problem.  
The error seems to be quite clear, but I add in the loop @moneta in case he can help out.

Best,  
Danilo

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 10, 2024, 8:55am UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/3 "2024-06-10T08:55:23Z")

</div>

Dear Pedro,

The operator 'Constant` is not currently support. It is however a trivial operator and we are going to add it soon. I will let you know when is included so you can try it using the nightly build of ROOT.  
I am sorry for this trouble

Best regards,

Lorenzo

---

<div class="post-metadata">

**Author:** ![Pedro\_Silva](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pedro_silva/32/33176_2.png) [@Pedro\_Silva](https://root-forum.cern.ch/u/Pedro_Silva)\
**Post date:** [June 10, 2024, 9:04am UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/4 "2024-06-10T09:04:49Z")

</div>

Dear Lorenzo (and Danilo)  
many thanks, it’s very much appreciated.  
Cheers,  
Pedro

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 14, 2024, 4:10pm UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/5 "2024-06-14T16:10:25Z")

</div>

Dear Pedro,

I have created a PR, which now fixes the problems found parsing your model.  
[root-project/root#15837](https://github.com/root-project/root/pull/15837)  
I have tested with your model and it works.  
I will let you know when is merged

Lorenzo

---

<div class="post-metadata">

**Author:** ![Pedro\_Silva](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pedro_silva/32/33176_2.png) [@Pedro\_Silva](https://root-forum.cern.ch/u/Pedro_Silva)\
**Post date:** [June 15, 2024, 6:48am UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/6 "2024-06-15T06:48:56Z")

</div>

Dear Lorenzo,  
many thanks - it’s very much appreciated  
Looking forward for the integration  
Cheers,  
Pedro

---

<div class="post-metadata">

**Author:** ![Pedro\_Silva](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pedro_silva/32/33176_2.png) [@Pedro\_Silva](https://root-forum.cern.ch/u/Pedro_Silva)\
**Post date:** [June 25, 2024, 11:17am UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/7 "2024-06-25T11:17:28Z")

</div>

Dear Lorenzo,  
any chance it got integrated? I would be eager to test it  
thanks a lot,  
Pedro

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 25, 2024, 4:17pm UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/8 "2024-06-25T16:17:29Z")

</div>

Dear Pedro,  
Sorry for the delay. I’ll ping the reviewer to approve the PR, so it will be integrated. I will let you know  
Lorenzo

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 28, 2024, 2:47pm UTC](https://root-forum.cern.ch/t/tmva-sofie-operator-type-constant/59599/9 "2024-06-28T14:47:27Z")

</div>

The Constant operator is now available and the nightly builds should be able to parse the model you posted. See [Nightlies - ROOT](https://root.cern/install/nightlies/) to use the nightly version

If you have still issues, please let me know

Best regards

Lorenzo
