[LinalgExt] Add padding attributes to im2col op#23950
Open
Conversation
Add optional padding fields to the im2col op: - input_pad_low/high: per-input-dimension padding amounts - output_pad_low/high: per-output-dimension padding amounts - pad_value: the value for out-of-bounds positions This includes: - Op definition with custom printer/parser for optional padding - Padding accessors, setters, and verifier checks - Output padding propagation in the tiling interface - Decomposition bail-out for padded im2col ops (full padding support via direct vectorization comes in a follow-up) - Roundtrip, verifier, and tiling tests Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Max Dawkins <max.dawkins@gmail.com>
d2a2c6a to
8566950
Compare
hanhanW
approved these changes
Mar 27, 2026
Comment on lines
+2459
to
+2468
| void Im2colOp::build( | ||
| OpBuilder &builder, OperationState &state, Value input, Value output, | ||
| ArrayRef<int64_t> strides, ArrayRef<int64_t> dilations, | ||
| ArrayRef<OpFoldResult> kernelSize, ArrayRef<OpFoldResult> offsets, | ||
| ArrayRef<SmallVector<OpFoldResult>> outputSizes, ArrayRef<int64_t> batchPos, | ||
| ArrayRef<int64_t> mPos, ArrayRef<int64_t> kPos, | ||
| ArrayRef<int64_t> inputKPerm, ArrayRef<int64_t> outputPerm, | ||
| ArrayRef<OpFoldResult> inputPadLow, ArrayRef<OpFoldResult> inputPadHigh, | ||
| ArrayRef<OpFoldResult> outputPadLow, ArrayRef<OpFoldResult> outputPadHigh, | ||
| Value padValue) { |
Contributor
Author
There was a problem hiding this comment.
And this is after I've already consolidated some of the fields in a recent PR :p
yzhang93
approved these changes
Mar 27, 2026
Contributor
yzhang93
left a comment
There was a problem hiding this comment.
LGTM! Just minor comments.
| // ----- | ||
|
|
||
| // Verify output_pad_low/output_pad_high roundtrip with input padding. | ||
| func.func @im2col_output_padding(%arg0: tensor<2x34x34x640xf32>) -> tensor<2x1040x5760xf32> { |
Contributor
There was a problem hiding this comment.
Nit: These test names are not accurate. The first one should be im2col_input_padding, and the second should be im2col_input_output_padding
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.
Add optional padding fields to the im2col op:
This includes:
This change is effectively non-functional, since we do not yet make use of the padding attributes. The follow-up PR will introduce canonicalizers that fold padding into im2col, which will enable the padding path.