Skip to content

[Codegen] Migrate PadOp/PackOp/UnPackOp to VectorizableOpInterface#23712

Merged
hanhanW merged 1 commit intomainfrom
users/hanhanW/vec-iface-c3a
Mar 12, 2026
Merged

[Codegen] Migrate PadOp/PackOp/UnPackOp to VectorizableOpInterface#23712
hanhanW merged 1 commit intomainfrom
users/hanhanW/vec-iface-c3a

Conversation

@hanhanW
Copy link
Contributor

@hanhanW hanhanW commented Mar 9, 2026

No new tests because it is an NFC in terms of functionality. It just follows different mechanism for vectorization.

It is a step towards https://lists.lfaidata.foundation/g/iree-technical-discussion/message/15

Assisted-by: Claude

@hanhanW hanhanW marked this pull request as ready for review March 9, 2026 20:04

/// External model for tensor::PadOp. Different dialect, goes through
/// linalg::vectorize.
struct PadOpVectorizationModel
Copy link
Contributor

Choose a reason for hiding this comment

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

The two external models look almost identical to me. Can't we use the templated version from above for PadOp as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is intended because they are from different dialect. IMHO, the some upstream linalg ops are not completed because they don't implement LinalgOp interface. There may be extentions for such ops, while tensor.pad is a very special case in vectorization.

Copy link
Contributor

Choose a reason for hiding this comment

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

But the dialect isn't part of the template, right? IMHO, we shouldn't duplicate code (DRY). If there is an extension of the upstream linalg ops in the future, we can always make a change here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you're over-abstracting the things. The duplication is okay to me if they are small. I've seen so many times about split -> merge -> split ->etc, and my thought is that if we already know it, we should do the split. It is clear to me that they have very different development attention, and the pack/unpack ops evolve much faster than pad op. Thus, splitting them in the first place is reasonable to me.

We also have good reasoning here, but not just "different dialect". As I mentioned, they should implement LinalgOp interface IMO. The other different thing is that tensor.pad op does not implement DPS interface, which can fall into different category easily. It is not happening now, but I'd like to make the isolation in the first place as I can see many difference between them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, if you expect a split is likely to happen because of the evolution of pack/unpack, we can keep it as is.

@hanhanW hanhanW force-pushed the users/hanhanW/vec-iface-c2c branch from 37cef0e to 5aa5b62 Compare March 10, 2026 17:46
@hanhanW hanhanW force-pushed the users/hanhanW/vec-iface-c3a branch from ba02055 to dcccae8 Compare March 10, 2026 17:46

/// External model for tensor::PadOp. Different dialect, goes through
/// linalg::vectorize.
struct PadOpVectorizationModel
Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, if you expect a split is likely to happen because of the evolution of pack/unpack, we can keep it as is.

@hanhanW hanhanW force-pushed the users/hanhanW/vec-iface-c2c branch from 5aa5b62 to a84722f Compare March 10, 2026 22:56
@hanhanW hanhanW force-pushed the users/hanhanW/vec-iface-c3a branch from dcccae8 to c8f23d0 Compare March 10, 2026 23:07
Base automatically changed from users/hanhanW/vec-iface-c2c to main March 11, 2026 01:11
Add external models for upstream linalg/tensor ops:
- NonLinalgStructuredOpVectorizationModel for PackOp, UnPackOp
- PadOpVectorizationModel for tensor::PadOp

Signed-off-by: hanhanW <[email protected]>
@hanhanW hanhanW force-pushed the users/hanhanW/vec-iface-c3a branch from c8f23d0 to 54492ef Compare March 11, 2026 01:16
@hanhanW hanhanW merged commit 246487b into main Mar 12, 2026
61 checks passed
@hanhanW hanhanW deleted the users/hanhanW/vec-iface-c3a branch March 12, 2026 16:20
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