35
35
#COO_3D = #sparse_tensor.encoding <{ map = (d0 , d1 , d2 ) -> (d0 : compressed(nonunique), d1 : singleton(nonunique), d2 : singleton), posWidth = 32 , crdWidth = 32 }>
36
36
37
37
module {
38
- func.func private @printMemref3dF32 (%ptr : tensor <?x?x?xf32 >) attributes { llvm.emit_c_interface }
39
- func.func private @printMemref2dF32 (%ptr : tensor <?x?xf32 >) attributes { llvm.emit_c_interface }
38
+ func.func private @printMemref3dF32 (%ptr : tensor <?x?x?xf32 > { bufferization.access = " read " } ) attributes { llvm.emit_c_interface }
39
+ func.func private @printMemref2dF32 (%ptr : tensor <?x?xf32 > { bufferization.access = " read " } ) attributes { llvm.emit_c_interface }
40
40
41
41
func.func @test_sparse_rhs (%arg0: tensor <5 x6 xf32 >, %arg1: tensor <6 x2 x3 xf32 , #COO_3D >) -> tensor <?x?x?xf32 > {
42
42
%collapsed = tensor.collapse_shape %arg1 [[0 ], [1 , 2 ]] : tensor <6 x2 x3 xf32 , #COO_3D > into tensor <6 x6 xf32 , #COO_2D >
@@ -46,6 +46,11 @@ module {
46
46
%2 = linalg.matmul ins (%arg0 , %collapsed : tensor <5 x6 xf32 >, tensor <6 x6 xf32 , #COO_2D >) outs (%1 : tensor <5 x6 xf32 >) -> tensor <5 x6 xf32 >
47
47
%expanded = tensor.expand_shape %2 [[0 ], [1 , 2 ]] : tensor <5 x6 xf32 > into tensor <5 x2 x3 xf32 >
48
48
%ret1 = tensor.cast %expanded : tensor <5 x2 x3 xf32 > to tensor <?x?x?xf32 >
49
+
50
+ // Note: tensor.collapse_shape is a metadata-only operation on dense tensors
51
+ // but requires reallocation on sparse tensors.
52
+ bufferization.dealloc_tensor %collapsed : tensor <6 x6 xf32 , #COO_2D >
53
+
49
54
return %ret1 : tensor <?x?x?xf32 >
50
55
}
51
56
@@ -57,6 +62,11 @@ module {
57
62
%2 = linalg.matmul ins (%arg0 , %collapsed : tensor <5 x6 xf32 , #COO_2D >, tensor <6 x6 xf32 , #COO_2D >) outs (%1 : tensor <5 x6 xf32 >) -> tensor <5 x6 xf32 >
58
63
%expanded = tensor.expand_shape %2 [[0 ], [1 , 2 ]] : tensor <5 x6 xf32 > into tensor <5 x2 x3 xf32 >
59
64
%ret1 = tensor.cast %expanded : tensor <5 x2 x3 xf32 > to tensor <?x?x?xf32 >
65
+
66
+ // Note: tensor.collapse_shape is a metadata-only operation on dense tensors
67
+ // but requires reallocation on sparse tensors.
68
+ bufferization.dealloc_tensor %collapsed : tensor <6 x6 xf32 , #COO_2D >
69
+
60
70
return %ret1 : tensor <?x?x?xf32 >
61
71
}
62
72
@@ -80,6 +90,11 @@ module {
80
90
%2 = linalg.matmul ins (%arg0 , %collapsed : tensor <5 x6 xf32 , #COO_2D >, tensor <6 x6 xf32 , #COO_2D >) outs (%1 : tensor <5 x6 xf32 >) -> tensor <5 x6 xf32 >
81
91
%expanded = tensor.expand_shape %2 [[0 ], [1 , 2 ]] : tensor <5 x6 xf32 > into tensor <5 x2 x3 xf32 >
82
92
%ret1 = tensor.cast %expanded : tensor <5 x2 x3 xf32 > to tensor <?x?x?xf32 >
93
+
94
+ // Note: tensor.collapse_shape is a metadata-only operation on dense tensors
95
+ // but requires reallocation on sparse tensors.
96
+ bufferization.dealloc_tensor %collapsed : tensor <6 x6 xf32 , #COO_2D >
97
+
83
98
return %ret1 : tensor <?x?x?xf32 >
84
99
}
85
100
@@ -192,6 +207,7 @@ module {
192
207
bufferization.dealloc_tensor %so1 : tensor <?x?x?xf32 >
193
208
bufferization.dealloc_tensor %so2 : tensor <?x?x?xf32 >
194
209
bufferization.dealloc_tensor %so3 : tensor <?x?x?xf32 >
210
+
195
211
return
196
212
}
197
213
}
0 commit comments