This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] lower index operations during linalg to vector lowering.
ClosedPublic

Authored by gysit on Apr 13 2021, 2:28 AM.

Details

Summary

The patch extends the vectorization pass to lower linalg index operations to vector code. It allocates constant 1d vectors that enumerate the indexes along the iteration dimensions and broadcasts/transposes these 1d vectors to the iteration space.

Diff Detail

Event Timeline

gysit created this revision.Apr 13 2021, 2:28 AM
gysit requested review of this revision.Apr 13 2021, 2:28 AM
ftynse accepted this revision.Apr 13 2021, 9:58 AM

Please give @nicolasvasilache a chance to review.

mlir/include/mlir/Dialect/Linalg/IR/LinalgInterfaces.td
1247

Naming nit: "StaticOperandDims" was confusing to me consider swapping to "OperandStaticDims" that makes clear _what_ is static (dimensions)

mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
201–202

llvm::append_range(res, t.getShape()) spares you the loop, and decreases the number of dynamic allocations

227

Nit: please spell out the auto. We generally use auto when the type is excessively long (iterators, lambdas) or evident from context (RHS is a cast).

This revision is now accepted and ready to land.Apr 13 2021, 9:58 AM
gysit updated this revision to Diff 337209.Apr 13 2021, 11:02 AM

Addressing review comments:

  • rename StaticOperandDims to OperandStaticDims
  • spell out auto
  • use llvm::append instead of a loop
gysit marked 3 inline comments as done.Apr 13 2021, 11:03 AM
gysit updated this revision to Diff 338728.Apr 19 2021, 11:59 PM

Updated to head.