1
- // RUN: mlir-opt %s --sparse-compiler | \
2
- // RUN: mlir-cpu-runner \
3
- // RUN: -e entry -entry-point-result=void \
4
- // RUN: -shared-libs=%mlir_lib_dir/libmlir_c_runner_utils%shlibext | \
5
- // RUN: FileCheck %s
1
+ // DEFINE: %{option} = enable-runtime-library=true
2
+ // DEFINE: %{command} = mlir-opt %s --sparse-compiler=%{option} | \
3
+ // DEFINE: mlir-cpu-runner \
4
+ // DEFINE: -e entry -entry-point-result=void \
5
+ // DEFINE: -shared-libs=%mlir_lib_dir/libmlir_c_runner_utils%shlibext | \
6
+ // DEFINE: FileCheck %s
7
+ //
8
+ // RUN: %{command}
9
+ //
10
+ // Do the same run, but now with direct IR generation.
11
+ // REDEFINE: %{option} = enable-runtime-library=false
12
+ // RUN: %{command}
6
13
7
14
#SparseVector = #sparse_tensor.encoding <{dimLevelType = [" compressed" ]}>
8
15
@@ -49,12 +56,14 @@ module {
49
56
func.func @dump (%arg0: tensor <?xf32 , #SparseVector >) {
50
57
%c0 = arith.constant 0 : index
51
58
%d0 = arith.constant -1.0 : f32
59
+ %n = sparse_tensor.number_of_entries %arg0 : tensor <?xf32 , #SparseVector >
60
+ vector.print %n : index
52
61
%values = sparse_tensor.values %arg0 : tensor <?xf32 , #SparseVector > to memref <?xf32 >
53
- %0 = vector.transfer_read %values [%c0 ], %d0: memref <?xf32 >, vector <4 x f32 >
54
- vector.print %0 : vector <4 x f32 >
62
+ %0 = vector.transfer_read %values [%c0 ], %d0: memref <?xf32 >, vector <3 x f32 >
63
+ vector.print %0 : vector <3 x f32 >
55
64
%indices = sparse_tensor.indices %arg0 { dimension = 0 : index } : tensor <?xf32 , #SparseVector > to memref <?xindex >
56
- %1 = vector.transfer_read %indices [%c0 ], %c0: memref <?xindex >, vector <4 x index >
57
- vector.print %1 : vector <4 x index >
65
+ %1 = vector.transfer_read %indices [%c0 ], %c0: memref <?xindex >, vector <3 x index >
66
+ vector.print %1 : vector <3 x index >
58
67
return
59
68
}
60
69
@@ -76,10 +85,12 @@ module {
76
85
//
77
86
// Verify the results.
78
87
//
79
- // CHECK: ( 5.13, 3, 5, -1 )
80
- // CHECK-NEXT: ( 0, 20, 31, 0 )
81
- // CHECK-NEXT: ( 2, 4, 6, -1 )
82
- // CHECK-NEXT: ( 0, 20, 31, 0 )
88
+ // CHECK: 3
89
+ // CHECK-NEXT: ( 5.13, 3, 5 )
90
+ // CHECK-NEXT: ( 0, 20, 31 )
91
+ // CHECK-NEXT: 3
92
+ // CHECK-NEXT: ( 2, 4, 6 )
93
+ // CHECK-NEXT: ( 0, 20, 31 )
83
94
//
84
95
call @dump (%0 ) : (tensor <?xf32 , #SparseVector >) -> ()
85
96
call @dump (%1 ) : (tensor <?xf32 , #SparseVector >) -> ()
0 commit comments