Skip to content

Validate kernel_shape and output_padding lengths in DML kernel setup - #31999

Merged
Akshay Sonawane (apsonawane) merged 2 commits into
mainfrom
fix/dml-conv-kernel-attr-length
Aug 13, 2026
Merged

Akshay Sonawane (apsonawane) merged 2 commits into
mainfrom
fix/dml-conv-kernel-attr-length

Conversation

@apsonawane

Copy link
Copy Markdown
Contributor

InitializeKernel copied the trailing spatialDimensionCount elements of kernel_shape and the leading spatialDimensionCount elements of output_padding without checking either vector was that long, so a shorter attribute made the iterator arithmetic run off the ends of the buffers. The output_padding check required only two elements, which is short for 3D. The adjacent strides, dilations and pads attributes already validate their lengths the same way; extend that to these two, and to the filter tensor shape used when kernel_shape is absent.

InitializeKernel copied the trailing spatialDimensionCount elements of
kernel_shape and the leading spatialDimensionCount elements of
output_padding without checking either vector was that long, so a shorter
attribute made the iterator arithmetic run off the ends of the buffers. The
output_padding check required only two elements, which is short for 3D. The
adjacent strides, dilations and pads attributes already validate their
lengths the same way; extend that to these two, and to the filter tensor
shape used when kernel_shape is absent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

This PR hardens the DML convolution kernel-argument initialization path by validating attribute vector lengths before slicing/copying, preventing out-of-bounds iterator arithmetic when ONNX attributes are shorter than the operator’s spatial rank.

Changes:

  • Validate kernel_shape length against spatialDimensionCount before copying trailing spatial elements into args.windowSize.
  • Validate filterTensorShape length when inferring kernel_shape from the filter tensor, preventing invalid end() - spatialDimensionCount arithmetic.
  • Validate output_padding length against spatialDimensionCount (instead of a hard-coded >= 2) before copying.

πŸ’‘ Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@apsonawane
Akshay Sonawane (apsonawane) merged commit 8ef1a88 into main Aug 13, 2026
111 of 116 checks passed
@apsonawane
Akshay Sonawane (apsonawane) deleted the fix/dml-conv-kernel-attr-length branch August 13, 2026 17:54
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