1// RUN: mlir-opt %s \
2// RUN:   --sparsification --sparse-tensor-conversion \
3// RUN:   --convert-vector-to-scf --convert-scf-to-std \
4// RUN:   --func-bufferize --tensor-constant-bufferize --tensor-bufferize \
5// RUN:   --std-bufferize --finalizing-bufferize  \
6// RUN:   --convert-vector-to-llvm --convert-memref-to-llvm --convert-std-to-llvm --reconcile-unrealized-casts | \
7// RUN: mlir-cpu-runner \
8// RUN:  -e entry -entry-point-result=void  \
9// RUN:  -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \
10// RUN: FileCheck %s
11
12#Tensor1  = #sparse_tensor.encoding<{
13  dimLevelType = [ "compressed", "compressed", "compressed" ],
14  dimOrdering = affine_map<(i,j,k) -> (i,j,k)>
15}>
16
17#Tensor2  = #sparse_tensor.encoding<{
18  dimLevelType = [ "compressed", "compressed", "compressed" ],
19  dimOrdering = affine_map<(i,j,k) -> (j,k,i)>
20}>
21
22#Tensor3  = #sparse_tensor.encoding<{
23  dimLevelType = [ "compressed", "compressed", "compressed" ],
24  dimOrdering = affine_map<(i,j,k) -> (k,i,j)>
25}>
26
27//
28// Integration test that tests conversions between sparse tensors.
29//
30module {
31  //
32  // Output utilities.
33  //
34  func @dumpf64(%arg0: memref<?xf64>) {
35    %c0 = arith.constant 0 : index
36    %d0 = arith.constant -1.0 : f64
37    %0 = vector.transfer_read %arg0[%c0], %d0: memref<?xf64>, vector<25xf64>
38    vector.print %0 : vector<25xf64>
39    return
40  }
41  func @dumpidx(%arg0: memref<?xindex>) {
42    %c0 = arith.constant 0 : index
43    %d0 = arith.constant 0 : index
44    %0 = vector.transfer_read %arg0[%c0], %d0: memref<?xindex>, vector<25xindex>
45    vector.print %0 : vector<25xindex>
46    return
47  }
48
49  //
50  // Main driver.
51  //
52  func @entry() {
53    %c0 = arith.constant 0 : index
54    %c1 = arith.constant 1 : index
55    %c2 = arith.constant 2 : index
56
57    //
58    // Initialize a 3-dim dense tensor.
59    //
60    %t = arith.constant dense<[
61       [  [  1.0,  2.0,  3.0,  4.0 ],
62          [  5.0,  6.0,  7.0,  8.0 ],
63          [  9.0, 10.0, 11.0, 12.0 ] ],
64       [  [ 13.0, 14.0, 15.0, 16.0 ],
65          [ 17.0, 18.0, 19.0, 20.0 ],
66          [ 21.0, 22.0, 23.0, 24.0 ] ]
67    ]> : tensor<2x3x4xf64>
68
69    //
70    // Convert dense tensor directly to various sparse tensors.
71    //    tensor1: stored as 2x3x4
72    //    tensor2: stored as 3x4x2
73    //    tensor3: stored as 4x2x3
74    //
75    %1 = sparse_tensor.convert %t : tensor<2x3x4xf64> to tensor<2x3x4xf64, #Tensor1>
76    %2 = sparse_tensor.convert %t : tensor<2x3x4xf64> to tensor<2x3x4xf64, #Tensor2>
77    %3 = sparse_tensor.convert %t : tensor<2x3x4xf64> to tensor<2x3x4xf64, #Tensor3>
78
79    //
80    // Convert sparse tensor to various sparse tensors. Note that the result
81    // should always correspond to the direct conversion, since the sparse
82    // tensor formats have the ability to restore into the original ordering.
83    //
84    %a = sparse_tensor.convert %1 : tensor<2x3x4xf64, #Tensor1> to tensor<2x3x4xf64, #Tensor1>
85    %b = sparse_tensor.convert %2 : tensor<2x3x4xf64, #Tensor2> to tensor<2x3x4xf64, #Tensor1>
86    %c = sparse_tensor.convert %3 : tensor<2x3x4xf64, #Tensor3> to tensor<2x3x4xf64, #Tensor1>
87    %d = sparse_tensor.convert %1 : tensor<2x3x4xf64, #Tensor1> to tensor<2x3x4xf64, #Tensor2>
88    %e = sparse_tensor.convert %2 : tensor<2x3x4xf64, #Tensor2> to tensor<2x3x4xf64, #Tensor2>
89    %f = sparse_tensor.convert %3 : tensor<2x3x4xf64, #Tensor3> to tensor<2x3x4xf64, #Tensor2>
90    %g = sparse_tensor.convert %1 : tensor<2x3x4xf64, #Tensor1> to tensor<2x3x4xf64, #Tensor3>
91    %h = sparse_tensor.convert %2 : tensor<2x3x4xf64, #Tensor2> to tensor<2x3x4xf64, #Tensor3>
92    %i = sparse_tensor.convert %3 : tensor<2x3x4xf64, #Tensor3> to tensor<2x3x4xf64, #Tensor3>
93
94    //
95    // Check values.
96    //
97    // CHECK:      ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, -1 )
98    // CHECK-NEXT: ( 1, 13, 2, 14, 3, 15, 4, 16, 5, 17, 6, 18, 7, 19, 8, 20, 9, 21, 10, 22, 11, 23, 12, 24, -1 )
99    // CHECK-NEXT: ( 1, 5, 9, 13, 17, 21, 2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23, 4, 8, 12, 16, 20, 24, -1 )
100    // CHECK-NEXT: ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, -1 )
101    // CHECK-NEXT: ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, -1 )
102    // CHECK-NEXT: ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, -1 )
103    // CHECK-NEXT: ( 1, 13, 2, 14, 3, 15, 4, 16, 5, 17, 6, 18, 7, 19, 8, 20, 9, 21, 10, 22, 11, 23, 12, 24, -1 )
104    // CHECK-NEXT: ( 1, 13, 2, 14, 3, 15, 4, 16, 5, 17, 6, 18, 7, 19, 8, 20, 9, 21, 10, 22, 11, 23, 12, 24, -1 )
105    // CHECK-NEXT: ( 1, 13, 2, 14, 3, 15, 4, 16, 5, 17, 6, 18, 7, 19, 8, 20, 9, 21, 10, 22, 11, 23, 12, 24, -1 )
106    // CHECK-NEXT: ( 1, 5, 9, 13, 17, 21, 2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23, 4, 8, 12, 16, 20, 24, -1 )
107    // CHECK-NEXT: ( 1, 5, 9, 13, 17, 21, 2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23, 4, 8, 12, 16, 20, 24, -1 )
108    // CHECK-NEXT: ( 1, 5, 9, 13, 17, 21, 2, 6, 10, 14, 18, 22, 3, 7, 11, 15, 19, 23, 4, 8, 12, 16, 20, 24, -1 )
109    //
110    %v1 = sparse_tensor.values %1 : tensor<2x3x4xf64, #Tensor1> to memref<?xf64>
111    %v2 = sparse_tensor.values %2 : tensor<2x3x4xf64, #Tensor2> to memref<?xf64>
112    %v3 = sparse_tensor.values %3 : tensor<2x3x4xf64, #Tensor3> to memref<?xf64>
113    %av = sparse_tensor.values %a : tensor<2x3x4xf64, #Tensor1> to memref<?xf64>
114    %bv = sparse_tensor.values %b : tensor<2x3x4xf64, #Tensor1> to memref<?xf64>
115    %cv = sparse_tensor.values %c : tensor<2x3x4xf64, #Tensor1> to memref<?xf64>
116    %dv = sparse_tensor.values %d : tensor<2x3x4xf64, #Tensor2> to memref<?xf64>
117    %ev = sparse_tensor.values %e : tensor<2x3x4xf64, #Tensor2> to memref<?xf64>
118    %fv = sparse_tensor.values %f : tensor<2x3x4xf64, #Tensor2> to memref<?xf64>
119    %gv = sparse_tensor.values %g : tensor<2x3x4xf64, #Tensor3> to memref<?xf64>
120    %hv = sparse_tensor.values %h : tensor<2x3x4xf64, #Tensor3> to memref<?xf64>
121    %iv = sparse_tensor.values %i : tensor<2x3x4xf64, #Tensor3> to memref<?xf64>
122
123    call @dumpf64(%v1) : (memref<?xf64>) -> ()
124    call @dumpf64(%v2) : (memref<?xf64>) -> ()
125    call @dumpf64(%v3) : (memref<?xf64>) -> ()
126    call @dumpf64(%av) : (memref<?xf64>) -> ()
127    call @dumpf64(%bv) : (memref<?xf64>) -> ()
128    call @dumpf64(%cv) : (memref<?xf64>) -> ()
129    call @dumpf64(%dv) : (memref<?xf64>) -> ()
130    call @dumpf64(%ev) : (memref<?xf64>) -> ()
131    call @dumpf64(%fv) : (memref<?xf64>) -> ()
132    call @dumpf64(%gv) : (memref<?xf64>) -> ()
133    call @dumpf64(%hv) : (memref<?xf64>) -> ()
134    call @dumpf64(%iv) : (memref<?xf64>) -> ()
135
136    //
137    // Check indices.
138    //
139    // CHECK-NEXT: ( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
140    // CHECK-NEXT: ( 0, 1, 2, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
141    // CHECK-NEXT: ( 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0 )
142    // CHECK-NEXT: ( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
143    // CHECK-NEXT: ( 0, 1, 2, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
144    // CHECK-NEXT: ( 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0 )
145    // CHECK-NEXT: ( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
146    // CHECK-NEXT: ( 0, 1, 2, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
147    // CHECK-NEXT: ( 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0 )
148    // CHECK-NEXT: ( 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
149    // CHECK-NEXT: ( 0, 1, 2, 0, 1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, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0 )
172    // CHECK-NEXT: ( 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
173    // CHECK-NEXT: ( 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
174    // CHECK-NEXT: ( 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0 )
175    //
176    %v10 = sparse_tensor.indices %1, %c0 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
177    %v11 = sparse_tensor.indices %1, %c1 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
178    %v12 = sparse_tensor.indices %1, %c2 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
179    %v20 = sparse_tensor.indices %2, %c0 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
180    %v21 = sparse_tensor.indices %2, %c1 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
181    %v22 = sparse_tensor.indices %2, %c2 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
182    %v30 = sparse_tensor.indices %3, %c0 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
183    %v31 = sparse_tensor.indices %3, %c1 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
184    %v32 = sparse_tensor.indices %3, %c2 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
185
186    %a10 = sparse_tensor.indices %a, %c0 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
187    %a11 = sparse_tensor.indices %a, %c1 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
188    %a12 = sparse_tensor.indices %a, %c2 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
189    %b10 = sparse_tensor.indices %b, %c0 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
190    %b11 = sparse_tensor.indices %b, %c1 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
191    %b12 = sparse_tensor.indices %b, %c2 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
192    %c10 = sparse_tensor.indices %c, %c0 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
193    %c11 = sparse_tensor.indices %c, %c1 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
194    %c12 = sparse_tensor.indices %c, %c2 : tensor<2x3x4xf64, #Tensor1> to memref<?xindex>
195
196    %d20 = sparse_tensor.indices %d, %c0 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
197    %d21 = sparse_tensor.indices %d, %c1 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
198    %d22 = sparse_tensor.indices %d, %c2 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
199    %e20 = sparse_tensor.indices %e, %c0 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
200    %e21 = sparse_tensor.indices %e, %c1 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
201    %e22 = sparse_tensor.indices %e, %c2 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
202    %f20 = sparse_tensor.indices %f, %c0 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
203    %f21 = sparse_tensor.indices %f, %c1 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
204    %f22 = sparse_tensor.indices %f, %c2 : tensor<2x3x4xf64, #Tensor2> to memref<?xindex>
205
206    %g30 = sparse_tensor.indices %g, %c0 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
207    %g31 = sparse_tensor.indices %g, %c1 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
208    %g32 = sparse_tensor.indices %g, %c2 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
209    %h30 = sparse_tensor.indices %h, %c0 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
210    %h31 = sparse_tensor.indices %h, %c1 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
211    %h32 = sparse_tensor.indices %h, %c2 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
212    %i30 = sparse_tensor.indices %i, %c0 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
213    %i31 = sparse_tensor.indices %i, %c1 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
214    %i32 = sparse_tensor.indices %i, %c2 : tensor<2x3x4xf64, #Tensor3> to memref<?xindex>
215
216    call @dumpidx(%v10) : (memref<?xindex>) -> ()
217    call @dumpidx(%v11) : (memref<?xindex>) -> ()
218    call @dumpidx(%v12) : (memref<?xindex>) -> ()
219    call @dumpidx(%v10) : (memref<?xindex>) -> ()
220    call @dumpidx(%v11) : (memref<?xindex>) -> ()
221    call @dumpidx(%v12) : (memref<?xindex>) -> ()
222    call @dumpidx(%v10) : (memref<?xindex>) -> ()
223    call @dumpidx(%v11) : (memref<?xindex>) -> ()
224    call @dumpidx(%v12) : (memref<?xindex>) -> ()
225
226    call @dumpidx(%a10) : (memref<?xindex>) -> ()
227    call @dumpidx(%a11) : (memref<?xindex>) -> ()
228    call @dumpidx(%a12) : (memref<?xindex>) -> ()
229    call @dumpidx(%b10) : (memref<?xindex>) -> ()
230    call @dumpidx(%b11) : (memref<?xindex>) -> ()
231    call @dumpidx(%b12) : (memref<?xindex>) -> ()
232    call @dumpidx(%c10) : (memref<?xindex>) -> ()
233    call @dumpidx(%c11) : (memref<?xindex>) -> ()
234    call @dumpidx(%c12) : (memref<?xindex>) -> ()
235
236    call @dumpidx(%d20) : (memref<?xindex>) -> ()
237    call @dumpidx(%d21) : (memref<?xindex>) -> ()
238    call @dumpidx(%d22) : (memref<?xindex>) -> ()
239    call @dumpidx(%e20) : (memref<?xindex>) -> ()
240    call @dumpidx(%e21) : (memref<?xindex>) -> ()
241    call @dumpidx(%e22) : (memref<?xindex>) -> ()
242    call @dumpidx(%f20) : (memref<?xindex>) -> ()
243    call @dumpidx(%f21) : (memref<?xindex>) -> ()
244    call @dumpidx(%f22) : (memref<?xindex>) -> ()
245
246    call @dumpidx(%g30) : (memref<?xindex>) -> ()
247    call @dumpidx(%g31) : (memref<?xindex>) -> ()
248    call @dumpidx(%g32) : (memref<?xindex>) -> ()
249    call @dumpidx(%h30) : (memref<?xindex>) -> ()
250    call @dumpidx(%h31) : (memref<?xindex>) -> ()
251    call @dumpidx(%h32) : (memref<?xindex>) -> ()
252    call @dumpidx(%i30) : (memref<?xindex>) -> ()
253    call @dumpidx(%i31) : (memref<?xindex>) -> ()
254    call @dumpidx(%i32) : (memref<?xindex>) -> ()
255
256    // Release the resources.
257    sparse_tensor.release %1 : tensor<2x3x4xf64, #Tensor1>
258    sparse_tensor.release %2 : tensor<2x3x4xf64, #Tensor2>
259    sparse_tensor.release %3 : tensor<2x3x4xf64, #Tensor3>
260    sparse_tensor.release %b : tensor<2x3x4xf64, #Tensor1>
261    sparse_tensor.release %c : tensor<2x3x4xf64, #Tensor1>
262    sparse_tensor.release %d : tensor<2x3x4xf64, #Tensor2>
263    sparse_tensor.release %f : tensor<2x3x4xf64, #Tensor2>
264    sparse_tensor.release %g : tensor<2x3x4xf64, #Tensor3>
265    sparse_tensor.release %h : tensor<2x3x4xf64, #Tensor3>
266
267    return
268  }
269}
270