detect invalid nodes and invalid graph in onnxruntime before handing them to execution providers #8152
Replies: 4 comments 7 replies
-
There is onnx checker that is exposed in python. |
Beta Was this translation helpful? Give feedback.
-
But tests like TEST(BatchNormTest, InvalidScaleDim) are unit c++ tests that test onnxruntime and its execution providers. Because onnxruntime doesn't catch the invalid node, it got handed to the execution provider which also doesn't check for it. So this test didn't pass. |
Beta Was this translation helpful? Give feedback.
-
ORT already uses onnx checker. see onnxruntime/onnxruntime/core/graph/graph.cc Line 2342 in d14b08d if the validation is op specific, then it's up to each execution provider to implement that specific validation. (because the EP may choose to implement all/part/none of the onnx spec for that operator) |
Beta Was this translation helpful? Give feedback.
-
A couple of different comments: (a) Agree that a check can and should be added to the shape-inference method for this op. (b) However, there is a difference between a static-checker and a runtime-checker. A static-checker like the ONNX checker can never catch all possible issues. For example, in this case, the tensor may be of an unknown rank during static-checking. So, kernels can't avoid runtime-checks. A shared checker may make sense, but then we would need a shared "runtime checker", not a "static checker". |
Beta Was this translation helpful? Give feedback.
-
Tests like TEST(BatchNormTest, InvalidScaleDim) have invalid values in the node attribute to test if invalid nodes are detected. It seems that it would make more sense for onnxruntime to check nodes in the graph and detect invalid ones before handing the graph to execution providers. If it's checked by onnxruntime, the code is written once in onnxruntime. If it's checked by execution providers, the code has to be written by every execution provider. It's one implementation vs n number of implementations for n number of execution providers.
Beta Was this translation helpful? Give feedback.
All reactions