Skip to content

Fix copy-paste typos in DynamicQuantizeLSTM zero-point and scale validation#29462

Merged
tianleiwu merged 1 commit into
mainfrom
chilo-ms/dqlstm-zp-scale-shape-typo
Jul 2, 2026
Merged

Fix copy-paste typos in DynamicQuantizeLSTM zero-point and scale validation#29462
tianleiwu merged 1 commit into
mainfrom
chilo-ms/dqlstm-zp-scale-shape-typo

Conversation

@chilo-ms

@chilo-ms chilo-ms commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

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

…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 tianleiwu requested a review from Copilot July 2, 2026 23:51
@tianleiwu tianleiwu merged commit 99ba5db into main Jul 2, 2026
87 checks passed
@tianleiwu tianleiwu deleted the chilo-ms/dqlstm-zp-scale-shape-typo branch July 2, 2026 23:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 of w_zp->Shape()) when validating R_zero_point.
  • Validate R_scale against R_scale_shape (instead of W_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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants