Bufferization.alloc_tensor and tensor.empty

Hi,

I am trying to improve my understanding of the differences between the use case for the alloc_tensor operation from the bufferization dialect and the tensor.empty op from the tensor dialect.

Currently, my understanding is that the former operation will always bufferize to a new memory allocation while the latter may or may not, depending on its use in the IR and what the bufferization pipeline determines needs to be a new allocation.

I am particularly confused when it comes to DPS operations with several outs operands of the same type. For e.g., in my dialect I have an operation which represents computing the gradient of some input field, producing one tensor result for each coordinate direction. If I need several uninitialized tensors of the same type and I use tensor.empty to create them, the CSE pass will fuse them together as the operation is Pure. However, if the uninitialized tensors are being used as the outs operands of an operation with several results, having the same value for each of the outs operands is confusing. In this case, is it more correct to use the bufferization.alloc_tensor to create the uninitialized tensors needed in the outs operands?

Thank you in advance,
Edward