HomePhabricator

Add patterns to lower vector.multi_reduction into a sequence of vector.reduction

Authored by asaadaldien on Apr 29 2021, 2:05 PM.

Description

Add patterns to lower vector.multi_reduction into a sequence of vector.reduction

Three patterns are added to convert into vector.multi_reduction into a
sequence of vector.reduction as the following:

  • Transpose the inputs so inner most dimensions are always reduction.
  • Reduce rank of vector.multi_reduction into 2d with inner most

reduction dim (get the 2d canical form)

  • 2D canonical form is converted into a sequence of vector.reduction.

There are two things we might worth in a follow up diff:

  • An scf.for (maybe optionally) around vector.reduction instead of unrolling it.
  • Breakdown the vector.reduction into a sequence of vector.reduction

(e.g tree-based reduction) instead of relying on how downstream dialects
handle it.

Note: this will requires passing target-vector-length

Differential Revision: https://reviews.llvm.org/D101570