Add size check on partial_ops x input vector#34595
Add size check on partial_ops x input vector#34595mangguo321 wants to merge 4 commits intoopenvinotoolkit:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds defensive input-count validation to the Paddle frontend partial_ops() converter to avoid out-of-bounds access when the "X" input list is malformed or incomplete.
Changes:
- Validate that
"X"contains exactly 2 inputs before indexingx[0]/x[1]inpartial_ops().
You can also share your feedback on Copilot code review. Take the survey.
|
|
||
| NamedOutputs partial_ops(const NodeContext& node, const std::string type) { | ||
| auto x = node.get_ng_inputs("X"); | ||
| PADDLE_OP_CHECK(node, x.size() == 2, "partial ops require exactly 2 inputs in X."); |
There was a problem hiding this comment.
[HIGH] This adds a hard validation to prevent out-of-bounds access when X has fewer than 2 inputs, but there is no regression test ensuring conversion fails gracefully (rather than crashing) for malformed models / cut models where the X list is size 0/1. Please add a Paddle FE negative test (e.g., reuse an existing partial_sum/partial_concat model and override inputs to leave only one, then assert conversion throws an expected frontend exception and includes this message).
|
|
||
| NamedOutputs partial_ops(const NodeContext& node, const std::string type) { | ||
| auto x = node.get_ng_inputs("X"); | ||
| PADDLE_OP_CHECK(node, x.size() == 2, "partial ops require exactly 2 inputs in X."); |
There was a problem hiding this comment.
| PADDLE_OP_CHECK(node, x.size() == 2, "partial ops require exactly 2 inputs in X."); | |
| PADDLE_OP_CHECK(node, x.size() == 2, "`partial_ops` requires exactly 2 inputs in X."); |
86d9395 to
2295b3e
Compare
| FAIL() << "Expected load to fail due to insufficient X inputs for partial_sum"; | ||
| } catch (const std::exception& ex) { | ||
| const std::string msg = ex.what(); | ||
| ASSERT_NE(msg.find("partial ops require exactly 2 inputs in X."), std::string::npos) << msg; |
There was a problem hiding this comment.
[BLOCKER] The expected substring in the assertion ("partial ops require exactly 2 inputs in X.") does not match the actual error message introduced in partial_ops.hpp ("partial_ops requires exactly 2 inputs in X."). As written, this test will fail even when the new validation triggers. Align the test expectation with the thrown message (or vice versa) so the substring check matches exactly (including underscore and verb tense).
| ASSERT_NE(msg.find("partial ops require exactly 2 inputs in X."), std::string::npos) << msg; | |
| ASSERT_NE(msg.find("partial_ops requires exactly 2 inputs in X."), std::string::npos) << msg; |
Details:
Tickets: