Fix copy-paste typos in DynamicQuantizeLSTM zero-point and scale validation#29462
Merged
Conversation
…dation Two copy-paste typos in DynamicQuantizeLSTM::Compute cause the recurrence- weight zero-point and scale to be validated against the wrong tensor's shape: 1. L181: R_zp_shape = w_zp->Shape() should be r_zp->Shape(). ZeroPointCheck then iterates w_zp's element count over the smaller r_zp tensor, reading past it. 2. L188: WeightCheck(W_scale_shape, R_scale) should use R_scale_shape. The recurrence scale shape is validated against the input scale shape instead of its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
tianleiwu
approved these changes
Jul 2, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes two copy/paste validation bugs in the DynamicQuantizeLSTM contrib CPU kernel that caused the recurrent (R_*) quantization parameters to be checked against the wrong tensor shapes, including a potential out-of-bounds read when R_zero_point is smaller than W_zero_point.
Changes:
- Use
r_zp->Shape()(instead ofw_zp->Shape()) when validatingR_zero_point. - Validate
R_scaleagainstR_scale_shape(instead ofW_scale_shape).
Comment on lines
185
to
+188
| WeightCheck(W_zp_shape, W_zero_point); | ||
| WeightCheck(R_zp_shape, R_zero_point); | ||
| WeightCheck(W_scale_shape, W_scale); | ||
| WeightCheck(W_scale_shape, R_scale); | ||
| WeightCheck(R_scale_shape, R_scale); |
feich-ms
pushed a commit
that referenced
this pull request
Jul 3, 2026
…dation (#29462) ### Description Two copy-paste typos in DynamicQuantizeLSTM::Compute ( dynamic_quantize_lstm.cc ) cause the recurrence-weight zero-point and scale to be validated against the wrong tensor's shape: 1. L181: R_zp_shape = w_zp->Shape() → r_zp->Shape() . ZeroPointCheck then iterates w_zp 's element count over the smaller r_zp tensor, reading past it (OOB read). 2. L188: WeightCheck(W_scale_shape, R_scale) → WeightCheck(R_scale_shape, R_scale) . The recurrence scale shape is validated against the input scale shape instead of its own. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Description
Two copy-paste typos in DynamicQuantizeLSTM::Compute ( dynamic_quantize_lstm.cc ) cause the recurrence-weight zero-point and scale to be validated against the wrong tensor's shape:
Motivation and Context