[Paddle FE] dropout: scale with a constant of the input element type - #38095
Open
siyiweigeHEW wants to merge 1 commit into
Open
[Paddle FE] dropout: scale with a constant of the input element type#38095siyiweigeHEW wants to merge 1 commit into
siyiweigeHEW wants to merge 1 commit into
Conversation
The `downgrade_in_infer` branch built the `(1 - dropout_prob)` constant as f32 and multiplied it with the input, so a model whose input is not f32 could not be converted at all: Check 'element::Type::merge(...)' failed ... While validating node 'opset1::Multiply ... (opset1::Parameter x[0]:f64[2,2,3], opset1::Constant Constant_2[0]:f32[1])' Arguments do not have the same element type (arg0 element type: f64, arg1 element type: f32). Paddle exports such a model fine and runs it (dropout is a plain scale by (1 - p) in inference), so the front-end has to accept it as well. Build the scale in f32 and convert it like the input. ConvertLike is used instead of typing the constant with the input element type directly because the element type of the input is not necessarily resolved yet at this point (same reasoning as create_same_type_const_scalar() in atan2.cpp).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Details:
dropoutwithdropout_implementation = downgrade_in_inferis converted toX * (1 - dropout_prob), but the scale constant was always created withov::element::f32. A model whose input is notfloat32therefore failed to convert at all:downgrade_in_inferis just a scale by(1 - p), so nothing in the exported graph depends on the input being f32. This is a front-end robustness gap, not a Paddle restriction.ConvertLikes it to the input.ConvertLikeis used rather than typing the constant with the input element type directly because the element type of the input is not necessarily resolved during conversion (the same reasoning ascreate_same_type_const_scalar()inatan2.cpp, which exists for exactly this case).Reproducer
Same failure with
float16. Before the change:float64andfloat16both fail to convert on master and on 2026.1.0;float32is unaffected.Verification
Built the Paddle front-end from this branch and compared OpenVINO against Paddle's own execution of the exported model (
paddle.static.load_inference_model), 3 dtypes x 2dropout_implementationmodes:x * (1 - p), Paddle CPU has no float16 dropout kernel)float32behaviour is unchanged (upscale_in_trainis a pass-through and is not touched).FrontEndFuzzyOpTest(src/frontends/tests/frontend/shared/src/op_fuzzy.cpp) only loads f32/i32/i64/boolean inputs and outputs and throws for any other dtype, so the non-f32 case this PR fixes cannot be expressed inop_fuzzy.cpp.Tickets:
AI Assistance:
AI assisted with the root-cause analysis and the implementation. Human validation performed: local build of
openvino_paddle_frontendfrom this branch, the reproducer above run before/after the change against Paddle2.6.2 for 6 dtype/mode combinations, and a check that the float32 path is bit-identical to Paddle.