This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Refactor convolution to img2col conversion to use gather semantics
ClosedPublic

Authored by qedawkins on Feb 23 2023, 2:51 PM.

Details

Summary

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.

Diff Detail

Event Timeline

qedawkins created this revision.Feb 23 2023, 2:51 PM
qedawkins requested review of this revision.Feb 23 2023, 2:51 PM

still looking, few nits for now

mlir/lib/Dialect/Linalg/Transforms/ConvertConv2DToImg2Col.cpp
44

mark private functions as static and add a doc

67

ditto

162
qedawkins updated this revision to Diff 500077.Feb 23 2023, 9:43 PM

clarify helpers and cleanup

qedawkins marked 3 inline comments as done.Feb 23 2023, 9:44 PM

@ThomasRaoux Bump on the review :)

This revision is now accepted and ready to land.Mar 23 2023, 4:16 PM
mlir/lib/Dialect/Linalg/Transforms/ConvertConv2DToImg2Col.cpp
64

you should express all those things with affine.apply ops

qedawkins added inline comments.Mar 24 2023, 8:50 AM
mlir/lib/Dialect/Linalg/Transforms/ConvertConv2DToImg2Col.cpp
64
mlir/lib/Dialect/Linalg/Transforms/ConvertConv2DToImg2Col.cpp
64

Nice, thanks!