Skip to content

Fix new-delete mismatch in DML EP's QuantizeLinear operator#27823

Merged
adrastogi merged 6 commits intomainfrom
adrastogi/dml-new-delete
Mar 30, 2026
Merged

Fix new-delete mismatch in DML EP's QuantizeLinear operator#27823
adrastogi merged 6 commits intomainfrom
adrastogi/dml-new-delete

Conversation

@adrastogi
Copy link
Copy Markdown
Contributor

Description

DmlOperatorQuantization21 was missing the tensor reshaping logic that the older DmlOperatorElementwiseQLinear already had.

Scalar scale tensors get padded to 4D, but a 5D input stays 5D. DML rejects the dimension mismatch with E_INVALIDARG, and the resulting exception unwind triggers a sized-delete bug in WRL's MakeAllocator which address sanitizer detects. The fix is to port the same logic from the DmlOperatorElementwiseQLinear into this path, so that the dimensions match.

Motivation and Context

This is required to ensure the DML EP correctly handles this scenario.

@adrastogi adrastogi requested review from RafaelCintron and fdwr March 24, 2026 04:07
@fdwr
Copy link
Copy Markdown
Contributor

fdwr commented Mar 24, 2026

exception unwind triggers a sized-delete bug in WRL's MakeAllocator

Is this fix hiding any remaining allocation issue which a different E_INVALIDARG might cause?

fdwr
fdwr previously approved these changes Mar 24, 2026
Copy link
Copy Markdown
Contributor

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

Glad you found it. 🔍 Approved with some recommendations.

fdwr
fdwr previously approved these changes Mar 24, 2026
Copy link
Copy Markdown
Contributor

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

✌️

fdwr
fdwr previously approved these changes Mar 26, 2026
Copy link
Copy Markdown
Contributor

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

Change looks okay to me (assuming the initial ref count is 1 rather than 0), but I wonder if this location is sufficient (other places use MakeOrThrow), and whether this is actually an issue because the heap block size is stored in the heap itself, meaning a sized delete mismatch seems bad in theory but not in practice (operator delete just calls free which reads the heap block header to read the block size - the same value that _msize function returns).

adrastogi and others added 2 commits March 27, 2026 08:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fdwr
fdwr previously approved these changes Mar 27, 2026
Copy link
Copy Markdown
Contributor

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

👍

@fdwr
Copy link
Copy Markdown
Contributor

fdwr commented Mar 28, 2026

/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
Copy link
Copy Markdown
Contributor

fdwr commented Mar 28, 2026

/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,MacOS CI Pipeline,Windows CPU CI Pipeline

@fdwr
Copy link
Copy Markdown
Contributor

fdwr commented Mar 28, 2026

/azp run Windows GPU CUDA CI Pipeline,Windows GPU DML CI Pipeline

@fdwr
Copy link
Copy Markdown
Contributor

fdwr commented Mar 28, 2026

/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

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

@fdwr
Copy link
Copy Markdown
Contributor

fdwr commented Mar 28, 2026

/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

No pipelines are associated with this pull request.

@fdwr
Copy link
Copy Markdown
Contributor

fdwr commented Mar 28, 2026

/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows GPU Doc Gen CI Pipeline,Windows ARM64 QNN CI Pipeline

@azure-pipelines
Copy link
Copy Markdown

No pipelines are associated with this pull request.

1 similar comment
@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 4 pipeline(s).

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

You can commit the suggested changes from lintrunner.

Copy link
Copy Markdown
Contributor

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

👍

@adrastogi adrastogi merged commit c884195 into main Mar 30, 2026
103 of 105 checks passed
@adrastogi adrastogi deleted the adrastogi/dml-new-delete branch March 30, 2026 00:29
adrastogi added a commit that referenced this pull request Mar 30, 2026
### Description
<!-- Describe your changes. -->
DmlOperatorQuantization21 was missing the tensor reshaping logic that
the older DmlOperatorElementwiseQLinear already had.

Scalar scale tensors get padded to 4D, but a 5D input stays 5D. DML
rejects the dimension mismatch with E_INVALIDARG, and the resulting
exception unwind triggers a sized-delete bug in WRL's MakeAllocator
which address sanitizer detects. The fix is to port the same logic from
the DmlOperatorElementwiseQLinear into this path, so that the dimensions
match.

### 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. -->
This is required to ensure the DML EP correctly handles this scenario.

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
adrastogi added a commit that referenced this pull request Mar 31, 2026
This cherry-picks the following commits for the release:

- #26434 [VitisAI]add tensor type bool
- #26452 [VitisAI EP] Fix error in graph resolving
- #26487 [VitisAI] Enable ort::logger usage in
compile_onnx_model_vitisai_ep_v4
- #26519 [VitisAI] Remove unused function body handling in graph fusion
- #26627 [VitisAI] Add External EP Loader
- #26699 [VitisAI] Add support compiled model compatibility information
retrieval and validation
- #27295 Remove s_kernel_registry_vitisaiep.reset() in
deinitialize_vitisai_ep()
- #27356 Add/Update telemetry events
- #27626 Add PE version info to onnxruntime_providers_vitisai.dll
- #27693 Fix integer division by zero crash in CPU EP Div operator
- #27815 Fix overflow in DmlGraphFusionHelper::ProcessInputData
- #27823 Fix new-delete mismatch in DML EP's QuantizeLinear operator

---------

Co-authored-by: Yueqing Zhang <yuz75@Pitt.edu>
Co-authored-by: Yueqing Zhang <yueqingz@amd.com>
Co-authored-by: zpye <yezupei92@foxmail.com>
Co-authored-by: Chunye Wang@AMD <chunywan@amd.com>
Co-authored-by: mingyue <131847423+mingyueliuh@users.noreply.github.com>
Co-authored-by: zz002 <zhenzew@amd.com>
Co-authored-by: Darshak Bhatti <47045043+dabhattimsft@users.noreply.github.com>
Co-authored-by: Darshak Bhatti <dabhatti@micorsoft.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Xiaoxi Han <xiha@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Co-authored-by: skottmckay <979079+skottmckay@users.noreply.github.com>
Co-authored-by: Tianlei Wu <tlwu@microsoft.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