[all-commits] [llvm/llvm-project] d80b04: [mlir][Affine][Vector] Support vectorizing reducti...

Sergei Grechanik via All-commits all-commits at lists.llvm.org
Wed May 5 09:13:38 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d80b04ab0015b218b613f8fe59506d45739817b8
      https://github.com/llvm/llvm-project/commit/d80b04ab0015b218b613f8fe59506d45739817b8
  Author: Sergei Grechanik <sergei.grechanik at intel.com>
  Date:   2021-05-05 (Wed, 05 May 2021)

  Changed paths:
    M mlir/include/mlir/Analysis/AffineAnalysis.h
    M mlir/include/mlir/Dialect/Affine/Passes.td
    M mlir/include/mlir/Dialect/Affine/Utils.h
    M mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
    M mlir/include/mlir/Dialect/Vector/VectorOps.h
    M mlir/lib/Analysis/AffineAnalysis.cpp
    M mlir/lib/Conversion/AffineToStandard/AffineToStandard.cpp
    M mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
    M mlir/lib/Dialect/StandardOps/IR/Ops.cpp
    M mlir/lib/Dialect/Vector/VectorOps.cpp
    M mlir/test/Dialect/Affine/SuperVectorize/vectorize_1d.mlir
    A mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction.mlir
    A mlir/test/Dialect/Affine/SuperVectorize/vectorize_reduction_2d.mlir

  Log Message:
  -----------
  [mlir][Affine][Vector] Support vectorizing reduction loops

This patch adds support for vectorizing loops with 'iter_args'
implementing known reductions along the vector dimension. Comparing to
the non-vector-dimension case, two additional things are done during
vectorization of such loops:
- The resulting vector returned from the loop is reduced to a scalar
  using `vector.reduce`.
- In some cases a mask is applied to the vector yielded at the end of
  the loop to prevent garbage values from being written to the
  accumulator.

Vectorization of reduction loops is disabled by default. To enable it, a
map from loops to array of reduction descriptors should be explicitly passed to
`vectorizeAffineLoops`, or `vectorize-reductions=true` should be passed
to the SuperVectorize pass.

Current limitations:
- Loops with a non-unit step size are not supported.
- n-D vectorization with n > 1 is not supported.

Reviewed By: nicolasvasilache

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




More information about the All-commits mailing list