[mlir][bufferization] Better handling of unranked tensors in resolveTensorOpOperandCo...
authorMatthias Springer <springerm@google.com>
Mon, 30 Jan 2023 09:19:32 +0000 (10:19 +0100)
committerMatthias Springer <springerm@google.com>
Mon, 30 Jan 2023 09:20:10 +0000 (10:20 +0100)
commitd7f72d4bb47a7097c895da8648b4f097f977fed3
treefc37f1e768b6665ef4297f853e1e6c7cc991c724
parentb7858f85f54c92ea6db2cd94247dea41c0e64026
[mlir][bufferization] Better handling of unranked tensors in resolveTensorOpOperandConflicts

Unranked tensors can currently not be copied. They are forced to always bufferize in-place. There is typically some other OpOperand that can bufferize out-of-place instead if needed.

Note: There is IR that cannot be bufferized with One-Shot Bufferize at the moment (see invalid test case). But it is unclear if we need to support such cases. We do not have a use case at the moment. This restriction could be loosened in the future if needed.

This change improves error handling when bufferizing IR where an unranked tensor would be copied. It also disables an optimization where an OpResult was copied instead of an OpOperand in case the OpResult is an unranked tensor (Github #60187).

Differential Revision: https://reviews.llvm.org/D142331
mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.td
mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp
mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-analysis.mlir
mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize-invalid.mlir
mlir/test/Dialect/Bufferization/Transforms/one-shot-module-bufferize.mlir