[PATCH] D76897: [mlir][Linalg] Extend fusion to support WAW atm on buffers.

Han-Chung Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 26 17:58:00 PDT 2020


hanchung created this revision.
hanchung added reviewers: mravishankar, nicolasvasilache, asaadaldien, pifon2a.
Herald added subscribers: llvm-commits, Joonsoo, liufengdb, aartbik, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.
hanchung updated this revision to Diff 253024.
hanchung added a comment.

Revert accidental change.


The RAW fusion happens only if the produecer block dominates the consumer block.
The WAW pattern also works with the precondition. I.e., if a producer can
dominate the consumer, they can fairly fuse together.

Since they are all tilable, we can think the pattern like this way:

Input:

  linalg_op1 view
  
  tile_loop
    subview_2
    linalg_op2 subview_2

Tile the first Linalg op as same as the second Linalg.

  tile_loop
    subview_1
    linalg_op1 subview_1
  
  tile_loop
    subview_2
    liangl_op2 subview_2

Since the first Linalg op is tilable in the same way and the computation are
independently, it's fair to fuse it with the second Linalg op.

  tile_loop
    subview_1
    linalg_op1 subview_1
    linalg_op2 subview_2

In short, this patch includes:

- Handling both RAW and WAW pattern.
- Adding a interface method to get input and output buffers.
- Exposing a method to get a StringRef of a dependency type.
- Fixing existing WAW tests and add one more use case: initialize the buffer before conv op.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76897

Files:
  mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h
  mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
  mlir/include/mlir/Dialect/Linalg/IR/LinalgTraits.h
  mlir/lib/Dialect/Linalg/Analysis/DependenceAnalysis.cpp
  mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
  mlir/test/Dialect/Linalg/fusion.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76897.253024.patch
Type: text/x-patch
Size: 12500 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200327/824b3b7d/attachment.bin>


More information about the llvm-commits mailing list