This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Use populateLinalgBufferizePatterns instead of copypasta.
AbandonedPublic

Authored by silvas on Oct 21 2020, 8:28 PM.

Details

Summary

The non-copypasta patterns set up proper type materializations, which
revealed the need for helper patterns that eliminate materializations,
which due to the complexity of the test cases (e.g. control flow),
tickles this particular issue.

The observation is that TestBufferPlacementPreparationPass is a
"finalizing" bufferization pass. That is, it does a "full" conversion
and needs all the materializations gone. So we expose a new helper
populateBufferizeEliminateMaterializationsPatternsAndLegality for
setting that up. This helper will soon be merged into
populateWithBufferizeOpConversionPatterns (which will be renamed
populateBufferizeFinalizationPatterns), but for now remains separate.

Note: LinalgBufferizePass is currently "finalizing", but I didn't apply
this there because I'm in the process of making that pass
non-finalizing (I'm making the finalizing process much nicer,
so that each dialect doesn't need its own finalizing bufferization).

Diff Detail

Event Timeline

silvas created this revision.Oct 21 2020, 8:28 PM
silvas requested review of this revision.Oct 21 2020, 8:28 PM
silvas edited the summary of this revision. (Show Details)Oct 21 2020, 9:05 PM
silvas edited the summary of this revision. (Show Details)Oct 21 2020, 9:09 PM
herhut requested changes to this revision.Oct 22 2020, 5:22 AM
herhut added subscribers: dfki-albo, dfki-heme.

Thanks for your work on cleaning up finalization. This all looks much nicer now.

I'd be happy to see the finalization part landing but would avoid introducing the dependency if it gets cleaned up soon enough.

mlir/lib/Transforms/Bufferize.cpp
104

Should this pattern fail if the operand is not a memref? Instead of creating wrong IR?

mlir/test/lib/Transforms/TestBufferPlacement.cpp
47

There is work underway by @dfki-albo and @dfki-heme to rephrase these tests so that they no longer depend on linalg operations. That will also remove the copypasta here.

This revision now requires changes to proceed.Oct 22 2020, 5:22 AM
silvas added inline comments.Oct 22 2020, 11:01 AM
mlir/test/lib/Transforms/TestBufferPlacement.cpp
47

Are there patches under-way? I'm going to get to this in the next couple days.

I'd be happy to see the finalization part landing but would avoid introducing the dependency if it gets cleaned up soon enough.

What do you mean "the dependency"? Or perhaps, what is the actionable request for this patch?

mlir/lib/Transforms/Bufferize.cpp
104

I don't think that is needed.

tensor (which is the only possibility other than memref), is illegal according to the TypeConverter that this pattern is meant to be used with, so operands cannot contain a tensor (the invariant is that operands are all legal types).

Most conversion patterns will create illegal IR / crash if invoked with an improper type converter. E.g. I can invoke mhlo to lmhlo patterns with a TypeConverter that converts tensor to i1 (with some bogus materialization) and then everything will crash.

I'd be happy to see the finalization part landing but would avoid introducing the dependency if it gets cleaned up soon enough.

What do you mean "the dependency"? Or perhaps, what is the actionable request for this patch?

Oh, I think I understand what you mean. I guess I'll just update this patch to not test the linalg case.

Ok, abandoning this patch. See the updated patch in https://reviews.llvm.org/D89979 which just generally refactors the pass to be a pure finalization test (and removes the dependence on linalg.generic bufferization).
I've added @dfki-albo @dfki-heme as reviewers there.

silvas abandoned this revision.Oct 22 2020, 1:42 PM