Skip to content

Commit e299d4a

Browse files
committed
[mlir][nfc] Add a negative test for --linalg-specialize-generic-ops
Following on from llvm#126737, adds a negative test that: * prior to llvm#126737, would incorrectly generated empty output, * with the fix in-tree, simply outputs the input IR (i.e. the specialization "fails"). I've also made minor editorial changes.
1 parent 0d2722c commit e299d4a

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

mlir/test/Dialect/Linalg/specialize-generic-ops-fail.mlir

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,26 @@
66
// CHECK-LABEL: @transpose_and_broadcast
77
// CHECK: linalg.generic
88
func.func @transpose_and_broadcast(%arg0: tensor<7x8xf32>, %arg1: tensor<8x7x9xf32>) -> tensor<8x7x9xf32> {
9-
%0 = linalg.generic
10-
{indexing_maps = [#map, #map1], iterator_types = ["parallel", "parallel", "parallel"]}
11-
ins(%arg0 : tensor<7x8xf32>) outs(%arg1 : tensor<8x7x9xf32>) {
12-
^bb0(%in: f32, %out: f32):
13-
linalg.yield %in : f32
9+
%res = linalg.generic {
10+
indexing_maps = [#map, #map1], iterator_types = ["parallel", "parallel", "parallel"]
11+
} ins(%arg0 : tensor<7x8xf32>) outs(%arg1 : tensor<8x7x9xf32>) {
12+
^bb0(%in: f32, %out: f32):
13+
linalg.yield %in : f32
1414
} -> tensor<8x7x9xf32>
15-
return %0 : tensor<8x7x9xf32>
15+
return %res : tensor<8x7x9xf32>
16+
}
17+
18+
// -----
19+
20+
#map = affine_map<(d0) -> (d0)>
21+
// CHECK-LABEL: @neither_permutation_nor_broadcast
22+
// CHECK: linalg.generic
23+
func.func @neither_permutation_nor_broadcast(%init : tensor<8xi32>) -> tensor<8xi32> {
24+
%res = linalg.generic {
25+
indexing_maps = [#map], iterator_types = ["parallel"]
26+
} outs(%init: tensor<8xi32>) {
27+
^bb0(%out: i32):
28+
linalg.yield %out: i32
29+
} -> tensor<8xi32>
30+
return %res : tensor<8xi32>
1631
}

0 commit comments

Comments
 (0)