Check duplicate issues.
Description
BatchNormalization parser currently accepts invalid input count and fails later during code generation.
I was going through tmva/sofie_parsers/src/ParseBatchNormalization.cxx and the code only constructs the operator when nodeproto.input_size() == 5, but does not throw otherwise:
case ETensorType::FLOAT:
if (nodeproto.input_size() == 5) {
op.reset(new ROperator_BatchNormalization<float>(...));
}
break;
This means that nvalid ONNX nodes(e.g. 4 inputs) pass Parse() and fail later in Generate() with an unrelated/less clear error. Expected behavior should have been that Parser rejects immediately with a clear message (BatchNormalization requires exactly 5 inputs).
Reproducer
On running the following script-
import os, tempfile
import onnx
from onnx import helper, TensorProto
import ROOT
X = helper.make_tensor_value_info('X', TensorProto.FLOAT, [1,1,1,1])
S = helper.make_tensor_value_info('S', TensorProto.FLOAT, [1])
B = helper.make_tensor_value_info('B', TensorProto.FLOAT, [1])
M = helper.make_tensor_value_info('M', TensorProto.FLOAT, [1])
Y = helper.make_tensor_value_info('Y', TensorProto.FLOAT, [1,1,1,1])
# Invalid BN: only 4 inputs
node = helper.make_node('BatchNormalization', ['X','S','B','M'], ['Y'])
graph = helper.make_graph([node], 'bn_bad_inputs', [X,S,B,M], [Y])
model = helper.make_model(graph, opset_imports=[helper.make_opsetid('', 13)])
model.ir_version = 10
fd, p = tempfile.mkstemp(suffix='.onnx'); os.close(fd)
onnx.save(model, p)
ROOT.gSystem.Load('libROOTTMVASofieParser')
parser = ROOT.TMVA.Experimental.SOFIE.RModelParser_ONNX()
m = parser.Parse(p) # currently succeeds (unexpected)
m.Generate() # fails later
Observed behavior:
- SOFIE: Parse succeeded, Generate failed later
- ONNX Runtime: input size 4 not in range [5,5]
ROOT version
6.39.01 (built from source)
Installation method
Built from source with SOFIE enabled.
Operating system
Linux (Ubuntu 22.04)
Additional context
No response
Check duplicate issues.
Description
BatchNormalizationparser currently accepts invalid input count and fails later during code generation.I was going through
tmva/sofie_parsers/src/ParseBatchNormalization.cxxand the code only constructs the operator whennodeproto.input_size() == 5, but does not throw otherwise:This means that nvalid ONNX nodes(e.g. 4 inputs) pass Parse() and fail later in Generate() with an unrelated/less clear error. Expected behavior should have been that Parser rejects immediately with a clear message (BatchNormalization requires exactly 5 inputs).
Reproducer
On running the following script-
Observed behavior:
ROOT version
6.39.01 (built from source)
Installation method
Built from source with SOFIE enabled.
Operating system
Linux (Ubuntu 22.04)
Additional context
No response