[Mlir-commits] [mlir] 95d6aa2 - [mlir][SparseTensor][NFC] Use `tensor.empty` for dense tensors (#74804)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Dec 11 15:57:07 PST 2023


Author: Matthias Springer
Date: 2023-12-12T08:56:47+09:00
New Revision: 95d6aa21fbd41b786a6fb50821bb84b59b3b20e7

URL: https://github.com/llvm/llvm-project/commit/95d6aa21fbd41b786a6fb50821bb84b59b3b20e7
DIFF: https://github.com/llvm/llvm-project/commit/95d6aa21fbd41b786a6fb50821bb84b59b3b20e7.diff

LOG: [mlir][SparseTensor][NFC] Use `tensor.empty` for dense tensors (#74804)

Use `tensor.empty` + initialization for dense tensors instead of
`bufferization.alloc_tensor`.

Added: 
    

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

Removed: 
    


################################################################################
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>) -> ()
 


        


More information about the Mlir-commits mailing list