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

[GSOC][TMVA][SOFIE] Cast ONNX Operator implemented with the corresponding unit tests #11033

Merged
merged 8 commits into from Aug 16, 2022

Conversation

Neel-Shah-29
Copy link
Contributor

This Pull request: Adds the Cast ONNX Operator with the corresponding Unit tests to validate the written code.

Checklist:

  • tested changes locally
  • updated the docs (if necessary)

Added the functionality and support of int input type in Cast ONNX Operator
@phsft-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@lmoneta
Copy link
Member

lmoneta commented Jul 22, 2022

@phsft-bot build just on ROOT-ubuntu2204/default, ROOT-ubuntu2004/default, ROOT-ubuntu18.04/default with flags -Dtmva-sofie=On

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-ubuntu2204/default, ROOT-ubuntu2004/default, ROOT-ubuntu18.04/default with flags -Dtmva-sofie=On
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu18.04/default.
Running on sft-ubuntu-1804-2.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-07-22T21:45:48.852Z] FAILED: tmva/sofie/test/CMakeFiles/TestCustomModelsFromONNX.dir/TestCustomModelsFromONNX.cxx.o
  • [2022-07-22T21:45:48.852Z] /mnt/build/workspace/root-pullrequests-build/build/tmva/sofie/test/Cast_FromONNX.hxx:18:1: error: ‘infer’ does not name a type; did you mean ‘index’?
  • [2022-07-22T21:45:48.852Z] /mnt/build/workspace/root-pullrequests-build/root/tmva/sofie/test/TestCustomModelsFromONNX.cxx:340:34: error: ‘struct TMVA_SOFIE_Cast::Session’ has no member named ‘infer’

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2004/default.
Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-07-22T21:45:46.420Z] FAILED: tmva/sofie/test/CMakeFiles/SofieCompileModels_ROOT.util

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2204/default.
Running on root-ubuntu-2204-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-07-22T21:45:41.510Z] /home/sftnight/build/workspace/root-pullrequests-build/build/tmva/sofie/test/Cast_FromONNX.hxx:18:1: error: ‘infer’ does not name a type
  • [2022-07-22T21:45:41.510Z] /home/sftnight/build/workspace/root-pullrequests-build/root/tmva/sofie/test/TestCustomModelsFromONNX.cxx:340:34: error: ‘struct TMVA_SOFIE_Cast::Session’ has no member named ‘infer’

@lmoneta
Copy link
Member

lmoneta commented Aug 1, 2022

@phsft-bot build just on ROOT-ubuntu2204/default with flags -Dtmva-sofie=On

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-ubuntu2204/default
How to customize builds

@lmoneta
Copy link
Member

lmoneta commented Aug 1, 2022

@phsft-bot build just on ROOT-ubuntu2204/default, ROOT-ubuntu2004/default, ROOT-ubuntu18.04/default with flags -Dtmva-sofie=On

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-ubuntu2204/default, ROOT-ubuntu2004/default, ROOT-ubuntu18.04/default with flags -Dtmva-sofie=On
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2204/default.
Running on root-ubuntu-2204-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-08-01T16:00:45.356Z] /home/sftnight/build/workspace/root-pullrequests-build/build/tmva/sofie/test/Cast_FromONNX.hxx:18:1: error: ‘infer’ does not name a type
  • [2022-08-01T16:00:45.356Z] /home/sftnight/build/workspace/root-pullrequests-build/root/tmva/sofie/test/TestCustomModelsFromONNX.cxx:340:34: error: ‘struct TMVA_SOFIE_Cast::Session’ has no member named ‘infer’

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu18.04/default.
Running on sft-ubuntu-1804-3.cern.ch:/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-08-01T16:01:57.184Z] FAILED: tmva/sofie/test/CMakeFiles/TestCustomModelsFromONNX.dir/TestCustomModelsFromONNX.cxx.o
  • [2022-08-01T16:01:57.184Z] /mnt/build/workspace/root-pullrequests-build/build/tmva/sofie/test/Cast_FromONNX.hxx:18:1: error: ‘infer’ does not name a type; did you mean ‘index’?
  • [2022-08-01T16:01:57.184Z] /mnt/build/workspace/root-pullrequests-build/root/tmva/sofie/test/TestCustomModelsFromONNX.cxx:340:34: error: ‘struct TMVA_SOFIE_Cast::Session’ has no member named ‘infer’

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2004/default.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Errors:

  • [2022-08-01T16:02:12.102Z] FAILED: tmva/sofie/test/CMakeFiles/TestCustomModelsFromONNX.dir/TestCustomModelsFromONNX.cxx.o
  • [2022-08-01T16:02:12.668Z] tmva/sofie/test/Cast_FromONNX.hxx:18:1: error: ‘infer’ does not name a type
  • [2022-08-01T16:02:12.668Z] /home/sftnight/build/workspace/root-pullrequests-build/root/tmva/sofie/test/TestCustomModelsFromONNX.cxx:340:34: error: ‘struct TMVA_SOFIE_Cast::Session’ has no member named ‘infer’

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Neel-Shah-29 , please include the support for the other type of casting.

