This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Masking support for reductions in Linalg vectorizer
ClosedPublic

Authored by dcaballe on Jan 12 2023, 12:13 AM.

Details

Summary

This patch enables vectorization of reductions in Linalg vectorizer
using the vector.mask operation. It also introduces the logic to slice
and propagate the vector mask of a masked multi-reduction to their
respective lowering operations.

Diff Detail

Event Timeline

dcaballe created this revision.Jan 12 2023, 12:13 AM
Herald added a project: Restricted Project. · View Herald Transcript
dcaballe requested review of this revision.Jan 12 2023, 12:13 AM
nicolasvasilache accepted this revision.Jan 12 2023, 3:51 AM

Nice, thanks!

Please address comments and let's iterate (fully dynamic condition relaxation can be a separate PR).

mlir/include/mlir/Dialect/Vector/Transforms/VectorMaskingUtils.h
20 ↗(On Diff #488501)

I usually prefer to make these static functions in the proper op / interface to avoid people missing them and constantly reinventing.
I have found the Utils thing to not work as well.

20 ↗(On Diff #488501)

ugh .. do we have other instances of such static impls in the .h ?

mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
957–958

Could we relax the dynamic requirement ?
I am expecting followup canonicalizations to be quite simple but I would like to be able to vectorize partially dynamic ops

mlir/lib/Dialect/Vector/IR/VectorOps.cpp
348

ugh .. why do we have 2 APIs for this now .. we have a VectorBuilder(vecType).xxx.
If this is an unambiguously better way that e.g. works with all types, we should only use that but I haven't seen an RFC or PSA for this.

This revision is now accepted and ready to land.Jan 12 2023, 3:51 AM
dcaballe updated this revision to Diff 488785.Jan 12 2023, 3:05 PM
dcaballe marked 3 inline comments as done.

Addressed feedback

mlir/include/mlir/Dialect/Vector/Transforms/VectorMaskingUtils.h
20 ↗(On Diff #488501)

Argg... sorry... This was a last minute change after posting D141559 as I thought it would be convenient to keep those utils separate from the rest of the vector stuff. Let me move this around.

mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
957–958

Yep, that is coming next. I'm just making sure we are not generating horrendous code for some cases. I enabled all of this in once shot and performance didn't look good :)

mlir/lib/Dialect/Vector/IR/VectorOps.cpp
348

Idk... fixed...

Cool, thanks!

Let's land and iterate.

This revision was landed with ongoing or failed builds.Jan 13 2023, 12:45 PM
This revision was automatically updated to reflect the committed changes.