Skip to content

Conversation

@lmoneta
Copy link
Member

@lmoneta lmoneta commented Jan 13, 2026

This PR superseeds #19692 fixing the conflicts and add some bug fixes

@guitargeek
Copy link
Contributor

Thanks for the PR! One two things to do before a more detailed review is to merge #15790 and fix the test failures in this PR. But I also have a general question, the same as in #19692 (comment): why not remove the old C++ parser at the same time, so we don't risk code duplication and user confusion?

@github-actions
Copy link

github-actions bot commented Jan 13, 2026

Test Results

    21 files      21 suites   3d 5h 32m 25s ⏱️
 3 788 tests  3 778 ✅ 0 💤 10 ❌
71 538 runs  71 509 ✅ 0 💤 29 ❌

For more details on these failures, see this check.

Results for commit ca33772.

♻️ This comment has been updated with latest results.

@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch 4 times, most recently from 0c9d958 to d592d31 Compare January 16, 2026 09:56
@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch 2 times, most recently from e7a5b7c to fc8f6a4 Compare January 30, 2026 13:12
@guitargeek
Copy link
Contributor

@lmoneta, it seems the new Python files are missing in the relevant CMakeLists.txt now, which is my fault because I have moved that CMakeLists.txt file in 3281aa9 to bindings/pyroot/pythonizations/python/CMakeLists.txt. Can you please add the Python files there now? Thanks!

diff --git a/bindings/pyroot/pythonizations/python/CMakeLists.txt b/bindings/pyroot/pythonizations/python/CMakeLists.txt
index 4c96c7556c7..e9bbed07628 100644
--- a/bindings/pyroot/pythonizations/python/CMakeLists.txt
+++ b/bindings/pyroot/pythonizations/python/CMakeLists.txt
@@ -58,7 +58,33 @@ if(tmva)
         ROOT/_pythonization/_tmva/_rtensor.py
         ROOT/_pythonization/_tmva/_tree_inference.py
         ROOT/_pythonization/_tmva/_utils.py
-        ROOT/_pythonization/_tmva/_gnn.py)
+        ROOT/_pythonization/_tmva/_gnn.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/__init__.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/generate_keras_functional.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/generate_keras_sequential.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/parser.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/parser_test_function.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/__init__.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/batchnorm.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/binary.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/concat.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/conv.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/dense.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/elu.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/flatten.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/identity.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/layernorm.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/leaky_relu.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/permute.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/pooling.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/reshape.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/relu.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/rnn.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/selu.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/sigmoid.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/softmax.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/swish.py
+        ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/tanh.py)
     if(dataframe)
       list(APPEND PYROOT_EXTRA_PYTHON_SOURCES
           ROOT/_pythonization/_tmva/_batchgenerator.py)

@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch 4 times, most recently from fe22713 to fef1ba1 Compare February 3, 2026 15:47
PrasannaKasar and others added 7 commits February 3, 2026 18:08
…ers and added tests for them. Imported Keras within the required functions. Created new CMakeLists.txt file for the keras parser. Made changes in the pythonization CMake file to build the keras parser files
…aced import keras_version with get_keras_version and called it in necessary files
… directory. Used import numpy statements within the parser functions to avoid slowing down the import of ROOT.
… Keras3 Sequential

In Keras3 Sequential output of a layer can have a different name than input of the next layer.
Since in sequnrial model each layer has a single input/output use as output names the layer name (which is unique) and set as input name for the next layer
…d C++ parser

- use new python keras parser for parsing a model into SOFIE.
Since new parser is only Python base, move some tutorials from C++ to Python

Remove also tutorial dependency on TMVA_Higgs_Classification by creating and training a model in tutorial TMVA_SOFIE_Keras_HiggsModel.py

Adapt also RSofieReader for using new Python Keras parser
…ndency to test

Fix also an issue in a SOFIE tutorial
With this fix now the Keras parser can parse the convolutional model generated by TMVA_CNN_Classification
Fix bug in Squeeze operator when the axes to squeeze are provided. In that case a wrong usage of vector.erase was done.

Fix the Keras parser tests when convolutions with channel_first are not supported (e.g. on CPU impelmentations of tensorflows)
The bug fixes the closing of the loops on the outer axis. The tests worked because the number of outer axes and normalization axes was the same in the test scripts.
@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch 4 times, most recently from dd9635a to ed4c2bd Compare February 3, 2026 18:11
@guitargeek
Copy link
Contributor

Hi @lmoneta, about these ruff linter errors: I know it's annoying to fix all of them, but many can actually be fixed automatically by running:

ruff check bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tmva/_sofie/_parser/_keras --fix

Ruff can just be installed with pip:
https://github.com/astral-sh/ruff

I think it would be worth it to add a commit that does does these automatic fixes! Then we don't have to update the code again later just for that.

…axpy

Avoid using saxpy and use directly the wrapper function in Sofie_common to call blas and automatically also include the bias addition

fix doing bias for Conv operator, beta must be equal to 1 now we don't use saxpy
@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch from ed4c2bd to 079dc53 Compare February 4, 2026 14:54
The Python files were moved in root-project@3281aa9  in a different location and it was not done during the rebase. This is now fixed

Fix also an issue in parsing input shape from the Keras model and add support also for the different types of input shapes

Increase also test tolerance from 10-3 to 10-2

Add also test RModelKerasParser test
@lmoneta lmoneta force-pushed the tmva_sofie_keras_parser_prasanna branch from 079dc53 to ca33772 Compare February 4, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants