Skip to content

Commit 95d6aa2

Browse files
[mlir][SparseTensor][NFC] Use tensor.empty for dense tensors (#74804)
Use `tensor.empty` + initialization for dense tensors instead of `bufferization.alloc_tensor`.
1 parent fb9a851 commit 95d6aa2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

mlir/test/Integration/Dialect/SparseTensor/CPU/sparse_matmul_slice.mlir

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ module {
158158
[ 0.0, 0.0, 6.0, 0.0 ],
159159
[ 0.0, 0.0, 7.0, 8.0 ]
160160
]> : tensor<8x4xf64>
161-
%zero = arith.constant dense<0.0> : tensor<4x4xf64>
162161

163162
// Convert all these matrices to sparse format.
164163
%tmp = sparse_tensor.convert %sa : tensor<8x8xf64> to tensor<8x8xf64, #DCSR>
@@ -257,9 +256,11 @@ module {
257256
%ds1 = tensor.extract_slice %sa[0, 1][4, 4][2, 1] : tensor<8x8xf64> to tensor<4x4xf64>
258257
%ds2 = tensor.extract_slice %sb[0, 0][4, 4][2, 1] : tensor<8x4xf64> to tensor<4x4xf64>
259258

260-
%d = bufferization.alloc_tensor() copy(%zero) : tensor<4x4xf64>
259+
%d = tensor.empty() : tensor<4x4xf64>
260+
%zeroed = linalg.fill ins(%f0 : f64) outs(%d : tensor<4x4xf64>)
261+
-> tensor<4x4xf64>
261262
%r = linalg.matmul ins(%ds2, %ds1: tensor<4x4xf64>, tensor<4x4xf64>)
262-
outs(%d: tensor<4x4xf64>) -> tensor<4x4xf64>
263+
outs(%zeroed: tensor<4x4xf64>) -> tensor<4x4xf64>
263264
%du = tensor.cast %r : tensor<4x4xf64> to tensor<*xf64>
264265
call @printMemrefF64(%du) : (tensor<*xf64>) -> ()
265266

0 commit comments

Comments
 (0)