Repository navigation
Add a pass to tile and vectorize workgroup tiles. - #3710
Conversation
a89f681 to
7025b23
Compare
| benefit) {} | ||
| LogicalResult matchAndRewrite(Operation *op, | ||
| PatternRewriter &rewriter) const override { | ||
| // Find the parent FuncOp before tiling. If tiling succeeds, the op will be |
There was a problem hiding this comment.
Comment seems off. The LinalgBaseTilingPattern doesnt erase the op (and you are erasing it here as you should). Also doesnt seem like you need funcOp at all.
| Identifier::get(getVectorizeMarker(), context))); | ||
|
|
||
| // Apply tiling. | ||
| applyPatternsAndFoldGreedily(funcOp, std::move(l1patterns)); |
There was a problem hiding this comment.
Not sure you need the move. The function expects a const &.
There was a problem hiding this comment.
This is needed, The API is update recently to use FrozenRewritePatternList
https://github.com/llvm/llvm-project/blob/master/mlir/include/mlir/Transforms/GreedyPatternRewriteDriver.h#L38
There was a problem hiding this comment.
Ok, I missed that. My issue with such code style is that if you unknowingly use l1Patterns later you will get weird behavior.
Two options
- Use FrozenRewritePatternList here and avoid using move.
- My preference is doing something like this
{
OwningRewritePatternList l1PatternList;
...
applyPatternsAndFoldGreedily(..., std::move(l1PatternList))
}
This way the list is out of scope when you move it.
| @@ -1,31 +1,35 @@ | |||
| // RUN: iree-opt --iree-codegen-linalg-to-llvm-matmul-vectorization-pass -split-input-file %s | IreeFileCheck %s | |||
| // RUN: iree-opt -iree-codegen-llvm-linalg-tile-and-distribute -iree-codegen-linalg-to-llvm-workgroups-vectorization-pass -split-input-file %s | IreeFileCheck %s | |||
There was a problem hiding this comment.
Nit: One of the reasons I dont like splitting the passes. Too many flags!
- Tile and distribute linalg.batch_matmul - Tile and vectorize linalg.matmul & linalg.batch_matmul - Remove MatMulVectorization - Add llvm flag driven kernel dispatch with default parameters getting lowest latency on mobile_bert benchmarks: ``` ------------------------------------------------------------------------------------ Benchmark Time CPU Iterations ------------------------------------------------------------------------------------ BM_serving_default/process_time/real_time 923 ms 918 ms ```
a923bb2 to
e32233a
Compare
| Identifier::get(getVectorizeMarker(), context))); | ||
|
|
||
| // Apply tiling. | ||
| applyPatternsAndFoldGreedily(funcOp, std::move(l1patterns)); |
There was a problem hiding this comment.
Ok, I missed that. My issue with such code style is that if you unknowingly use l1Patterns later you will get weird behavior.
Two options
- Use FrozenRewritePatternList here and avoid using move.
- My preference is doing something like this
{
OwningRewritePatternList l1PatternList;
...
applyPatternsAndFoldGreedily(..., std::move(l1PatternList))
}
This way the list is out of scope when you move it.
| linalg::LinalgMarker( | ||
| Identifier::get(getWorkgroupMarker(), context), | ||
| Identifier::get(getWorkgroupL1TileMarker(), context))); | ||
|
|
There was a problem hiding this comment.
Nit: based on previous comment. Split the scope here. l2patterns not used before here.
lowest latency on mobile_bert benchmarks: