[mlir][tensor] Merge consecutive insert_slice/extract_slice ops
authorLei Zhang <antiagainst@google.com>
Tue, 20 Sep 2022 23:52:19 +0000 (19:52 -0400)
committerLei Zhang <antiagainst@google.com>
Tue, 20 Sep 2022 23:52:56 +0000 (19:52 -0400)
commitbb4c53b7ba113b274ad0fd8d881313509947c896
tree15736d8d7d937b5a3ca15e145f624706e85f5126
parent42bcb35c0f2946b66ae397515823a3792f14b067
[mlir][tensor] Merge consecutive insert_slice/extract_slice ops

Consecutive tensor.insert_slice/tensor.extract_slice can be
created for the case like tiling convolution and then downsizing
2-D convolutions into 1-D ones. It hinders further transformations.
So adding these patterns to clean it up.

Given that bufferization is sensitive and have requirements over
the IR structure (see https://reviews.llvm.org/D132666),
these patterns are put in Transforms/ with separate entry points
for explicit collection.

Reviewed By: ThomasRaoux, mravishankar

Differential Revision: https://reviews.llvm.org/D133871
mlir/include/mlir/Dialect/Tensor/Transforms/Transforms.h
mlir/lib/Dialect/Tensor/Transforms/CMakeLists.txt
mlir/lib/Dialect/Tensor/Transforms/MergeConsecutiveInsertExtractSlicePatterns.cpp [new file with mode: 0644]
mlir/test/Dialect/Tensor/fold-consecutive-insert-extract-slice.mlir [new file with mode: 0644]
mlir/test/lib/Dialect/Tensor/TestTensorTransforms.cpp