Repository navigation
[tmva][sofie] register Swish operator in the ONNX parser - #22564
Conversation
|
kindly review, thanks. On a side note, I had a doubt whether we would need a clean build for this as well? Since for the last 2 PR there was some caching issue where simple build was failing. @guitargeek |
lmoneta
left a comment
There was a problem hiding this comment.
Thank you for the PR. Interesting we add the suppot in the ROPerator but missed the parser.
Nice you included also the test.
We can maybe simplify the code, removing the template parameter in ROperator_Swish
Test Results 23 files 23 suites 3d 14h 42m 29s ⏱️ Results for commit eb39001. ♻️ This comment has been updated with latest results. |
|
i've updated the PR with the requested changes, kindly review, thanks |
|
the build is currently failing on several platforms, CI logs doesn't seeem to show any issues related to swish tho, I'll try and take a look to see what could be the issue |
I don't know how you get to that conclusion, you can see it clearly in the log that the failure is related to the ======================================================================
ERROR: test_functional (sofie_keras_parser.SOFIE_Keras_Parser.test_functional) [Functional Activation layer Swish test]
----------------------------------------------------------------------
Traceback (most recent call last):
File "/github/home/ROOT-CI/src/bindings/pyroot/pythonizations/test/sofie_keras_parser.py", line 72, in run_model_tests
generate_and_test_inference(keras_model_path, f"{model_type}/generated_header_files_dir")
File "/github/home/ROOT-CI/src/bindings/pyroot/pythonizations/test/parser_test_function.py", line 55, in generate_and_test_inference
rmodel = ROOT.TMVA.Experimental.SOFIE.PyKeras.Parse(model_file_path, batch_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/github/home/ROOT-CI/build/lib/ROOT/_pythonization/_tmva/_sofie/_parser/_keras/parser.py", line 432, in Parse
rmodel = add_layer_into_RModel(rmodel, layer_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/github/home/ROOT-CI/build/lib/ROOT/_pythonization/_tmva/_sofie/_parser/_keras/parser.py", line 211, in add_layer_into_RModel
rmodel.AddOperator(move_operator(mapKerasLayer[fLayerType](layer_data)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/github/home/ROOT-CI/build/lib/ROOT/_pythonization/_tmva/_sofie/_parser/_keras/parser.py", line 31, in MakeKerasActivation
return mapKerasLayer[fLayerActivation](layer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/github/home/ROOT-CI/build/lib/ROOT/_pythonization/_tmva/_sofie/_parser/_keras/layers/swish.py", line 25, in MakeKerasSwish
op = SOFIE.ROperator_Swish("float")(fLayerInputName, fLayerOutputName)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: none of the 4 overloaded methods succeeded. Full details:
ROperator_Swish::ROperator_Swish(TMVA::Experimental::SOFIE::ROperator_Swish&&) =>
TypeError: could not convert argument 1
ROperator_Swish::ROperator_Swish(const TMVA::Experimental::SOFIE::ROperator_Swish&) =>
TypeError: could not convert argument 1
ROperator_Swish::ROperator_Swish() =>
TypeError: takes at most 0 arguments (1 given)
ROperator_Swish::ROperator_Swish(string nameX, string nameY) =>
TypeError: takes at least 2 arguments (1 given)
======================================================================I'll update the PR with the simple fix, approve and merge. |
This PR registers the existing Swish operator in the ONNX parser. `ROperator_Swish` was implemented but never registered, so a model with the standard ONNX `Swish` op (opset 24) failed with "Operator type Swish is not yet supported". I've added `ParseSwish` and it also reads the optional `alpha` attribute and rejectes when alpha!=1, since right now the op only implements alpha=1. Correspondingly "Swish" has been registered in `RModelParser_ONNX`. Also added a `Swish` test model with reference and a test patch/ Closes root-project#22552.
0ac5a25 to
eb39001
Compare
guitargeek
left a comment
There was a problem hiding this comment.
LGTM, thank you very much for the fixes!
|
apologies for not correctly noticing the error in the logs, thank you for the changes |
Changes or fixes:
This PR registers the existing Swish operator in the ONNX parser.
ROperator_Swishwas implemented but never registered, so a model with the standard ONNXSwishop (opset 24) failed with "Operator type Swish is not yet supported".I've added
ParseSwishand it also reads the optionalalphaattribute and rejectes when alpha!=1, since right now the op only implements alpha=1. Correspondingly "Swish" has been registered inRModelParser_ONNX.Also added a
Swishtest model with reference and a test patch/Checklist:
This PR fixes #22552