[PATCH] D73565: [mlir][Linalg] Introduce folding patterns to remove certain MemRefCastOp

Nicolas Vasilache via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 10:49:11 PST 2020


nicolasvasilache created this revision.
nicolasvasilache added reviewers: ftynse, aartbik, jsetoain, tetuante, asaadaldien.
Herald added subscribers: llvm-commits, liufengdb, lucyrfox, mgester, arpith-jacob, antiagainst, shauheen, burmako, jpienaar, rriddle, mehdi_amini.
Herald added a project: LLVM.

Canonicalization and folding patterns in StandardOps may interfere with the needs
of Linalg. This revision introduces specific foldings for dynamic memrefs that can
be proven to be static.

Very concretely:

Determines whether it is possible to fold it away in the parent Linalg op:

  mlir
    %1 = memref_cast %0 : memref<8x16xf32> to memref<?x?xf32>
    %2 = linalg.slice %1 ... : memref<?x?xf32> ...
    // or
    %1 = memref_cast %0 : memref<8x16xf32, affine_map<(i, j)->(16 * i + j)>>
           to memref<?x?xf32>
    linalg.generic(%1 ...) : memref<?x?xf32> ...

into

  mlir
    %2 = linalg.slice %0 ... : memref<8x16xf32> ...
    // or
    linalg.generic(%0 ... : memref<8x16xf32, affine_map<(i, j)->(16 * i + j)>>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73565

Files:
  mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td
  mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOps.td
  mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
  mlir/test/Dialect/Linalg/canonicalize.mlir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73565.240938.patch
Type: text/x-patch
Size: 10203 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200128/3118979c/attachment.bin>


More information about the llvm-commits mailing list