This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Linalg] Revisit heuristic ordering of tensor.insert_slice in comprehensive bufferize.
ClosedPublic

Authored by nicolasvasilache on Sep 20 2021, 7:04 AM.

Details

Summary

It was previously assumed that tensor.insert_slice should be bufferized first in a greedy fashion to avoid out-of-place bufferization of the large tensor. This heuristic does not hold upon further inspection.

This CL removes the special handling of such ops and adds a test that exhibits better behavior and appears in real use cases.

The only test adversely affected is an artificial test which results in a returned memref: this pattern is not allowed by comprehensive bufferization in real scenarios anyway and the offending test is deleted.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Sep 20 2021, 7:04 AM
gysit accepted this revision.Sep 20 2021, 7:33 AM
This revision is now accepted and ready to land.Sep 20 2021, 7:33 AM
springerm accepted this revision.Sep 20 2021, 5:47 PM
springerm added inline comments.
mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
2483–2493

Less code is always good but I'm wondering if there any important cases that see a performance degradation (more out-of-place bufferization) because of this.

nicolasvasilache marked an inline comment as done.Sep 21 2021, 7:28 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Linalg/Transforms/ComprehensiveBufferize.cpp
2483–2493

I'd turn the burden of proof back :)

Evidence has shown that this was a premature concern as:

  1. the only existing test case that benefits from this is artifical and would fail bufferization anyway.
  2. the new test case we were discussing suffers from the order and hides the subalias intersection problem.

It is possible (even likely) future use cases appear that will require a real heuristic; when we have the concrete need we should improve the heuristic further.

This revision was landed with ongoing or failed builds.Sep 21 2021, 7:31 AM
This revision was automatically updated to reflect the committed changes.
nicolasvasilache marked an inline comment as done.