Repository navigation
[LinalgExt][NFC] Split the op definition between pure ops and LinalgExt ops - #22368
Conversation
hanhanW
left a comment
There was a problem hiding this comment.
Thanks for the patch!
I think MapScatterOp and attention ops should belong to LinalgExtOps.td. (I don't know why they dont inherit LinalgExtOp for now, but it is a separate issue.)
My mental model is that we structure it like linalg ops. There are pure ops and structure ops (that I call compute ops in IREE). The MapScatterOp and attention ops describe the computation, so they belong to LinalgExtOps.td.
|
|
||
| class IREELinalgExt_Op<string mnemonic, list<Trait> traits = []> : | ||
| IREELinalgExt_PureOp<mnemonic, !listconcat(traits, | ||
| Op<IREELinalgExt_Dialect, mnemonic, !listconcat(traits, |
There was a problem hiding this comment.
Can't this file include LinalgExtPureOps.td?
There was a problem hiding this comment.
If this file directly includes LinalgExtPureOps.td, it redefines pureOps, which causes an error.
It is better to move the base class to LinalgExtBase.td and include it from there.
77d6141 to
baf3a79
Compare
baf3a79 to
a1fc2bf
Compare
hanhanW
left a comment
There was a problem hiding this comment.
overall looks good, I think we miss few removal; I think we can drop the comments for three ops.
| // map_scatter op does not have enough operands to use AttrSizedOperandSegments trait | ||
| // so we inherit from IREELinalgExt_PureOp for now. |
There was a problem hiding this comment.
The comment is not accurate to me. The reason of using AttrSizedOperandSegments for an op if it has at least two variadic operands. I think you can drop the comments for this case and other cases. I'll do a cleanup for this in a follow-up. Thanks.
| IREE::LinalgExt::AttentionOp::attachInterface< | ||
| LinalgExtOpInterface<IREE::LinalgExt::AttentionOp>>(*ctx); | ||
| IREE::LinalgExt::MapScatterOp::attachInterface< | ||
| LinalgExtOpInterface<IREE::LinalgExt::MapScatterOp>>(*ctx); |
There was a problem hiding this comment.
We no longer need them, right? Because they should be registered with the above include.
| IREE::LinalgExt::AttentionOp::attachInterface< | ||
| LinalgOpTiedOpInterface<IREE::LinalgExt::AttentionOp>>(*context); |
a1fc2bf to
ad99b91
Compare
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Hanhan approved it, but missing context as to why we need this? Its a bit of an artificial split. I have no strong opinions, but curious why we did this to start with (especially since we only moved a single op into a different file).
The main reason is described here: #20862 (comment) It will allow us to have less burden when adding a new LinalgExt op. The interface registration (e.g., memory side effect, bufferization, etc) will be done automatically, so we no longer need commit like dce563a |
|
@sakupan102 can you fix the bazel and update PR description? https://google.github.io/eng-practices/review/developer/cl-descriptions.html has the guidance about what a good PR title and description can be. |
IIRC it's because most of linalg ext ops are trying to act like linalg.generic syntax with ins()/outs() which the interface requires. Attention/MapScatter have a fixed number of arguements and don't need that. Most ops in linalg_ext don't need variadic arguements and but we never changed it. |
|
LGTM, we need to revamp LinalgExtInterface to not have variadic arguements in future though, most ops don't need it in linalg_ext |
Closes iree-org#20862 Signed-off-by: Ryutaro Okada <[email protected]>
…d `.inc.h` or `.inc.cpp` files Closes iree-org#20862 Signed-off-by: Ryutaro Okada <[email protected]>
ad99b91 to
d9d0ff4
Compare
This is what I'm going to do in a follow-up. Ops should add the interface when they need to; it should not belong to the LinalgExtOps traits today. (It's mostly legacy.) |
Yeah my bad! It wrote that at a time when I didn't know better |
…xt ops (iree-org#22368) Split LinalgExtOp into PureOp and LinalgExtOp. This enables automatically attaching the right interfaces by simply including the generated .cpp.inc files, preventing missed interface attachments. Closes iree-org#20862 --------- Signed-off-by: Ryutaro Okada <[email protected]>
…xt ops (iree-org#22368) Split LinalgExtOp into PureOp and LinalgExtOp. This enables automatically attaching the right interfaces by simply including the generated .cpp.inc files, preventing missed interface attachments. Closes iree-org#20862 --------- Signed-off-by: Ryutaro Okada <[email protected]>
…xt ops (iree-org#22368) Split LinalgExtOp into PureOp and LinalgExtOp. This enables automatically attaching the right interfaces by simply including the generated .cpp.inc files, preventing missed interface attachments. Closes iree-org#20862 --------- Signed-off-by: Ryutaro Okada <[email protected]>
Split LinalgExtOp into PureOp and LinalgExtOp. This enables automatically attaching the right interfaces by simply including the generated .cpp.inc files, preventing missed interface attachments.
Closes #20862