[mlir][linalg] Add control to pad-slice swap pattern
authorLei Zhang <antiagainst@google.com>
Wed, 16 Feb 2022 15:28:51 +0000 (10:28 -0500)
committerLei Zhang <antiagainst@google.com>
Wed, 16 Feb 2022 16:19:35 +0000 (11:19 -0500)
commit0edb4127730a27f06b73326fecd89870b2eb80d6
tree0a93e80dc5de95e2b32b5676925216e238ded745
parent27cd2a6284b8c59f5dbd9086cf80db3b7b7047b1
[mlir][linalg] Add control to pad-slice swap pattern

The pad-slice swap pattern generates `scf.if` and `tensor.generate`
to guard against zero-sized slices if it cannot prove the slice is
always non-zero. This is safe but quite conservative. It can be
unnecessary for cases where we know by problem definition such cases
does not exist, even if with dynamic shaped ops or unknown tile/slice
sizes, e.g., convolution padding size = 1 with kernel dim size = 3.

So this commit introduces a control to the pattern to specify
whether to generate the if constructs to handle such cases better,
given that once the if constructs is materialized, it's very hard
to analyze and simplify.

Reviewed By: mravishankar

Differential Revision: https://reviews.llvm.org/D117017
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/Dialect/Tensor/IR/TensorTilingInterfaceImpl.h
mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
utils/bazel/llvm-project-overlay/mlir/BUILD.bazel