Skip to content

Add a pass to tile and vectorize workgroup tiles. - #3710

Merged
asaadaldien merged 5 commits into
mainfrom
ataei-refactor_vectorization_pass
Nov 6, 2020
Merged

asaadaldien merged 5 commits into
mainfrom
ataei-refactor_vectorization_pass

Conversation

@asaadaldien

Copy link
Copy Markdown
Contributor
  • Tile and distribute linalg.batch_matmul.
  • Tile and vectorize linalg.matmul and linalg.batch_matmul.
  • Remove MatMulVectorization,
  • Enable Distribute + Tile + Vectorize passes by default.
  • 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

@google-cla google-cla Bot added the cla: yes label Nov 4, 2020
@asaadaldien
asaadaldien force-pushed the ataei-refactor_vectorization_pass branch 2 times, most recently from a89f681 to 7025b23 Compare November 5, 2020 00:14
benefit) {}
LogicalResult matchAndRewrite(Operation *op,
PatternRewriter &rewriter) const override {
// Find the parent FuncOp before tiling. If tiling succeeds, the op will be

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

Identifier::get(getVectorizeMarker(), context)));

// Apply tiling.
applyPatternsAndFoldGreedily(funcOp, std::move(l1patterns));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure you need the move. The function expects a const &.

@asaadaldien asaadaldien Nov 5, 2020 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

  1. Use FrozenRewritePatternList here and avoid using move.
  2. 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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done!

@@ -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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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
```
@asaadaldien
asaadaldien force-pushed the ataei-refactor_vectorization_pass branch from a923bb2 to e32233a Compare November 5, 2020 23:16
Identifier::get(getVectorizeMarker(), context)));

// Apply tiling.
applyPatternsAndFoldGreedily(funcOp, std::move(l1patterns));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

  1. Use FrozenRewritePatternList here and avoid using move.
  2. 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)));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nit: based on previous comment. Split the scope here. l2patterns not used before here.

@asaadaldien
asaadaldien merged commit 559e7b4 into main Nov 6, 2020
@asaadaldien
asaadaldien deleted the ataei-refactor_vectorization_pass branch November 6, 2020 00:56
This was referenced Nov 6, 2020
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.

2 participants