Skip to content

Keep QDQ nodes w/ nonpositive scale around MaxPool#21182

Merged
skottmckay merged 13 commits intomicrosoft:mainfrom
mcollinswisc:qdq_optim_nonpositive_scale
Jul 29, 2024
Merged

Keep QDQ nodes w/ nonpositive scale around MaxPool#21182
skottmckay merged 13 commits intomicrosoft:mainfrom
mcollinswisc:qdq_optim_nonpositive_scale

Conversation

@mcollinswisc
Copy link
Copy Markdown
Contributor

@mcollinswisc mcollinswisc commented Jun 26, 2024

Description

This change adds a check for whether the scale in the QuantizeLinear (or DequantizeLinear) is a positive scalar, and a new selector to disallow removing the QDQ around MaxPool if it is not.

Motivation and Context

Currently, the DropQDQNodesRules optimization removes QuantizeLinear and DequantizeLinear nodes from DequantizeLinear ∘ MaxPool ∘ QuantizeLinear. However, if the x_scale/y_scale values are non-positive, the (de-)quantization changes the ordering of the elements in the input value, so this optimization is changing the results.

#21176

Currently, the DropQDQNodesRules optimization removes QuantizeLinear and
DequantizeLinear nodes from DequantizeLinear∘MaxPool∘QuantizeLinear.
However, if the x_scale/y_scale values are non-positive, this changes
the ordering of the elements in the input value, so this optimization is
changing the results.

This change adds a check for whether the scale in the QuantizeLinear (or
DequantizeLinear) is a positive scalar, and a new selector to disallow
removing the QDQ around MaxPool if it is not.

microsoft#21176
@mcollinswisc
Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="TetraMem"

@mcollinswisc mcollinswisc force-pushed the qdq_optim_nonpositive_scale branch from a36db30 to 61c5d84 Compare June 26, 2024 18:24
@mcollinswisc
Copy link
Copy Markdown
Contributor Author

Also incorporating some name changes from scottmckay on stacked PR #21376 (comment) (thanks to both for review)

@mcollinswisc mcollinswisc requested a review from edgchen1 July 25, 2024 23:08
Comment thread onnxruntime/test/optimizer/qdq_transformer_test.cc Outdated
@edgchen1
Copy link
Copy Markdown
Contributor

/azp run Windows ARM64 QNN CI Pipeline,Windows x64 QNN CI Pipeline,Windows CPU CI Pipeline,Windows GPU CI Pipeline,Windows GPU TensorRT CI Pipeline,ONNX Runtime Web CI Pipeline,Linux CPU CI Pipeline,Linux CPU Minimal Build E2E CI Pipeline,Linux GPU CI Pipeline,Linux GPU TensorRT CI Pipeline

@edgchen1
Copy link
Copy Markdown
Contributor

/azp run Linux OpenVINO CI Pipeline,Linux QNN CI Pipeline,MacOS CI Pipeline,orttraining-amd-gpu-ci-pipeline,orttraining-linux-ci-pipeline,orttraining-linux-gpu-ci-pipeline,orttraining-ortmodule-distributed,onnxruntime-binary-size-checks-ci-pipeline,Big Models,Linux Android Emulator QNN CI Pipeline

@edgchen1
Copy link
Copy Markdown
Contributor

/azp run Android CI Pipeline,iOS CI Pipeline,ONNX Runtime React Native CI Pipeline

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 3 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 9 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 10 pipeline(s).

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