This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Vectorize 2-D NHWC-HWCF convolution ops
AbandonedPublic

Authored by antiagainst on Oct 25 2021, 10:42 AM.

Details

Summary

This commits adds support for vectorizing linalg ops
that are effectively linalg.conv_2d_nhwc_hwcf ops.

This rebase the ConvolutionOpInterface-based impl.
in https://reviews.llvm.org/D111722 to be implemented
using Linalg meta-programming schemes. Right now only
the NHWC-HWCF layout is supported.

Diff Detail

Event Timeline

antiagainst created this revision.Oct 25 2021, 10:42 AM
antiagainst requested review of this revision.Oct 25 2021, 10:42 AM
nicolasvasilache requested changes to this revision.Oct 27 2021, 1:11 AM

I do not understand why this is implemented as a new vectorization pattern.
The whole point of the discussion we had over the past few weeks was to find the smallest granularity vector op that packs enough punch to reach peak form registers (i.e. the conv1d).

Once this is available, one only needs to rewrite other convs in this form by tiling + rewrite at the linalg level.
There is value in creating a new such vectorization scheme only when it is proven (with performance numbers) that it is needed.

In the absence of such performance numbers, this is just more code that we need to maintain.
Even in the presence of such numbers, the conclusion may not be that we want a special 2-D conv vectorizer but that something needs to be improved in the existing code.

Our bias should be towards finer and simpler granularity.
For instance, I am not convinced the current 1-D conv granularity is the smallest that can achieve peak and I will be looking at breaking it up into smaller more modular components that can reach peak.
Rationale: We know that vector.contract can reach peak (but only after a certain size e.g. 12x32x16 on AVX512) and those sizes may not be good for conv1d to lower to, so it makes sense to do something conv-specific with a bit higher granularity.

This diff is going in the exact opposite way.

This revision now requires changes to proceed.Oct 27 2021, 1:11 AM
antiagainst abandoned this revision.Nov 1 2021, 7:29 AM

Thanks for the comment. I've uploaded https://reviews.llvm.org/D112928 to perform the conversion at linalg level directly.