[Mlir-commits] [mlir] d4e1617 - [mlir][sparse] add dce test for all sparse tensor ops

Aart Bik llvmlistbot at llvm.org
Fri Sep 17 13:03:49 PDT 2021


Author: Aart Bik
Date: 2021-09-17T13:03:42-07:00
New Revision: d4e16171e889df1be22cb9cc64c58c9966124db3

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

LOG: [mlir][sparse] add dce test for all sparse tensor ops

Reviewed By: ThomasRaoux

Differential Revision: https://reviews.llvm.org/D109992

Added: 
    

Modified: 
    mlir/test/Dialect/SparseTensor/fold.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/test/Dialect/SparseTensor/fold.mlir b/mlir/test/Dialect/SparseTensor/fold.mlir
index b26f00329a439..035cac4dbe4b2 100644
--- a/mlir/test/Dialect/SparseTensor/fold.mlir
+++ b/mlir/test/Dialect/SparseTensor/fold.mlir
@@ -1,5 +1,6 @@
 // RUN: mlir-opt %s  --canonicalize --cse | FileCheck %s
 
+#DenseVector  = #sparse_tensor.encoding<{dimLevelType = ["dense"]}>
 #SparseVector = #sparse_tensor.encoding<{dimLevelType = ["compressed"]}>
 
 // CHECK-LABEL: func @sparse_nop_convert(
@@ -18,3 +19,28 @@ func @sparse_dce_convert(%arg0: tensor<64xf32>) {
   %0 = sparse_tensor.convert %arg0 : tensor<64xf32> to tensor<64xf32, #SparseVector>
   return
 }
+
+// CHECK-LABEL: func @sparse_dce_getters(
+//  CHECK-SAME: %[[A:.*]]: tensor<64xf32, #sparse_tensor.encoding<{{{.*}}}>>)
+//   CHECK-NOT: sparse_tensor.pointers
+//   CHECK-NOT: sparse_tensor.indices
+//   CHECK-NOT: sparse_tensor.values
+//       CHECK: return
+func @sparse_dce_getters(%arg0: tensor<64xf32, #SparseVector>) {
+  %c = constant 0 : index
+  %0 = sparse_tensor.pointers %arg0, %c : tensor<64xf32, #SparseVector> to memref<?xindex>
+  %1 = sparse_tensor.indices %arg0, %c : tensor<64xf32, #SparseVector> to memref<?xindex>
+  %2 = sparse_tensor.values %arg0 : tensor<64xf32, #SparseVector> to memref<?xf32>
+  return
+}
+
+// CHECK-LABEL: func @sparse_dce_reconstruct(
+//  CHECK-SAME: %[[A:.*]]: tensor<64xf32, #sparse_tensor.encoding<{{{.*}}}>>)
+//   CHECK-NOT: sparse_tensor.values
+//   CHECK-NOT: sparse_tensor.tensor
+//       CHECK: return
+func @sparse_dce_reconstruct(%arg0: tensor<64xf32, #DenseVector>) {
+  %0 = sparse_tensor.values %arg0 : tensor<64xf32, #DenseVector> to memref<?xf32>
+  %1 = sparse_tensor.tensor %0 : memref<?xf32> to tensor<64xf32, #DenseVector>
+  return
+}


        


More information about the Mlir-commits mailing list