Original implementation from @harsh
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/test/Dialect/Linalg/tile-softmax.mlir | ||
---|---|---|
25 | The semantics of this is to take the max of each tile, which is not always the same as the softmax of the original dimension. If the tile is a whole head, this may be what you want. If not, you'll get different results. I'm not sure how to restrict this in a meaningful way, or perhaps this is up to the compiler to "do the right thing". At the very least, this should be documented somewhere, perhaps in the op description? | |
40 | I'm assuming this also works with the tile-and-fuse pass. Could there be a test for that, too? |
mlir/test/Dialect/Linalg/tile-softmax.mlir | ||
---|---|---|
25 | Good point. @ftynse, @nicolasvasilache do you have a recommendation on what we should do here? Technically getTiledImplementation can return a failure, but I don't know if that's doable/desirable to do that check here. | |
40 | Let me give a try! |
mlir/test/Dialect/Linalg/tile-softmax.mlir | ||
---|---|---|
25 | Spoke with @nicolasvasilache offline and the conclusion was the compiler has to do the right thing. |
Should be fine with just transform tests for now. Once we incorporate on existing infra we'll see how it plays with passes.
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | ||
---|---|---|
53 | This is the deprecated form https://mlir.llvm.org/deprecation/ | |
2239 | s/mlir::// |
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | ||
---|---|---|
53 | Thanks I didn't know about that. |
- Add a tile and fuse test
- Remove deprecated use of cast
- Fix the way we generate the dimension (value vs. attribute)
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | ||
---|---|---|
55 | FYI, the "fix" I mentioned in my previous update is here. We use an attribute instead of a value here and that allows the fusing to work properly. I'll highlight what was broken without that. | |
65 | @springerm Do you know if such utility function already exists somewhere? | |
2239 | I had to keep that otherwise clang grab the clone from Operation:: which doesn't take any argument. | |
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp | ||
531 | This change is not technically required for this PR, but when I "screwed up" my tiling by returning a value instead of an attribute, this led to slice ops with dynamic dimensions and these were breaking ExtractSliceOp::rankReduceIfNeeded. By changing this assert into a note, this makes the compiler more robust in case someone does the same mistake as I did. I.e., it will not fuse instead of crashing the compiler. | |
mlir/test/Dialect/Linalg/tile-softmax.mlir | ||
40 | @rengolin I added a test for tile and fuse and it exposed a weakness in the fuse algorithm, which I fixed here as well (it was asserting.) |
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | ||
---|---|---|
20 | This introduces a cycle between LinalgUtils and Linalg. Is this intended? |
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | ||
---|---|---|
20 | Ah good catch, I forgot to remove that line. Let me fix that. |
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp | ||
---|---|---|
20 | Fixed at cf244b55c3d2 |
This introduces a cycle between LinalgUtils and Linalg. Is this intended?