Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tmva][sofie] Add new operators and function to check input ONNX model #17248

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

lmoneta
Copy link
Member

@lmoneta lmoneta commented Dec 11, 2024

This Pull request adds these new operators (including their tests):

In addition, implement:

  • a function to check the ONNX model for missing operators (not yet implmented in SOFIE) in the ONNX parser.
    Example of usage:
    TMVA::Experimental::SOFIE::RModelParser_ONNX p;
    bool ret = p.CheckModel("model.onnx");
  • Fix retrieving the value data for the Constant operator
  • Optimize Broadcast function to avoid unneeded allocations

- optimize broadcast for the special case of last dim and add interface avoiding allocations
- optimize Expand and Binary to use new broadcast interface
A new function has been added to check the model operators (nodes) and
print the list of missing ones (not yet supported)

To use it do:

```
TMVA::Experimental::SOFIE::RModelParser_ONNX p;
bool ret = p.CheckModel("model.onnx");
```

It will return true if all operators of the model are supported.
In case of missing ones, it will print their list.
The check will also extend to subgraph presented in the model as attributes of
some specific nodes (e.g. of If operator)
@lmoneta lmoneta self-assigned this Dec 11, 2024
@lmoneta lmoneta requested a review from bellenot as a code owner December 11, 2024 13:14
Add new pad operator and a corresponding test.

Fix also the parsing of Constant in case explicitly the data are not stored as
raw_data in the onnx::TensorProto class
@lmoneta lmoneta force-pushed the tmva_sofie_operator_devs branch from 9075077 to 8a7d0d4 Compare December 11, 2024 13:15
Copy link

github-actions bot commented Dec 11, 2024

Test Results

     9 files       9 suites   1d 13h 41m 50s ⏱️
 2 685 tests  2 685 ✅ 0 💤 0 ❌
23 167 runs  23 167 ✅ 0 💤 0 ❌

Results for commit fe633a2.

♻️ This comment has been updated with latest results.

Rename the RModel function IsINputTensor because was valid only for tensors without a defined shape.
Add function IsReadyInputTensor to check if a tensor with a defined shape is an input tensor of the model

This change avoids confusion
Add support for new operator Where and add corrisponding test

Fix broadcasting of tensor in case of boolean tensor where one uses a std::vector<bool> instead of a span of bool
@lmoneta lmoneta changed the title [tmva][sofie] Add new Pad operator and a funciton to check ONNX model [tmva][sofie] Add new operators and a funciton to check ONNX model Dec 12, 2024
@lmoneta lmoneta changed the title [tmva][sofie] Add new operators and a funciton to check ONNX model [tmva][sofie] Add new operators and function to check input ONNX model Dec 12, 2024
Add Sin and Cos operators as new Unary operators.
Add also tests, taken from Vedant's PR  root-project#16809
@lmoneta lmoneta force-pushed the tmva_sofie_operator_devs branch from 812964f to 4b12e44 Compare December 13, 2024 11:18
Add first version of Einsum operator. So far we support only the standard
signature for indices (e.g. "ik,kj->i,j") and no broadcasting
Add support for RandomNormal, RandomNormalLike, RandomUniform and RandomUniformLike operators

We add the random operators using the ROOT random number engine.
This gives a ROOT dependency in the generate code. We can add in the future random operator based on std::random
- add support for Transpose in case of integer tensor
- Add support in Slice for constant output
- Add in MatMul (implemented in  ROperator_Gemm) the support for multiplications of matrices with different sizes as in numpy.matmul (e.g. (1,2,3) x (3,4)
- Fix Gather case for constant tenmsor when q=1 (which is equivalent for q=0)
@lmoneta lmoneta force-pushed the tmva_sofie_operator_devs branch from 0306287 to f0944f4 Compare January 9, 2025 12:56
Improve the generated code that declare in the Session constructor the constant tensor. If the tensor size is > 100 do not allocate the constant tensor in the stack (use instad std::vector) to avoid exceeding maximum stack sizes.

Also for tensors which are initialized with all the same values, avoid using initializer lists to speed up compilation times
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant