[mlir][LinAlg][Transform] Add a transform op for conv2d to im2col
authorQuentin Colombet <quentin.colombet@gmail.com>
Thu, 23 Feb 2023 22:26:15 +0000 (22:26 +0000)
committerThomas Raoux <thomasraoux@google.com>
Thu, 23 Feb 2023 22:27:16 +0000 (22:27 +0000)
commit17b2e73cb477d42771fbc68a215dde648f3eaaef
tree486fa92d1182ce1cf0593717df6aaae394494063
parentdb288184765c0b4010060ebea1f6de3ac1f66445
[mlir][LinAlg][Transform] Add a transform op for conv2d to im2col

This patch adds patterns to convert `linalg.conv_2d_xxx` operations
into `linalg.generic` (for img2col packing) and `linalg.matmul`.

The meat of the patch comes straight from IREE
(https://github.com/iree-org/iree).
(To the original authors are you okay with that?)

What this patch adds is proper plumbing of the im2col patterns into the
transform dialect.

PS: Feel free to add more reviewers. I wanted to cover the original contributors of im2col in IREE but I'm not sure I got all of them.

Reviewed By: nicolasvasilache, ThomasRaoux

Differential Revision: https://reviews.llvm.org/D144108
mlir/include/mlir/Dialect/Linalg/TransformOps/LinalgTransformOps.td
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
mlir/lib/Dialect/Linalg/Transforms/CMakeLists.txt
mlir/lib/Dialect/Linalg/Transforms/ConvertConv2DToImg2Col.cpp [new file with mode: 0644]
mlir/test/Dialect/Linalg/convert-conv2d-to-img2col.mlir [new file with mode: 0644]