This is an archive of the discontinued LLVM Phabricator instance.

[MLIR] [Linalg] Add option to use the partial view after promotion.
ClosedPublic

Authored by poechsel on May 14 2020, 1:48 AM.

Details

Summary

For now the promoted buffer is indexed using the full view. The full view might be
slightly bigger than the partial view (which is accounting for boundaries).
Unfortunately this does not compose easily with other transformations when multiple buffers
with shapes related to each other are involved.
Take linalg.matmul A B C (with A of size MxK, B of size KxN and C of size MxN) and suppose we are:

  • Tiling over M by 100
  • Promoting A only

This is producing a linalg.matmul promoted_A B subview_C where promoted_A is a promoted buffer
of A of size (100xK) and subview_C is a subview of size mxK where m could be smaller than 100 due
to boundaries thus leading to a possible incorrect behavior.

We propose to:

  • Add a new parameter to the tiling promotion allowing to enable the use of the full tile buffer.
  • By default all promoted buffers will be indexed by the partial view.

Note that this could be considered as a breaking change in comparison to the way the tiling promotion
was working.

Diff Detail

Event Timeline

poechsel created this revision.May 14 2020, 1:48 AM
ftynse requested changes to this revision.May 14 2020, 4:06 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
102

And if None?

103

You can also consider llvm::BitVector

105

The API looks misleading, ArrayRef<int64_t> uses feels like it accepts the indices of operands for which full tiles must be used, but you really imply ArrayRef<bool> useFullTiles).

110

This looks like it would use full buffer for the first operand, not all operands.

mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
73
SmallVector<bool, 4> vUseFullTileBuffers = options.useFullTileBuffers.getValueOr(SmallVector<bool, 4>());
vUseFullTileBuffers.resize(linalgOp.getNumInputsAndOutputBuffers(), false);

looks more concise to me

83

Nit: I think this-> is unncessary here

This revision now requires changes to proceed.May 14 2020, 4:06 AM
poechsel updated this revision to Diff 264011.May 14 2020, 8:56 AM

Clarified semantics of useFullTileBuffers.

poechsel marked 6 inline comments as done.May 14 2020, 8:57 AM
nicolasvasilache accepted this revision.May 14 2020, 8:55 PM
ftynse accepted this revision.May 18 2020, 5:09 AM
ftynse added inline comments.
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
78

Please don't use references with llvm::enumerate

This revision is now accepted and ready to land.May 18 2020, 5:09 AM
poechsel marked an inline comment as done.May 18 2020, 7:05 AM
This revision was automatically updated to reflect the committed changes.