[all-commits] [llvm/llvm-project] 3110e7: [mlir] Introduce AffineMinSCF folding as a pattern

Nicolas Vasilache via All-commits all-commits at lists.llvm.org
Fri Aug 7 11:33:27 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 3110e7b077d0031e8743614f742a500ccc522c77
      https://github.com/llvm/llvm-project/commit/3110e7b077d0031e8743614f742a500ccc522c77
  Author: Nicolas Vasilache <ntv at google.com>
  Date:   2020-08-07 (Fri, 07 Aug 2020)

  Changed paths:
    M mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
    M mlir/include/mlir/IR/AffineExpr.h
    M mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
    M mlir/lib/IR/AffineExpr.cpp
    A mlir/test/Dialect/Linalg/fold-affine-min-scf.mlir
    M mlir/test/lib/Transforms/TestLinalgTransforms.cpp

  Log Message:
  -----------
  [mlir] Introduce AffineMinSCF folding as a pattern

This revision adds a folding pattern to replace affine.min ops by the actual min value, when it can be determined statically from the strides and bounds of enclosing scf loop .

This matches the type of expressions that Linalg produces during tiling and simplifies boundary checks. For now Linalg depends both on Affine and SCF but they do not depend on each other, so the pattern is added there.
In the future this will move to a more appropriate place when it is determined.

The canonicalization of AffineMinOp operations in the context of enclosing scf.for and scf.parallel proceeds by:
  1. building an affine map where uses of the induction variable of a loop
  are replaced by `%lb + %step * floordiv(%iv - %lb, %step)` expressions.
  2. checking if any of the results of this affine map divides all the other
  results (in which case it is also guaranteed to be the min).
  3. replacing the AffineMinOp by the result of (2).

The algorithm is functional in simple parametric tiling cases by using semi-affine maps. However simplifications of such semi-affine maps are not yet available and the canonicalization does not succeed yet.

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




More information about the All-commits mailing list