From d3ba5701b97928549bc717124931e1e0e0f703b0 Mon Sep 17 00:00:00 2001 From: Chi Lo Date: Wed, 1 Jul 2026 13:42:01 -0700 Subject: [PATCH] Fix copy-paste typos in DynamicQuantizeLSTM zero-point and scale validation 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> --- .../contrib_ops/cpu/quantization/dynamic_quantize_lstm.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnxruntime/contrib_ops/cpu/quantization/dynamic_quantize_lstm.cc b/onnxruntime/contrib_ops/cpu/quantization/dynamic_quantize_lstm.cc index 2094af78f40b7..ba3c8a2ada30b 100644 --- a/onnxruntime/contrib_ops/cpu/quantization/dynamic_quantize_lstm.cc +++ b/onnxruntime/contrib_ops/cpu/quantization/dynamic_quantize_lstm.cc @@ -178,14 +178,14 @@ Status DynamicQuantizeLSTM::Compute(OpKernelContext* context) const { const Tensor* r_zp = context->Input(11); const TensorShape& W_zp_shape = w_zp->Shape(); - const TensorShape& R_zp_shape = w_zp->Shape(); + const TensorShape& R_zp_shape = r_zp->Shape(); const TensorShape& W_scale_shape = w_scale->Shape(); const TensorShape& R_scale_shape = r_scale->Shape(); 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); const bool is_W_signed = (W != nullptr) ? W->IsDataType() : is_W_signed_; const bool is_R_signed = (R != nullptr) ? R->IsDataType() : is_R_signed_;