This patch introduces a new conversion to convert bufferization.clone operations
into a memref.alloc and a memref.copy operation. This transformation is needed to
transform all remaining clones which "survive" all previous transformations, before
a given program is lowered further (to LLVM e.g.). Otherwise, these operations
cannot be handled anymore and lead to compile errors.
See: https://llvm.discourse.group/t/bufferization-error-related-to-memref-clone/4665
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This is the first time I am solicited as a reviewer, probably because I raised the issue on discourse (https://llvm.discourse.group/t/bufferization-error-related-to-memref-clone/4665).
The patch implements a solution to the problem we signalled.
The code seems complete, and a test has been provided.
I am not yet competent enough to judge conformance to coding rules. If you think this should have made me resign as a reviewer, please let me know.
mlir/lib/Conversion/MemRefToMemRef/MemRefToMemRef.cpp | ||
---|---|---|
23 ↗ | (On Diff #388458) | This only works for static shapes. |
mlir/test/Conversion/MemRefToMemRef/memref-to-memref.mlir | ||
4 ↗ | (On Diff #388458) | Please add a test with dynamic shapes and unknown rank. I think it is ok if this fails for unknown rank for now but at least dynamic shapes should be supported. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
355 | Why is it not a "transform"? I thought that when we stay within a dialect, then it should be a transformation, not a conversion. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
355 | The idea was, that we could simply rename it to "bufferize-to-memref", if a bufferize dialect will be created. In this case, it would be a conversion. But you are right, if we stay within a dialect it should be a transformation. I suggest to move it to transforms, because this is the right place for this and both renaming and moving is almost the same amount of work. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
355 | Since the bufferization dialect is almost landed, let's just wait a bit and not submit. Then you will be able to just rename it. In the meantime, you can address Stephan's comments. |
mlir/test/Conversion/MemRefToMemRef/memref-to-memref.mlir | ||
---|---|---|
10–13 ↗ | (On Diff #388458) | No numbered values in CHECK lines. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
355 | Sounds good. Just tell me when it is landed. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
356 | The description looks too generic -- perhaps rephrase to " ... to simpler ones in the MemRef ...". | |
358 | I think you are missing the dependent dialects specification. | |
mlir/lib/Conversion/MemRefToMemRef/MemRefToMemRef.cpp | ||
6 ↗ | (On Diff #389208) | File-level summary comment here. |
20 ↗ | (On Diff #389208) | Summary doc comment. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
355 | I think it did : https://reviews.llvm.org/D114552 |
All files are renamed to "bufferization to memref" after the bufferization
dialect has been created.
Addressed further comments.
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
134 | Does this need to be a module pass? This limits concurrency and I think the transformation done here is function local. | |
mlir/lib/Conversion/BufferizationToMemRef/BufferizationToMemRef.cpp | ||
27 | nit: transforms. | |
38 | This limits composition. As an alternative, have the pattern fail and return a failure reason via the rewriter. | |
48 | nit: would memrefType.isDynamicDim(i) work here, too? | |
50 | Should this be a DimOp here? | |
63 | Are these comments needed? |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
135 | Can you expand on the doc a bit, at least mention that it turns a clone into alloc+copy. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
135 | Ping on this? |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
135 | I think, this is not the right place to mention that a clone operation is converted into alloc+copy, since this is a general description of the conversion pass. All other conversion passes also don't have a description or list of all converted operations. If there are further op-conversions added, the description has to be changed again. So, I added these remarks to the conversion implementation in the cpp file. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
135 |
Well this is all of what this pass does right now, and the bufferization stuff is complex enough that I'll insist on better documentation and cross referencing.
My point is that this summary right now is basically useless as a doc: this is purely redundant with the pass mnemonic without adding any new information. The doc gets published on the website: https://mlir.llvm.org/docs/Passes/#-convert-bufferization-to-memref-convert-operations-from-the-bufferization-dialect-to-the-memref-dialect ; So please fix and improve. You only added a summary (which isn't published for some reason), but there should be a description fields which can contains multiple paragraph as needed. Please also consider any such comment as blocking by default in the future. |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
135 | Ping here? |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
135 | Added documentation here: |
mlir/include/mlir/Conversion/Passes.td | ||
---|---|---|
135 | Thanks! |
Does this need to be a module pass? This limits concurrency and I think the transformation done here is function local.