[Mlir-commits] [mlir] [mlir][linalg] do not break outs from block argument (PR #73572)

Okwan Kwon llvmlistbot at llvm.org
Tue Nov 28 22:40:41 PST 2023


================
@@ -1818,6 +1818,11 @@ struct RemoveOutsDependency : public OpRewritePattern<GenericOp> {
         if (sparse_tensor::getSparseTensorEncoding(operandVal.getType()))
           continue;
 
+        // If outs is wired from a block argument, keep the dependency to
+        // prevent the argument from being optimized away.
----------------
okkwon wrote:

> Yes, tensors are immutable object: the outs in linalg-on-tensor refers to two things as far as I remember:
>
> The shape of the output, in case of dynamic output.
> The initial value in case of reduction iterators.

Thanks a lot @joker-eph for this. I think I now understand the tensor emtpy semantic much better.

Based on the semantic, linking the information from the output storage through the DPS doesn't seem to be a robust way. I really like the explicit way using an operation. Since tensor is supposed to be immutable, let me try to preserve the property. I was hesitant to introduce memref before bufferization, but memref + explicit operation seems to be the cleanest way without introducing some hidden dependency on how things should work implicitly.


https://github.com/llvm/llvm-project/pull/73572


More information about the Mlir-commits mailing list