[mlir][linalg] Refactor convolution to img2col conversion to use gather semantics
authorQuinn Dawkins <quinn@nod-labs.com>
Thu, 23 Feb 2023 16:30:20 +0000 (11:30 -0500)
committerQuinn Dawkins <quinn@nod-labs.com>
Thu, 23 Mar 2023 23:38:53 +0000 (19:38 -0400)
commitc82803097f6a89edc49577e5bb4f7309e053efcc
tree8e2dbab615fb80672dc43915bff055945dc5cb37
parent07ef7b1ff21e8e3faaf8279b8ec6a7f0ac252fad
[mlir][linalg] Refactor convolution to img2col conversion to use gather semantics

Following up on the comments in https://reviews.llvm.org/D144108 this
patch refactors the im2col conversion patterns for `linalg.conv_2d_nhwc_hwcf`
and `linalg.conv_2d_nchw_fchw` convolutions to use gather semantics for the im2col
packing `linalg.generic`.

Follow up work can include a similar pattern for depthwise convolutions
and a generalization of the patterns here to work with any `LinalgOp` as
well.

Differential Revision: https://reviews.llvm.org/D144678
mlir/lib/Dialect/Linalg/Transforms/ConvertConv2DToImg2Col.cpp
mlir/test/Dialect/Linalg/convert-conv2d-to-img2col.mlir