[PATCH] D143747: [mlir][MemRef][Transform] Don't apply multibuffer on "useless" allocs

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 08:49:59 PST 2023


qcolombet created this revision.
qcolombet added reviewers: ftynse, thomas, kile, nicolasvasilache.
qcolombet added a project: MLIR.
Herald added subscribers: Moerafaat, bzcheeseman, sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, thopre.
Herald added a project: All.
qcolombet requested review of this revision.
Herald added a subscriber: stephenneuendorffer.

`alloc`s that have users outside of loops are guaranteed to fail in
`multibuffer`.

Instead of exposing ourselves to that failure in the transform dialect,
filter out the `alloc`s that fall in this category.

To be able to do this filtering we have to change the `multibuffer`
transform op from `TransformEachOpTrait` to a plain `TransformOp`. This is
because `TransformEachOpTrait` expects that every successful `applyToOne`
returns a non-empty result.

Couple of notes:

- I changed the assembly syntax to make sure we only get `alloc` ops as input. (And added a test case to make sure we reject invalid inputs.)
- `multibuffer` can still fail pretty easily when you know its limitations. See the updated `op failed to multibuffer` test case for instance. Longer term, instead of leaking/coupling the actual implementation (in this case the checks normally done in `memref::multiBuffer`) with the transform dialect (the added check in `::apply`), we may want to refactor how we structure the underlying implementation. E.g., we could imagine a `canApply` method for all the implementations that we want to hook up in the transform dialect. This has some implications on how not to duplicate work between `canApply` and the actual implementation but I thought I throw that here to have us think about it :).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143747

Files:
  mlir/include/mlir/Dialect/MemRef/TransformOps/MemRefTransformOps.td
  mlir/lib/Dialect/MemRef/TransformOps/MemRefTransformOps.cpp
  mlir/test/Dialect/MemRef/transform-ops.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143747.496498.patch
Type: text/x-patch
Size: 9855 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230210/5fffb4dc/attachment.bin>


More information about the llvm-commits mailing list