[Mlir-commits] [mlir] [mlir][SparseTensor][NFC] Use `tensor.empty` for dense tensors (PR #74804)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Dec 7 19:38:38 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: Matthias Springer (matthias-springer)
<details>
<summary>Changes</summary>
Use `tensor.empty` + initialization for dense tensors instead of `bufferization.alloc_tensor`.
---
Full diff: https://github.com/llvm/llvm-project/pull/74804.diff
1 Files Affected:
- (modified) mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul_slice.mlir (+4-3)
``````````diff
diff --git a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul_slice.mlir b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul_slice.mlir
index 8c42f667bb6014..85d51931db6c21 100644
--- a/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul_slice.mlir
+++ b/mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul_slice.mlir
@@ -158,7 +158,6 @@ module {
[ 0.0, 0.0, 6.0, 0.0 ],
[ 0.0, 0.0, 7.0, 8.0 ]
]> : tensor<8x4xf64>
- %zero = arith.constant dense<0.0> : tensor<4x4xf64>
// Convert all these matrices to sparse format.
%tmp = sparse_tensor.convert %sa : tensor<8x8xf64> to tensor<8x8xf64, #DCSR>
@@ -257,9 +256,11 @@ module {
%ds1 = tensor.extract_slice %sa[0, 1][4, 4][2, 1] : tensor<8x8xf64> to tensor<4x4xf64>
%ds2 = tensor.extract_slice %sb[0, 0][4, 4][2, 1] : tensor<8x4xf64> to tensor<4x4xf64>
- %d = bufferization.alloc_tensor() copy(%zero) : tensor<4x4xf64>
+ %d = tensor.empty() : tensor<4x4xf64>
+ %zeroed = linalg.fill ins(%f0 : f64) outs(%d : tensor<4x4xf64>)
+ -> tensor<4x4xf64>
%r = linalg.matmul ins(%ds2, %ds1: tensor<4x4xf64>, tensor<4x4xf64>)
- outs(%d: tensor<4x4xf64>) -> tensor<4x4xf64>
+ outs(%zeroed: tensor<4x4xf64>) -> tensor<4x4xf64>
%du = tensor.cast %r : tensor<4x4xf64> to tensor<*xf64>
call @printMemrefF64(%du) : (tensor<*xf64>) -> ()
``````````
</details>
https://github.com/llvm/llvm-project/pull/74804
More information about the Mlir-commits
mailing list