Repository navigation
[LinalgExt] Add argmax op with rountrip and invalid mlir test - #21021
Conversation
Signed-off-by: Bangtian Liu <[email protected]>
hanhanW
left a comment
There was a problem hiding this comment.
drive-by: to make this op work e2e, you'll need to implement tiling interface, generateScalarImplementation, and add interface registration like this.
The interface registration is a little annoying. IMO, it can be fixed, but I did not get cycles on this. How to make it work is documented in the issue: #20862
Signed-off-by: Bangtian Liu <[email protected]>
Signed-off-by: Bangtian Liu <[email protected]>
Signed-off-by: Bangtian Liu <[email protected]>
Yeah, just step by step send all the required PRs. |
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Sorry I wasnt able to review this PR before it landed, but I think it might be better to address comments here before moving forward.
| let arguments = (ins | ||
| Variadic<AnyShaped>:$inputs, | ||
| Variadic<AnyShaped>:$outputs, | ||
| I64Attr:$dimension |
There was a problem hiding this comment.
The intent of this operation is that this should be tilable. To make that correct I think we need a couple of mor things.
- I think defining an operation just for argmax is not scalable. I think we should define an operation that llows you to do "max" of any operation. So it might be better to add an operation that allows you to specify different functions to compute the "max".
Basically do
%0:2 = iree_linalg_ext.arg_compare ins(%0 : tensor<?x?xf32>) outs(...) dimension(...) {
^bb0(%b0 : f32, %b1: f32):
%1 = arith.cmpf ge, %b0, %b1 : f32
iree_linalg_ext.yield %1 : f32
} -> tensor<?xf32>
(Think how you would do this with something like C++ std lib which generally allows you to take a comparator function, this is essentially that).
- I think you also need an additional argument that represents the "global start index", that is by default 0. After tiling you will need to update the global start index appropriately.
There was a problem hiding this comment.
Yes, I actually considered both adding a region and supporting a global start index.
My initial plan was to start with a basic implementation to get the core functionality in place, and then extend it to support custom comparators via regions for more flexibility . Similarly, the global start index will be important for correctness when enabling split-K.
Thanks for the suggestions, I'll make sure to address both aspects in the follow-up PR.
There was a problem hiding this comment.
That would create too much churn no? It will be a pain to update all the tests after the fact etc. I think it would be better to just add this from the get go.
If we find out later that we missed something then there is nothing we can do, but we might as well start with accounting for things we already know?
There was a problem hiding this comment.
It will be a pain to update all the tests after the fact etc
Ok, then I will add all the required changes directly to the second PR #21077.
There was a problem hiding this comment.
Ok that's fine. Will be easier to stage it, i.e. fix the op and then the PR on top of that, but your call
There was a problem hiding this comment.
Ok that's fine. Will be easier to stage it, i.e. fix the op and then the PR on top of that, but your call
Sure, sounds good and I’ll follow your suggestion. I’ll first send a follow-up to address the argmax op fixes, then rebase and update the tiling PR accordingly. This should help keep the diffs cleaner and easier to review.
This is a follow-up PR to address feedback on the previously landed PR for the argmax op #21021 according to comments in #21021 (comment): - Adds support for a comparator region in the argmax op - Introduces an optional index_base operand to specify the starting index offset. --------- Signed-off-by: Bangtian Liu <[email protected]>
This PR introduces the `iree_linalg_ext.argmax` operation and defines its verifier along with corresponding roundtrip and invalid tests (`roundtrip.mlir` and `invalid.mlir`). Support for argmax will be added incrementally across multiple PRs: - Add the iree_linalg_ext.argmax op definition and verification logic, along with roundtrip and invalid IR tests (this PR) - Add tiling support - Add convert_to_loops lowering support - Add e2e support with other changes in compiler/Codegen/Interfaces (also split-k and ukernel) --------- Signed-off-by: Bangtian Liu <[email protected]>
This is a follow-up PR to address feedback on the previously landed PR for the argmax op #21021 according to comments in #21021 (comment): - Adds support for a comparator region in the argmax op - Introduces an optional index_base operand to specify the starting index offset. --------- Signed-off-by: Bangtian Liu <[email protected]>
This PR introduces the
iree_linalg_ext.argmaxoperation and defines its verifier along with corresponding roundtrip and invalid tests (roundtrip.mlirandinvalid.mlir).Support for argmax will be added incrementally across multiple PRs: