Repository navigation
Split iree-dispatch-linalg-on-tensors-pass into two - #11313
Conversation
|
In the 2nd phase (iree-flow-form-workgroups-regions-pass), workload generation was a bit tricky. Right now, I first generates workload inside the One alternative could be to generate workloads in the first pass (iree-flow-form-dispatch-regions-pass). In this case, I should use these variables, otherwise, the optimizer removes them. So I can extend |
|
I think you're discovering why flow.dispatch ops require workloads: it's too brittle to try to split that up when forming them :) |
|
(it's also important that (nearly) any IR is able to be round-tripped and that programs can come in with flow IR that earlier stages may have produced - so anything that requires certain passes run in certain orders or that things like the canonicalizer aren't allowed on certain stages of IR is a no go) |
|
Mahesh and I discussed about splitting the pass into two, this PR is my first attempt. Great feedback, thanks, I think we can discuss from here how we want to pursue. I can add optional workload to 'dispatch.region'. I can find a reason why we need workload and 'dispatch.workgroups' in general. We run the workload region on host and we might run the other region on different device like gpu. But I don't understand why we need 'dispatch.region' 🤔 |
|
The region op was added as an un-distributed form of the workgroups op - the idea being that going from |
|
I have been thinking about how to reduce the handshake between the workgroup count region created at Flow and its lowering in codegen. Right now it is workable, but a bit wonky... Without going into details (cause doing this correctly will require moving the first level tile and distribute in Codegen to use |
a1ca0aa to
78fe041
Compare
|
Thanks for the feedback to everyone. I addressed your comments. Here are the changes:
Let's take this example: This is after 1st pass: This is after 2nd pass: |
78fe041 to
58ff262
Compare
58ff262 to
a32ed6a
Compare
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Awesome! Mostly looks ready to go to me. Have a few follow up comments. Thanks for taking this on!
a0f04ac to
73de5e0
Compare
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Very nice! Thanks a lot. Regarding clone/move I left a pointer if that helps.
Thanks once again for doing this!
Also now that these are different passes, maybe we can actually split the file as well and move relevant pieces to the right files. Totally for bonus points! :)
73de5e0 to
4b2403b
Compare
|
I split files too, let me know if you like the names of the passes and files -- bonus episodes are always fun :) |
benvanik
left a comment
There was a problem hiding this comment.
Looks great to me and a really nice cleanup/reorganization! Thanks for doing this!
MaheshRavishankar
left a comment
There was a problem hiding this comment.
Looks good! Thanks!
| namespace mlir { | ||
| class Operation; | ||
| /// A rewriter that keeps track of all tensor::DimOps. | ||
| class TensorDimTrackingRewriter : public IRRewriter { |
There was a problem hiding this comment.
Not needed to do with this PR, but you can land this in llvm-external-projects and use it from there. You are probably interested in upstreaming this?
| for (Region &r : op->getRegions()) | ||
| for (Block &b : r.getBlocks()) | ||
| for (Operation &op : b) | ||
| if (isa<OpTys...>(&op)) rootOps.push_back(&op); |
There was a problem hiding this comment.
Does Region::getOps() work for this case? That could help less nested loops. E.g.,
for (Region &r : op->getRegions()) {
for (auto &op: r->getOps()) {
if (isa<OpTys..
}
}
also, we have to wrap braces for this case.
`iree-flow-dispatch-linalg-on-tensors-pass` has become a large Pass: 1) generates `flow.dispatch.region`, 2) forms `flow.dispatch.workgroups` from these generated ones, 3) transforms Linalg Ops into flow Ops. This PR splits this pass into first step and further steps. It introduces two Passes to do this. **iree-flow-form-dispatch-regions-pass** : Runs heuristic to fuse Linalg Ops using tensors and generates `flow.dispatch.region` from them. It also generates workload information for each `dispatch.region`. **iree-flow-form-workgroups-regions-pass** : It traverses over `flow.dispatch.region` and generates `flow.dispatch.workgroups`. It also performs the remaining steps of `iree-flow-dispatch-linalg-on-tensors-pass`.
2b7e086 to
17203ff
Compare
|
@grypp feel free to land this and rebase your other PR on top of this. All reviewers have stamped it. |
iree-flow-dispatch-linalg-on-tensors-passhas become a large Pass: 1) generatesflow.dispatch.region, 2) formsflow.dispatch.workgroupsfrom these generated ones, 3) transforms Linalg Ops into flow Ops. This PR splits this pass into first step and further steps. It introduces two Passes to do this.iree-flow-form-dispatch-regions-pass : Runs heuristic to fuse Linalg Ops using tensors and generates
flow.dispatch.regionfrom them. It also generates workload information for eachdispatch.region.iree-flow-form-workgroups-regions-pass : It traverses over
flow.dispatch.regionand generatesflow.dispatch.workgroups. It also performs the remaining steps ofiree-flow-dispatch-linalg-on-tensors-pass.