[all-commits] [llvm/llvm-project] 35d3b3: [mlir][bufferization] Add "bottom-up from terminat...

Matthias Springer via All-commits all-commits at lists.llvm.org
Wed Mar 20 22:16:23 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 35d3b3430eff16403d004d9f0b0369f0814cf140
      https://github.com/llvm/llvm-project/commit/35d3b3430eff16403d004d9f0b0369f0814cf140
  Author: Matthias Springer <me at m-sp.org>
  Date:   2024-03-21 (Thu, 21 Mar 2024)

  Changed paths:
    M mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h
    M mlir/include/mlir/Dialect/Bufferization/Transforms/OneShotAnalysis.h
    M mlir/include/mlir/Dialect/Bufferization/Transforms/Passes.td
    M mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
    M mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
    M mlir/test/Dialect/Arith/one-shot-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-allow-return-allocs.mlir
    A mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-analysis-bottom-up-from-terminators.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize-partial.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-bufferize.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-allow-return-allocs.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-analysis.mlir
    M mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir
    M mlir/test/Dialect/Linalg/one-shot-bufferize.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize-analysis.mlir
    M mlir/test/Dialect/SCF/one-shot-bufferize.mlir
    M mlir/test/Dialect/Tensor/one-shot-bufferize.mlir

  Log Message:
  -----------
  [mlir][bufferization] Add "bottom-up from terminators" analysis heuristic (#83964)

One-Shot Bufferize currently does not support loops where a yielded
value bufferizes to a buffer that is different from the buffer of the
region iter_arg. In such a case, the bufferization fails with an error
such as:
```
Yield operand #0 is not equivalent to the corresponding iter bbArg
    scf.yield %0 : tensor<5xf32>
```

One common reason for non-equivalent buffers is that an op on the path
from the region iter_arg to the terminator bufferizes out-of-place. Ops
that are analyzed earlier are more likely to bufferize in-place.

This commit adds a new heuristic that gives preference to ops that are
reachable on the reverse SSA use-def chain from a region terminator and
are within the parent region of the terminator. This is expected to work
better than the existing heuristics for loops where an iter_arg is
written to multiple times within a loop, but only one write is fed into
the terminator.

Current users of One-Shot Bufferize are not affected by this change.
"Bottom-up" is still the default heuristic. Users can switch to the new
heuristic manually.

This commit also turns the "fuzzer" pass option into a heuristic,
cleaning up the code a bit.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list