The generate code has also some issues, from the test one has:

//Code generated automatically by TMVA for Inference of Model file [Cast.onnx] at [Mon Aug  1 16:00:41 2022] 

#ifndef TMVA_SOFIE_CAST
#define TMVA_SOFIE_CAST

#include<vector>
#include "TMVA/SOFIE_common.hxx"
#include <fstream>

namespace TMVA_SOFIE_Cast{
struct Session {


Session(std::string filename ="") {
   if (filename.empty()) filename = "Cast.dat";
}

infer){

//------ CAST
   for (int id = 0; id < 6 ; id++){
      tensor_1[id] = (float)(tensor_onnxCast0[id]);
   }
	std::vector<float> ret (tensor_1, tensor_1 + 6);
	return ret;
}
};
} //TMVA_SOFIE_Cast

the infer function is not correctly defined. This is happening in RModel, because it sees that there is no output tensor. I think in this case a void infer function should be generated, I will fix this.
However, the input model should have an output tensor. This is maybe a possible problem with the generated test model. Can you please check this too

tmva/sofie_parsers/src/RModelParser_ONNX.cxx Show resolved Hide resolved
tmva/sofie/inc/TMVA/ROperator_Cast.hxx Outdated Show resolved Hide resolved
tmva/sofie_parsers/src/RModelParser_ONNX.cxx Show resolved Hide resolved
tmva/sofie_parsers/src/RModelParser_ONNX.cxx Show resolved Hide resolved
…operator and added the support to RModel::Generate method also
tmva/sofie/src/SOFIE_common.cxx Outdated Show resolved Hide resolved
tmva/sofie/src/SOFIE_common.cxx Outdated Show resolved Hide resolved
tmva/sofie/src/RModel.cxx Outdated Show resolved Hide resolved
@lmoneta
Copy link
Member

lmoneta commented Aug 4, 2022

@phsft-bot build just on ROOT-ubuntu2204/default with flags -Dtmva-sofie=On

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-ubuntu2204/default
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2204/default.
Running on root-ubuntu-2204-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2022-08-04T19:19:46.227Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-04T19:19:47.363Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-04T19:19:51.687Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-04T19:19:53.750Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]

Failing tests:

tmva/sofie/src/RModel.cxx Outdated Show resolved Hide resolved
tmva/sofie/src/RModel.cxx Outdated Show resolved Hide resolved
tmva/sofie/src/SOFIE_common.cxx Outdated Show resolved Hide resolved
Neel-Shah-29 and others added 2 commits August 8, 2022 16:26
This fixes the new Cast operator.
Several changes are needed for Cast since the input tensor can be of a type different than float

Also a fix for parsing correctly the attribute of Cast is applied
@lmoneta
Copy link
Member

lmoneta commented Aug 12, 2022

@phsft-bot build just on ROOT-ubuntu2204/default with flags -Dtmva-sofie=On

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-ubuntu2204/default with flags -Dtmva-sofie=On
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2204/default.
Running on root-ubuntu-2204-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2022-08-12T16:09:56.332Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-12T16:10:01.497Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-12T16:10:08.038Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-12T16:10:19.407Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]

Failing tests:

@lmoneta
Copy link
Member

lmoneta commented Aug 16, 2022

@phsft-bot build just on ROOT-ubuntu2204/default with flags -Dtmva-sofie=On

@phsft-bot
Copy link
Collaborator

Starting build on ROOT-ubuntu2204/default with flags -Dtmva-sofie=On
How to customize builds

@phsft-bot
Copy link
Collaborator

Build failed on ROOT-ubuntu2204/default.
Running on root-ubuntu-2204-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Warnings:

  • [2022-08-16T10:30:35.727Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-16T10:30:37.493Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-16T10:30:41.320Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]
  • [2022-08-16T10:30:44.739Z] /usr/include/python3.10/numpy/__multiarray_api.h:1464:1: warning: ‘int _import_array()’ defined but not used [-Wunused-function]

Failing tests:

Copy link
Member

@lmoneta lmoneta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, Thank you Neel for including all my comments!

tmva/sofie/inc/TMVA/ROperator_Cast.hxx Outdated Show resolved Hide resolved
@lmoneta lmoneta merged commit 2c97479 into root-project:master Aug 16, 2022
@Neel-Shah-29 Neel-Shah-29 deleted the Neel-Shah-Cast branch August 16, 2022 11:04
@Neel-Shah-29 Neel-Shah-29 restored the Neel-Shah-Cast branch August 17, 2022 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants