Skip to content

Commit 6075207

Browse files
committed
[tmva][sofie] Re-introduce an exception when parsing the ONNX nodes and input type of operator is not found
1 parent 3db1d0f commit 6075207

File tree

1 file changed

+42
-55
lines changed

1 file changed

+42
-55
lines changed

tmva/sofie_parsers/src/RModelParser_ONNX.cxx

Lines changed: 42 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ std::unique_ptr<ROperator> make_ROperator_Add(const onnx::NodeProto& nodeproto,
5151
else
5252
assert(it->second == input_type);
5353
} else {
54-
//throw std::runtime_error("TMVA::SOFIE ONNX Parser Add op has input tensor " + input_name + " but its type is not yet registered");
55-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
56-
" op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
57-
input_type = ETensorType::FLOAT;
54+
throw std::runtime_error("TMVA::SOFIE ONNX Parser Add op has input tensor " + input_name + " but its type is not yet registered");
55+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
56+
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
57+
// input_type = ETensorType::FLOAT;
5858
}
5959
}
6060

@@ -85,10 +85,10 @@ std::unique_ptr<ROperator> make_ROperator_Transpose(const onnx::NodeProto& nodep
8585
if (it != tensor_type.end()){
8686
input_type = it->second;
8787
}else{
88-
//throw std::runtime_error("TMVA::SOFIE ONNX Parser tranpose op has input tensor" + input_name + " but its type is not yet registered");
89-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
90-
" op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
91-
input_type = ETensorType::FLOAT;
88+
throw std::runtime_error("TMVA::SOFIE ONNX Parser tranpose op has input tensor" + input_name + " but its type is not yet registered");
89+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
90+
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
91+
// input_type = ETensorType::FLOAT;
9292
}
9393

9494
std::unique_ptr<ROperator> op;
@@ -128,9 +128,9 @@ std::unique_ptr<ROperator> make_ROperator_Identity(const onnx::NodeProto& nodepr
128128
if (it != tensor_type.end()){
129129
input_type = it->second;
130130
}else{
131-
//throw std::runtime_error("TMVA::SOFIE ONNX Parser Identity op has input tensor" + input_name + " but its type is not yet registered");
132-
std::cout << "TMVA::SOFIE ONNX Parser Identity op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
133-
input_type = ETensorType::FLOAT;
131+
throw std::runtime_error("TMVA::SOFIE ONNX Parser Identity op has input tensor" + input_name + " but its type is not yet registered");
132+
// std::cout << "TMVA::SOFIE ONNX Parser Identity op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
133+
// input_type = ETensorType::FLOAT;
134134
}
135135

136136
std::unique_ptr<ROperator> op;
@@ -162,10 +162,10 @@ std::unique_ptr<ROperator> make_ROperator_Relu(const onnx::NodeProto& nodeproto,
162162
if (it != tensor_type.end()){
163163
input_type = it->second;
164164
}else{
165-
//throw std::runtime_error("TMVA::SOFIE ONNX Parser relu op has input tensor" + input_name + " but its type is not yet registered");
166-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
167-
" op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
168-
input_type = ETensorType::FLOAT;
165+
throw std::runtime_error("TMVA::SOFIE ONNX Parser relu op has input tensor" + input_name + " but its type is not yet registered");
166+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
167+
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
168+
// input_type = ETensorType::FLOAT;
169169
}
170170

171171
std::unique_ptr<ROperator> op;
@@ -264,12 +264,12 @@ std::unique_ptr<ROperator> make_ROperator_Softmax(const onnx::NodeProto &nodepro
264264
if (it != tensor_type.end()) {
265265
input_type = it->second;
266266
} else {
267-
// throw std::runtime_error("TMVA::SOFIE ONNX Parser Softmax op has input tensor" + input_name + " but its type is
268-
// not yet registered");
269-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type()
270-
<< " op has input tensor" + input_name + " but its type is not yet registered - use default float "
271-
<< std::endl;
272-
input_type = ETensorType::FLOAT;
267+
throw std::runtime_error("TMVA::SOFIE ONNX Parser Softmax op has input tensor " + input_name +
268+
" but its type is not yet registered");
269+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type()
270+
// << " op has input tensor" + input_name + " but its type is not yet registered - use default float "
271+
// << std::endl;
272+
// input_type = ETensorType::FLOAT;
273273
}
274274

275275
std::unique_ptr<ROperator> op;
@@ -300,7 +300,7 @@ std::unique_ptr<ROperator> make_ROperator_GemmFromMatMulandAdd(const onnx::NodeP
300300
if (it != tensor_type.end())
301301
input_type = ETensorType::FLOAT;
302302
else
303-
throw std::runtime_error("TMVA::SOFIE ONNX Parser MatMul op has input tensor" + input_name + " but its type is not yet registered");
303+
throw std::runtime_error("TMVA::SOFIE ONNX Parser MatMul op has input tensor " + input_name + " but its type is not yet registered");
304304
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto1.op_type() <<
305305
// " op has input tensor " + input_name + " but its type is not yet registered - use default float " << std::endl;
306306

@@ -309,20 +309,7 @@ std::unique_ptr<ROperator> make_ROperator_GemmFromMatMulandAdd(const onnx::NodeP
309309
throw std::runtime_error("TMVA::SOFIE ONNX Parser : cannot fuse MatMul and Add since have different inputs");
310310

311311
// we don't check input type of ADD since it is not be registered
312-
// for (int i = 0; i < 2; ++i) {
313-
// auto input_name = nodeproto2.input(i);
314-
// auto it = tensor_type.find(input_name);
315-
// if (it != tensor_type.end()){
316-
// if (input_type != it->second)
317-
// throw std::runtime_error("TMVA::SOFIE ONNX Parser : cannot fuse MatMul and Add : inputs have different types");
318-
// // according to ONNX both inputs have same time
319-
// } else {
320-
// //throw std::runtime_error("TMVA::SOFIE ONNX Parser Add op has input tensor" + input_name + " but its type is not yet registered");
321-
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto2.op_type() <<
322-
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
323-
// input_type = ETensorType::FLOAT;
324-
// }
325-
// }
312+
326313
std::unique_ptr<ROperator> op;
327314

328315

@@ -418,10 +405,10 @@ std::unique_ptr<ROperator> make_ROperator_GRU(const onnx::NodeProto& nodeproto,
418405
if (it != tensor_type.end()) {
419406
input_type = it->second;
420407
} else {
421-
//throw std::runtime_error("TMVA::SOFIE ONNX Parser GRU op has input tensor " + input_name + " but its type is not yet registered");
422-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
423-
" op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
424-
input_type = ETensorType::FLOAT;
408+
throw std::runtime_error("TMVA::SOFIE ONNX Parser GRU op has input tensor " + input_name + " but its type is not yet registered");
409+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
410+
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
411+
// input_type = ETensorType::FLOAT;
425412
}
426413

427414
std::unique_ptr<ROperator> op;
@@ -512,11 +499,11 @@ std::unique_ptr<ROperator> make_ROperator_Conv(const onnx::NodeProto& nodeproto,
512499
if (it != tensor_type.end()) {
513500
input_type = it->second;
514501
} else {
515-
//throw
516-
// std::runtime_error("TMVA::SOFIE ONNX Parser Conv op has input tensor " + input_name + " but its type is not yet registered");
517-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
518-
" op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
519-
input_type = ETensorType::FLOAT;
502+
throw
503+
std::runtime_error("TMVA::SOFIE ONNX Parser Conv op has input tensor " + input_name + " but its type is not yet registered");
504+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
505+
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
506+
// input_type = ETensorType::FLOAT;
520507
}
521508

522509
std::unique_ptr<ROperator> op;
@@ -675,11 +662,11 @@ std::unique_ptr<ROperator> make_ROperator_Reshape(const onnx::NodeProto &nodepro
675662
if (it != tensor_type.end()) {
676663
input_type = it->second;
677664
} else {
678-
//throw std::runtime_error("TMVA::SOFIE ONNX Parser Reshape op has input tensor" + input_name +
679-
// " but its type is not yet registered");
680-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
681-
" op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
682-
input_type = ETensorType::FLOAT;
665+
throw std::runtime_error("TMVA::SOFIE ONNX Parser Reshape op has input tensor" + input_name +
666+
" but its type is not yet registered");
667+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
668+
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
669+
// input_type = ETensorType::FLOAT;
683670
}
684671

685672
// Reshape is having one attribute: allowzero (int) (default = 0)
@@ -1002,11 +989,11 @@ std::unique_ptr<ROperator> make_ROperator_BatchNormalization(const onnx::NodePro
1002989
if (it != tensor_type.end()) {
1003990
input_type = it->second;
1004991
} else {
1005-
//throw std::runtime_error("TMVA::SOFIE ONNX Parser BatchNorm op has input tensor " + input_name +
1006-
// " but its type is not yet registered");
1007-
std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
1008-
" op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
1009-
input_type = ETensorType::FLOAT;
992+
throw std::runtime_error("TMVA::SOFIE ONNX Parser BatchNorm op has input tensor " + input_name +
993+
" but its type is not yet registered");
994+
// std::cout << "TMVA::SOFIE ONNX Parser " << nodeproto.op_type() <<
995+
// " op has input tensor" + input_name + " but its type is not yet registered - use default float " << std::endl;
996+
// input_type = ETensorType::FLOAT;
1010997
}
1011998

1012999
std::unique_ptr<ROperator> op;

0 commit comments

Comments
 (0)