1
1
// RUN: mlir-opt %s --canonicalize --cse | FileCheck %s
2
2
3
+ #DenseVector = #sparse_tensor.encoding <{dimLevelType = [" dense" ]}>
3
4
#SparseVector = #sparse_tensor.encoding <{dimLevelType = [" compressed" ]}>
4
5
5
6
// CHECK-LABEL: func @sparse_nop_convert(
@@ -18,3 +19,28 @@ func @sparse_dce_convert(%arg0: tensor<64xf32>) {
18
19
%0 = sparse_tensor.convert %arg0 : tensor <64 xf32 > to tensor <64 xf32 , #SparseVector >
19
20
return
20
21
}
22
+
23
+ // CHECK-LABEL: func @sparse_dce_getters(
24
+ // CHECK-SAME: %[[A:.*]]: tensor<64xf32, #sparse_tensor.encoding<{{{.*}}}>>)
25
+ // CHECK-NOT: sparse_tensor.pointers
26
+ // CHECK-NOT: sparse_tensor.indices
27
+ // CHECK-NOT: sparse_tensor.values
28
+ // CHECK: return
29
+ func @sparse_dce_getters (%arg0: tensor <64 xf32 , #SparseVector >) {
30
+ %c = constant 0 : index
31
+ %0 = sparse_tensor.pointers %arg0 , %c : tensor <64 xf32 , #SparseVector > to memref <?xindex >
32
+ %1 = sparse_tensor.indices %arg0 , %c : tensor <64 xf32 , #SparseVector > to memref <?xindex >
33
+ %2 = sparse_tensor.values %arg0 : tensor <64 xf32 , #SparseVector > to memref <?xf32 >
34
+ return
35
+ }
36
+
37
+ // CHECK-LABEL: func @sparse_dce_reconstruct(
38
+ // CHECK-SAME: %[[A:.*]]: tensor<64xf32, #sparse_tensor.encoding<{{{.*}}}>>)
39
+ // CHECK-NOT: sparse_tensor.values
40
+ // CHECK-NOT: sparse_tensor.tensor
41
+ // CHECK: return
42
+ func @sparse_dce_reconstruct (%arg0: tensor <64 xf32 , #DenseVector >) {
43
+ %0 = sparse_tensor.values %arg0 : tensor <64 xf32 , #DenseVector > to memref <?xf32 >
44
+ %1 = sparse_tensor.tensor %0 : memref <?xf32 > to tensor <64 xf32 , #DenseVector >
45
+ return
46
+ }
0 commit comments