OSDN Git Service

[mlir] Fix subtensor_insert bufferization.
authorSean Silva <silvasean@google.com>
Thu, 12 Nov 2020 18:33:04 +0000 (10:33 -0800)
committerSean Silva <silvasean@google.com>
Thu, 12 Nov 2020 22:56:09 +0000 (14:56 -0800)
commitad2f9f67451cbb5e3af9760222f802da82f8024e
treef770c76be0062f492165df798cd164b1f5ad065a
parentd0ba6c4002e455cc005ca3f4baca36f2d199582f
[mlir] Fix subtensor_insert bufferization.

It was incorrect in the presence of a tensor argument with multiple
uses.

The bufferization of subtensor_insert was writing into a converted
memref operand, but there is no guarantee that the converted memref for
that operand is safe to write into. In this case, the same converted
memref is written to in-place by the subtensor_insert bufferization,
violating the tensor-level semantics.

I left some comments in a TODO about ways forward on this. I will be
working actively on this problem in the coming days.

Differential Revision: https://reviews.llvm.org/D91371
mlir/integration_test/Dialect/Linalg/CPU/test-subtensor-insert-multiple-uses.mlir [new file with mode: 0644]
mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/test/Dialect/Linalg/bufferize.mlir