@@ -1142,3 +1142,186 @@ func.func @winograd_output_transform_output_width(%arg0: tensor<6x6x3x3x2x2xf32>
1142
1142
%0 = linalg.winograd_output_transform m (4 ) r (3 ) ins (%arg0 : tensor <6 x6 x3 x3 x2 x2 xf32 >) outs (%arg1 : tensor <2 x12 x11 x2 xf32 >) -> tensor <2 x12 x11 x2 xf32 >
1143
1143
return %0 : tensor <2 x12 x11 x2 xf32 >
1144
1144
}
1145
+
1146
+ // -----
1147
+
1148
+ //===----------------------------------------------------------------------===//
1149
+ // linalg.pack
1150
+ //===----------------------------------------------------------------------===//
1151
+
1152
+ func.func @pack_invalid_no_padding_no_full_tiles (%input: tensor <256 x128 xf32 >, %output: tensor <8 x8 x16 x33 xf32 >) -> tensor <8 x8 x16 x33 xf32 > {
1153
+ // expected-error@+1 {{invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set}}
1154
+ %0 = linalg.pack %input inner_dims_pos = [1 , 0 ] inner_tiles = [16 , 33 ] into %output : tensor <256 x128 xf32 > -> tensor <8 x8 x16 x33 xf32 >
1155
+ return %0 : tensor <8 x8 x16 x33 xf32 >
1156
+ }
1157
+
1158
+ // -----
1159
+
1160
+ func.func @pack_invalid_no_padding_no_full_tiles_dyn_tiles (%input: tensor <256 x128 xf32 >, %output: tensor <10 x8 x?x?xf32 >, %tile_size_0: index , %tile_size_1: index ) -> tensor <10 x8 x?x?xf32 > {
1161
+ // expected-error@+1 {{invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set}}
1162
+ %0 = linalg.pack %input inner_dims_pos = [1 , 0 ] inner_tiles = [%tile_size_0 , %tile_size_1 ] into %output : tensor <256 x128 xf32 > -> tensor <10 x8 x?x?xf32 >
1163
+ return %0 : tensor <10 x8 x?x?xf32 >
1164
+ }
1165
+
1166
+ // -----
1167
+
1168
+ func.func @pack_invalid_no_padding_no_full_tiles_dyn_tiles_outperm (%input: tensor <256 x128 xf32 >, %output: tensor <8 x10 x?x?xf32 >, %tile_size_0: index , %tile_size_1: index ) -> tensor <8 x10 x?x?xf32 > {
1169
+ // expected-error@+1 {{invalid tile factor or output size provided. Only full tiles are supported when padding_value is not set}}
1170
+ %0 = linalg.pack %input outer_dims_perm = [1 , 0 ] inner_dims_pos = [1 , 0 ] inner_tiles = [%tile_size_0 , %tile_size_1 ] into %output : tensor <256 x128 xf32 > -> tensor <8 x10 x?x?xf32 >
1171
+ return %0 : tensor <8 x10 x?x?xf32 >
1172
+ }
1173
+
1174
+ // -----
1175
+
1176
+ func.func @pad_and_pack_invalid_type (%input: tensor <13 x15 xf32 >, %output: tensor <2 x8 x8 x2 xf32 >, %pad: i32 ) -> tensor <2 x8 x8 x2 xf32 > {
1177
+ // expected-error@+1 {{expected padding_value has 'f32' but got: 'i32'}}
1178
+ %0 = linalg.pack %input padding_value (%pad: i32 ) inner_dims_pos = [0 , 1 ] inner_tiles = [8 , 2 ] into %output : tensor <13 x15 xf32 > -> tensor <2 x8 x8 x2 xf32 >
1179
+ return %0 : tensor <2 x8 x8 x2 xf32 >
1180
+ }
1181
+
1182
+ // -----
1183
+
1184
+ func.func @pack_invalid_inner_dims_pos_vector (%input: tensor <256 x128 xf32 >, %output: tensor <8 x8 x32 x16 xf32 >) -> tensor <8 x8 x32 x16 xf32 > {
1185
+ // expected-error@+1 {{invalid inner_dims_pos vector}}
1186
+ %0 = linalg.pack %input inner_dims_pos = [2 , 0 ] inner_tiles = [2 , 2 ] into %output : tensor <256 x128 xf32 > -> tensor <8 x8 x32 x16 xf32 >
1187
+ return %0 : tensor <8 x8 x32 x16 xf32 >
1188
+ }
1189
+
1190
+ // -----
1191
+
1192
+ func.func @pack_invalid_duplicate_element_in_inner_dims (%input: tensor <256 x128 xf32 >, %output: tensor <8 x8 x32 x16 xf32 >) -> tensor <8 x8 x32 x16 xf32 > {
1193
+ // expected-error@+1 {{invalid inner_dims_pos vector}}
1194
+ %0 = linalg.pack %input inner_dims_pos = [1 , 1 ] inner_tiles = [2 , 2 ] into %output : tensor <256 x128 xf32 > -> tensor <8 x8 x32 x16 xf32 >
1195
+ return %0 : tensor <8 x8 x32 x16 xf32 >
1196
+ }
1197
+
1198
+ // -----
1199
+
1200
+ func.func @pack_invalid_duplicate_element_in_outer_perm (%input: tensor <256 x128 xf32 >, %output: tensor <8 x8 x32 x16 xf32 >) -> tensor <8 x8 x32 x16 xf32 > {
1201
+ // expected-error@+1 {{invalid outer_dims_perm vector}}
1202
+ %0 = linalg.pack %input outer_dims_perm = [1 , 1 ] inner_dims_pos = [0 , 1 ] inner_tiles = [2 , 2 ] into %output : tensor <256 x128 xf32 > -> tensor <8 x8 x32 x16 xf32 >
1203
+ return %0 : tensor <8 x8 x32 x16 xf32 >
1204
+ }
1205
+
1206
+ // -----
1207
+
1208
+ func.func @pack_invalid_output_rank (%input: tensor <256 x128 xf32 >, %output: tensor <64 x32 x16 xf32 >) -> tensor <64 x32 x16 xf32 > {
1209
+ // expected-error@+1 {{packed rank != (unpacked rank + num tiling factors), got 3 != 4}}
1210
+ %0 = linalg.pack %input inner_dims_pos = [0 , 1 ] inner_tiles = [32 , 16 ] into %output : tensor <256 x128 xf32 > -> tensor <64 x32 x16 xf32 >
1211
+ return %0 : tensor <64 x32 x16 xf32 >
1212
+ }
1213
+
1214
+ // -----
1215
+
1216
+ //===----------------------------------------------------------------------===//
1217
+ // linalg.unpack
1218
+ //===----------------------------------------------------------------------===//
1219
+
1220
+ func.func @unpack_invalid_output_rank (%input: tensor <256 x128 xf32 >, %output: tensor <64 x32 x16 xf32 >) -> tensor <256 x128 xf32 > {
1221
+ // expected-error@+1 {{packed rank != (unpacked rank + num tiling factors), got 3 != 4}}
1222
+ %0 = linalg.unpack %output inner_dims_pos = [0 , 1 ] inner_tiles = [32 , 16 ] into %input : tensor <64 x32 x16 xf32 > -> tensor <256 x128 xf32 >
1223
+ return %0 : tensor <256 x128 xf32 >
1224
+ }
1225
+
1226
+ // -----
1227
+
1228
+ func.func @unpack_invalid_out_of_bound_outer_perm (%input: tensor <256 x128 xf32 >, %output: tensor <8 x8 x32 x16 xf32 >) -> tensor <8 x8 x32 x16 xf32 > {
1229
+ // expected-error@+1 {{invalid outer_dims_perm vector}}
1230
+ %0 = linalg.unpack %output outer_dims_perm = [2 , 1 ] inner_dims_pos = [0 , 1 ] inner_tiles = [2 , 2 ] into %input : tensor <8 x8 x32 x16 xf32 > -> tensor <256 x128 xf32 >
1231
+ return %0 : tensor <256 x128 xf32 >
1232
+ }
1233
+
1234
+ // -----
1235
+
1236
+ func.func @pack_invalid_outer_dims_perm (%source: tensor <128 x256 xf32 >, %dest: tensor <16 x4 x32 x16 xf32 >) -> tensor <16 x4 x32 x16 xf32 > {
1237
+ // expected-error@+1 {{outer_dims_perm must be a permutation or empty}}
1238
+ %0 = linalg.pack %source outer_dims_perm = [0 ] inner_dims_pos = [0 , 1 ] inner_tiles = [32 , 16 ] into %dest : tensor <128 x256 xf32 > -> tensor <16 x4 x32 x16 xf32 >
1239
+ return %0 : tensor <16 x4 x32 x16 xf32 >
1240
+ }
1241
+
1242
+ // -----
1243
+
1244
+ func.func @unpack_invalid_outer_dims_perm (%source: tensor <128 x256 xf32 >, %dest: tensor <16 x4 x32 x16 xf32 >) -> tensor <128 x256 xf32 > {
1245
+ // expected-error@+1 {{outer_dims_perm must be a permutation or empty}}
1246
+ %0 = linalg.unpack %dest outer_dims_perm = [1 ] inner_dims_pos = [0 , 1 ] inner_tiles = [32 , 16 ] into %source : tensor <16 x4 x32 x16 xf32 > -> tensor <128 x256 xf32 >
1247
+ return %0 : tensor <128 x256 xf32 >
1248
+ }
1249
+
1250
+ // -----
1251
+
1252
+ func.func @pack_invalid (%input: tensor <256 x128 xf32 >, %output: tensor <8 x8 x32 x16 xf32 >) -> tensor <8 x8 x32 x16 xf32 > {
1253
+ // expected-error@+1 {{the shape of output is not large enough to hold the packed data. Expected at least 'tensor<8x8x16x32xf32>', got 'tensor<8x8x32x16xf32>'}}
1254
+ %0 = linalg.pack %input inner_dims_pos = [1 , 0 ] inner_tiles = [16 , 32 ] into %output : tensor <256 x128 xf32 > -> tensor <8 x8 x32 x16 xf32 >
1255
+ return %0 : tensor <8 x8 x32 x16 xf32 >
1256
+ }
1257
+
1258
+ // -----
1259
+
1260
+ func.func @unpack_invalid (%output: tensor <256 x128 xf32 >, %input: tensor <8 x8 x32 x16 xf32 >) -> tensor <256 x128 xf32 > {
1261
+ // expected-error@+1 {{the shape of output is not large enough to hold the packed data. Expected at least 'tensor<8x32x4x32xf32>', got 'tensor<8x8x32x16xf32>'}}
1262
+ %0 = linalg.unpack %input inner_dims_pos = [1 , 0 ] inner_tiles = [4 , 32 ] into %output : tensor <8 x8 x32 x16 xf32 > -> tensor <256 x128 xf32 >
1263
+ return %0 : tensor <256 x128 xf32 >
1264
+ }
1265
+
1266
+ // -----
1267
+
1268
+ func.func @pack_invalid (%input: tensor <256 x128 xf32 >, %output: tensor <8 x8 x32 x16 xf32 >) -> tensor <8 x8 x32 x16 xf32 > {
1269
+ // expected-error@+1 {{invalid zero tile factor}}
1270
+ %0 = linalg.pack %input inner_dims_pos = [1 , 0 ] inner_tiles = [0 , 2 ] into %output : tensor <256 x128 xf32 > -> tensor <8 x8 x32 x16 xf32 >
1271
+ return %0 : tensor <8 x8 x32 x16 xf32 >
1272
+ }
1273
+
1274
+ // -----
1275
+ func.func @pack_mismatch_inner_tile_size_and_output_shape (
1276
+ %input : tensor <?x?xf32 >, %output : tensor <?x?x8 x8 xf32 >) -> tensor <?x?x8 x8 xf32 > {
1277
+ // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}
1278
+ %0 = linalg.pack %input inner_dims_pos = [0 , 1 ] inner_tiles = [8 , 4 ] into %output : tensor <?x?xf32 > -> tensor <?x?x8 x8 xf32 >
1279
+ return %0 : tensor <?x?x8 x8 xf32 >
1280
+ }
1281
+
1282
+ // -----
1283
+
1284
+ func.func @pack_dynamic_inner_tile_size_and_static_output_shape (
1285
+ %input : tensor <?x?xf32 >, %output : tensor <?x?x8 x8 xf32 >) -> tensor <?x?x8 x8 xf32 > {
1286
+ %c8 = arith.constant 8 : index
1287
+ // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}
1288
+ %0 = linalg.pack %input inner_dims_pos = [0 , 1 ] inner_tiles = [8 , %c8 ] into %output : tensor <?x?xf32 > -> tensor <?x?x8 x8 xf32 >
1289
+ return %0 : tensor <?x?x8 x8 xf32 >
1290
+ }
1291
+
1292
+ // -----
1293
+
1294
+ func.func @pack_static_inner_tile_size_and_dynamic_output_shape (
1295
+ %input : tensor <?x?xf32 >, %output : tensor <?x?x8 x?xf32 >) -> tensor <?x?x8 x?xf32 > {
1296
+ // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}
1297
+ %0 = linalg.pack %input inner_dims_pos = [0 , 1 ] inner_tiles = [8 , 8 ] into %output : tensor <?x?xf32 > -> tensor <?x?x8 x?xf32 >
1298
+ return %0 : tensor <?x?x8 x?xf32 >
1299
+ }
1300
+
1301
+ // -----
1302
+
1303
+ func.func @unpack_mismatch_inner_tile_size_and_output_shape (
1304
+ %input : tensor <?x?x8 x8 xf32 >, %output : tensor <?x?xf32 >) -> tensor <?x?xf32 > {
1305
+ // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}
1306
+ %0 = linalg.unpack %input inner_dims_pos = [0 , 1 ] inner_tiles = [8 , 4 ] into %output : tensor <?x?x8 x8 xf32 > -> tensor <?x?xf32 >
1307
+ return %0 : tensor <?x?xf32 >
1308
+ }
1309
+
1310
+ // -----
1311
+
1312
+ func.func @unpack_dynamic_inner_tile_size_and_static_output_shape (
1313
+ %input : tensor <?x?x8 x4 xf32 >, %output : tensor <?x?xf32 >) -> tensor <?x?xf32 > {
1314
+ %c8 = arith.constant 8 : index
1315
+ // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}
1316
+ %0 = linalg.unpack %input inner_dims_pos = [0 , 1 ] inner_tiles = [%c8 , 4 ] into %output : tensor <?x?x8 x4 xf32 > -> tensor <?x?xf32 >
1317
+ return %0 : tensor <?x?xf32 >
1318
+ }
1319
+
1320
+ // -----
1321
+
1322
+ func.func @unpack_static_inner_tile_size_and_dynamic_output_shape (
1323
+ %input : tensor <?x?x?x4 xf32 >, %output : tensor <?x?xf32 >) -> tensor <?x?xf32 > {
1324
+ // expected-error@+1 {{mismatch in inner tile sizes specified and shaped of tiled dimension in the packed type}}
1325
+ %0 = linalg.unpack %input inner_dims_pos = [0 , 1 ] inner_tiles = [8 , 4 ] into %output : tensor <?x?x?x4 xf32 > -> tensor <?x?xf32 >
1326
+ return %0 : tensor <?x?xf32 >
1327
+ }
0 commit comments