Repository navigation
Validate kernel_shape and output_padding lengths in DML kernel setup - #31999
Merged
Akshay Sonawane (apsonawane) merged 2 commits intoAug 13, 2026
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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_shapelength againstspatialDimensionCountbefore copying trailing spatial elements intoargs.windowSize. - Validate
filterTensorShapelength when inferringkernel_shapefrom the filter tensor, preventing invalidend() - spatialDimensionCountarithmetic. - Validate
output_paddinglength againstspatialDimensionCount(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.
Akshay Sonawane (apsonawane)
enabled auto-merge (squash)
August 12, 2026 04:00
Ti-Tai Wang (titaiwangms)
approved these changes
Aug 13, 2026
Akshay Sonawane (apsonawane)
deleted the
fix/dml-conv-kernel-attr-length
branch
August 13, 2026 17:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.