Skip to content

[WebNN] Fix bug in quantizeLinear and dequantizeLinear - #25931

Merged
fdwr merged 3 commits into
microsoft:mainfrom
Honry:fix-qdq
Sep 11, 2025
Merged

[WebNN] Fix bug in quantizeLinear and dequantizeLinear#25931
fdwr merged 3 commits into
microsoft:mainfrom
Honry:fix-qdq

Conversation

@Honry

@Honry Honry commented Sep 3, 2025

Copy link
Copy Markdown
Contributor

Description

In latest WebNN spec, it requires the scale and zeroPoint rank to be same as the input rank for quantizeLinear and dequantizeLinear operators.

Motivation and Context

This PR adjusts the shape of scale and zeroPoint by appending or prepending 1s to their dimensions if they are not equal to the input rank to align with the latest spec.
BTW, this PR also fixes some nits and makes some code improvement.

@Honry

Honry commented Sep 3, 2025

Copy link
Copy Markdown
Contributor Author

@fdwr, @guschmue, PTAL, thanks!

In latest WebNN spec, it requires the scale and zeroPoint rank to
be same as the input rank for dequantizeLinear and dequantizeLinear
operators.

This PR adjusts the shape of scale and zeroPoint by appending or prepending
1s to their dimensions if they are not equal to the input rank.

BTW, this PR also fixes some nits and makes some code improvement.
Comment thread onnxruntime/core/providers/webnn/builders/impl/qdq_op_builder.cc
fdwr
fdwr previously approved these changes Sep 3, 2025

@fdwr fdwr 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.

👍

Comment thread onnxruntime/core/providers/webnn/builders/impl/gemm_op_builder.cc Outdated
Comment thread onnxruntime/core/providers/webnn/builders/impl/gemm_op_builder.cc Outdated
@Honry Honry changed the title [WebNN] Fix bug in dequantizeLinear and dequantizeLinear [WebNN] Fix bug in quantizeLinear and dequantizeLinear Sep 4, 2025
fdwr
fdwr previously approved these changes Sep 5, 2025

@fdwr fdwr 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.

Small requests else LGTM.

Comment thread onnxruntime/core/providers/webnn/builders/impl/gemm_op_builder.cc Outdated
Comment thread onnxruntime/core/providers/webnn/builders/impl/gemm_op_builder.cc Outdated

@fdwr fdwr 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.

👍

@fdwr

fdwr commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

/azp run ONNX Runtime Web CI Pipeline,Windows GPU CI Pipeline,Linux Android Emulator QNN CI Pipeline,Windows GPU WebGPU CI Pipeline,Windows OpenVINO CI Pipeline

@fdwr

fdwr commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

/azp run Linux CPU CI Pipeline,Linux CPU Minimal Build E2E CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline,Linux OpenVINO CI Pipeline,Linux QNN CI Pipeline,MacOS CI Pipeline,Windows ARM64 QNN CI Pipeline,Windows CPU CI Pipeline

@fdwr

fdwr commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

/azp run Windows GPU CUDA CI Pipeline,Windows GPU DML CI Pipeline,Windows GPU Doc Gen CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI

@fdwr

fdwr commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

/azp run Windows GPU TensorRT CI Pipeline,onnxruntime-binary-size-checks-ci-pipeline,orttraining-linux-ci-pipeline,orttraining-linux-gpu-ci-pipeline,orttraining-ortmodule-distributed,Windows x64 QNN CI Pipeline,Big Models

@fdwr

fdwr commented Sep 5, 2025

Copy link
Copy Markdown
Contributor

/azp run Test Linux CUDA x64 Release,Test Linux TensorRT x64 Release,web_Debug / build_onnxruntime_web,web_Release / build_onnxruntime_web

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@fdwr
fdwr merged commit 99ae86b into microsoft:main Sep 11, 2025
87 checks passed
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.

2 participants