[Mlir-commits] [mlir] [mlir][tosa] Forward concat insert_slice destination into DPS provider (PR #183490)
Hsiangkai Wang
llvmlistbot at llvm.org
Fri Feb 27 06:53:22 PST 2026
================
@@ -454,11 +456,84 @@ struct ConcatConverter : public OpConversionPattern<tosa::ConcatOp> {
}
};
+// Forward the destination tensor of concat generated tensor.insert_slice ops
+// into single-use destination-style tensor producers. This avoids creating a
+// producer on a temporary tensor that is immediately copied into the concat
+// result tensor.
----------------
Hsiangkai wrote:
Give an example to show the effect of applying the pattern. Something like,
Before:
`
%0 = tensor.empty() : tensor<4xf32>
%1 = linalg.fill ins(%cst : f32) outs(%0 : tensor<4xf32>) -> tensor<4xf32>
%2 = tensor.empty() : tensor<8xf32>
%inserted_slice = tensor.insert_slice %1 into %2[0] [4] [1] : tensor<4xf32> into tensor<8xf32>
%inserted_slice_1 = tensor.insert_slice %arg0 into %inserted_slice[4] [4] [1] : tensor<4xf32> into tensor<8xf32>
`
After:
`
%2 = tensor.empty() : tensor<8xf32>
%ext = tensor.extract_slice %2 ... : tensor<4xf32>
%1 = linalg.fill ins(%cst : f32) outs(%ext : tensor<4xf32>) -> tensor<4xf32>
%inserted_slice = tensor.insert_slice %1 into %2[0] [4] [1] : tensor<4xf32> into tensor<8xf32>
%inserted_slice_1 = tensor.insert_slice %arg0 into %inserted_slice[4] [4] [1] : tensor<4xf32> into tensor<8xf32>
`
https://github.com/llvm/llvm-project/pull/183490
More information about the Mlir-commits
mailing list