[Conformance] Fix input shape generation for Broadcast (f32) #29515
+29
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix Broadcast operation conformance test failure (f32)
Description
In this PR, I fixed a conformance test failure in the Broadcast operation (opset3, type=f32), where the input tensor shape did not meet NumPy broadcasting rules and caused shape inference errors.
In the original test scenario,
input[0]
was a data tensor with incompatible shape (e.g., [37, 15, 15]), andinput[1]
: the target shape was a Constant (e.g., [37, 37, 128]). The generatedinput[0]
could not be broadcast correctly, leading to inference failure in the TEMPLATE plugin.Solution
A custom input shape adjustment logic has been added in
generate_inputs.cpp
. Specifically:input[0]
by replacing incompatible dimensions with1
(when they do not match the target shape or output shape), ensuring compliance with NumPy broadcasting rules.Test Result
The
Broadcast.3_Type=f32
conformance test now passes successfully.However, the
Broadcast.3_Type=i64
test case still fails. Based on the analysis, the cause is different:input[1]
(target shape) is aParameter
instead of aConstant
.Parameter
, which may not conform to broadcasting rules.input[1]
, and notinput[0]
, this PR focuses solely on fixing the f32 case.Note: I'm happy to follow up with a separate fix for the i64 case if needed (e.g., by improving test model generation or adjusting framework behavior). Feedback and suggestions are welcome! 🙂
Related Issue
Fixes #23549