Hi

is the purpose of DPS(DestinationStype) for to reduce the memref.copy when one-shot-bufferization?

thanks.

yes, I read, but still donâ€™t get the key informaion

DestinationPassing style exists in itself without bufferization, many ops are â€śupdatingâ€ť part of a tensor, and so they take the tensor and the slice to update. Since tensors are immutable object, the op returns a new tensor.

Another example is linalg, with the misleading â€śoutsâ€ť parameters which provides the initial values when the operation is doing a reduction, and also used to infer the resulting shape.

There is a relationship to bufferization though in that when this â€śimmutable tensorâ€ť that serves as initial value to the operation isnâ€™t used anywhere else, it becomes trivial to just reuse its memory and update it in place instead of creating a copy.

This is more visible for an operation which does not actually need an initial tensor, letâ€™s say you want just to add two tensors with linalg:

```
%r = linalg.generic {
indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>,
affine_map<(d0, d1) -> (do, d1)>,
affine_map<(d0, d1)-> (d0, d1)>],
iterator_types = ["parallel", "parallel"]}
ins(%t1, %t2 : tensor<?x?xf32>, tensor<?x?xf32>)
outs(%empty : tensor<?x?xf32>) {
^bb0(%arg0 : f32, %arg1 : f32, %arg2 : f32) :
%add = arith.addf %arg0, %arg1 : f32
linalg.yield %add : f32
} -> tensor<?x?xf32>
```

Conceptually if I simplify it is:

```
%r = %t1, %t2, %empty : linalg.addf tensor<?x?xf32>
```

There are three input In this form the `outs`

isnâ€™t strictly needed, but linalg still requires it. We will consider this op in destination passing style, and if the â€ś%emptyâ€ť tensor isnâ€™t used anywhere else, itâ€™ll provide an â€śanchorâ€ť for the bufferization algorithm to use for aliasing its buffer allocation with the result.

But Iâ€™m just repeating here whatâ€™s in the doc, and you should be more precise about what is unclearâ€¦

now, it is clearly, thanks very much

This paper also has an excellent explanation for DPS: https://www.microsoft.com/en-us/research/wp-content/uploads/2016/11/dps-submitted.pdf

got it, thanks