This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Refactor Linalg vectorization for better reuse and extensibility.
ClosedPublic

Authored by nicolasvasilache on Feb 1 2021, 9:55 AM.

Details

Summary

This revision unifies Linalg vectorization and paves the way for vectorization of Linalg ops with mixed-precision operations.
The new algorithm traverses the ops in the linalg block in order and avoids recursion.
It uses a BlockAndValueMapping to keep track of vectorized operations.

The revision makes the following modifications but is otherwise NFC:

  1. vector.transfer_read are created eagerly and may appear in a different order than the original order.
  2. a more progressive vectorization to vector.contract results in only the multiply operation being converted to vector.contract %a, %b, %zero, where %zero is a constant of the proper type. Later vector canonicalizations are assumed to rewrite vector.contract %a, %b, %zero + add to a proper accumulate form.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Feb 1 2021, 9:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 1 2021, 9:55 AM
ThomasRaoux accepted this revision.Feb 1 2021, 8:44 PM
ThomasRaoux added inline comments.
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
273

remove?

This revision is now accepted and ready to land.Feb 1 2021, 8:44 PM
bondhugula requested changes to this revision.Feb 2 2021, 12:18 AM
bondhugula added a subscriber: bondhugula.
bondhugula added inline comments.
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
42

Nit: missing period at the end.

46

Likewise.

55–58

Missing doc comments - for struct and for fields (esp. the second one).

60

Missing doc comment.

67

Likewise.

77

Missing doc comment.

107

All local methods are also expected to have doc comments - however obvious they may appear now.

184

Likewise.

This revision now requires changes to proceed.Feb 2 2021, 12:18 AM
bondhugula added inline comments.Feb 2 2021, 12:35 AM
mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp
44

Triple ///.

192–193

then block should use braces if the else block does.
https://llvm.org/docs/CodingStandards.html#id59

273

Drop commented out code.

461

Use variadic isa.

In general, you may want to add a summary comment in the commit summary as to what moved and what additions were made.

Address comments.

nicolasvasilache marked 12 inline comments as done.Feb 2 2021, 3:16 AM
nicolasvasilache marked an inline comment as done.

Address comments.

nicolasvasilache edited the summary of this revision. (Show Details)Feb 2 2021, 3:22 AM
This revision was not accepted when it landed; it landed in state Needs Review.Feb 2 2021, 3:34 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.