[mlir][Linalg] Add pattern to tile and fuse Linalg operations on buffers.
authorMaheshRavishankar <ravishankarm@google.com>
Wed, 30 Sep 2020 21:55:59 +0000 (14:55 -0700)
committerMaheshRavishankar <ravishankarm@google.com>
Wed, 30 Sep 2020 21:56:58 +0000 (14:56 -0700)
commitc694588fc52a8845174fee06ad0bcfa338e87816
tree3b26c5cd8dee8e92c4de3ca9ef96d291d0326656
parent8d250ac3cd48d0f17f9314685a85e77895c05351
[mlir][Linalg] Add pattern to tile and fuse Linalg operations on buffers.

The pattern is structured similar to other patterns like
LinalgTilingPattern. The fusion patterns takes options that allows you
to fuse with producers of multiple operands at once.
- The pattern fuses only at the level that is known to be legal, i.e
  if a reduction loop in the consumer is tiled, then fusion should
  happen "before" this loop. Some refactoring of the fusion code is
  needed to fuse only where it is legal.
- Since the fusion on buffers uses the LinalgDependenceGraph that is
  not mutable in place the fusion pattern keeps the original
  operations in the IR, but are tagged with a marker that can be later
  used to find the original operations.

This change also fixes an issue with tiling and
distribution/interchange where if the tile size of a loop were 0 it
wasnt account for in these.

Differential Revision: https://reviews.llvm.org/D88435
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/test/Dialect/Linalg/fusion-pattern.mlir [new file with mode: 0644]
mlir/test/lib/Transforms/CMakeLists.txt
mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp [new file with mode: 0644]
mlir/tools/mlir-opt/mlir-opt.cpp