Skip to content

Commit be791b7

Browse files
committed
fix invalid tests
1 parent 8a76339 commit be791b7

File tree

2 files changed

+103
-3
lines changed

2 files changed

+103
-3
lines changed

mlir/test/Dialect/Linalg/canonicalize.mlir

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,33 @@ func.func @cast_dest(%arg0: tensor<?x?x?xf32>, %arg1: tensor<1x?x?xf32>, %arg2:
649649

650650
// -----
651651

652+
#map = affine_map<(d0, d1) -> (d0, d1)>
653+
#sparse = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>
654+
// CHECK-DAG: #[[$SPARSE:.+]] = #sparse_tensor.encoding<{ map = (d0, d1) -> (d0 : dense, d1 : compressed) }>
655+
// CHECK-LABEL: func @static_shape_inference_with_encoding(
656+
// CHECK-SAME: %[[ARG0:[a-zA-Z0-9]+]]
657+
// CHECK-SAME: %[[ARG1:[a-zA-Z0-9]+]]
658+
func.func @static_shape_inference_with_encoding(%arg0: tensor<?x?xf32, #sparse>, %arg1: tensor<?x?xf32>) -> tensor<3x4xf32> {
659+
%0 = tensor.empty() : tensor<3x4xf32>
660+
%1 = linalg.generic {
661+
indexing_maps = [#map, #map, #map],
662+
iterator_types = ["parallel", "parallel"]
663+
} ins(%arg0, %arg1 : tensor<?x?xf32, #sparse>, tensor<?x?xf32>)
664+
outs(%0 : tensor<3x4xf32>) {
665+
^bb0(%in: f32, %in_0: f32, %out: f32):
666+
%2 = arith.addf %in, %in_0 : f32
667+
linalg.yield %2 : f32
668+
} -> tensor<3x4xf32>
669+
return %1 : tensor<3x4xf32>
670+
// CHECK: %[[CAST_ARG0:.*]] = tensor.cast %[[ARG0]] : tensor<?x?xf32, #[[$SPARSE]]> to tensor<3x4xf32, #[[$SPARSE]]>
671+
// CHECK-NEXT: %[[CAST_ARG1:.*]] = tensor.cast %[[ARG1]] : tensor<?x?xf32> to tensor<3x4xf32>
672+
// CHECK-NEXT: %[[GENERIC_OP:.*]] = linalg.generic
673+
// CHECK-SAME: ins(%[[CAST_ARG0]], %[[CAST_ARG1]] : tensor<3x4xf32, #[[$SPARSE]]>, tensor<3x4xf32>)
674+
// CHECK-SAME: outs({{.*}} : tensor<3x4xf32>)
675+
}
676+
677+
// -----
678+
652679
// CHECK: #[[$MAP:.+]] = affine_map<()[s0] -> (s0 + 1)>
653680
// CHECK-LABEL: func @insert_pad_into_fill
654681
// CHECK-SAME: (%[[INPUT:.+]]: tensor<?x?x?xf32>, %[[LOW0:.+]]: index, %[[LOW1:.+]]: index, %{{.+}}: index, %{{.+}}: index)
@@ -1730,8 +1757,13 @@ func.func @pack_dont_drop_attributes(%arg0: tensor<?x?x?xf16>, %arg1: tensor<128
17301757
%pack = linalg.pack %arg0 padding_value(%cst : f16) outer_dims_perm = [0, 1, 2] inner_dims_pos = [1, 2] inner_tiles = [16, 1] into %arg1 {test_attr} : tensor<?x?x?xf16> -> tensor<128x?x100x16x1xf16>
17311758
return %pack : tensor<128x?x100x16x1xf16>
17321759
}
1760+
17331761
// -----
17341762

1763+
//===----------------------------------------------------------------------===//
1764+
// linalg.unpack + tensor.extract_slice
1765+
1766+
17351767
//===----------------------------------------------------------------------===//
17361768
// linalg.fill + linalg.unpack
17371769
//===----------------------------------------------------------------------===//
@@ -1755,6 +1787,75 @@ func.func @fold_dst_style_ops_into_unpack(%arg0 : tensor<?x?x16x64xf32>, %init :
17551787
// tensor.cast + linalg.unpack
17561788
//===----------------------------------------------------------------------===//
17571789

1790+
func.func @fold_extract_slice_into_unpack(
1791+
%src : tensor<28x2x?x16x16xf32>, %dest : tensor<28x32x?xf32>, %size : index
1792+
) -> tensor<28x28x?xf32> {
1793+
%unpack = linalg.unpack %src
1794+
outer_dims_perm = [0, 1, 2]
1795+
inner_dims_pos = [1, 2]
1796+
inner_tiles = [16, 16]
1797+
into %dest : tensor<28x2x?x16x16xf32> -> tensor<28x32x?xf32>
1798+
%extracted_slice = tensor.extract_slice %unpack
1799+
[0, 0, 0] [28, 28, %size] [1, 1, 1] : tensor<28x32x?xf32> to tensor<28x28x?xf32>
1800+
return %extracted_slice : tensor<28x28x?xf32>
1801+
}
1802+
// CHECK-LABEL: func @fold_extract_slice_into_unpack
1803+
// CHECK-SAME: %[[SRC:.+]]: tensor<28x2x?x16x16xf32>
1804+
// CHECK-SAME: %[[DEST:.+]]: tensor<28x32x?xf32>
1805+
// CHECK-SAME: %[[SIZE:.+]]: index
1806+
// CHECK: %[[DEST_SLICE:.+]] = tensor.extract_slice %[[DEST]]
1807+
// CHECK-SAME: [0, 0, 0] [28, 28, %[[SIZE]]] [1, 1, 1]
1808+
// CHECK: %[[UNPACK:.+]] = linalg.unpack %[[SRC]]
1809+
// CHECK-SAME: into %[[DEST_SLICE]]
1810+
// CHECK: return %[[UNPACK]]
1811+
1812+
// -----
1813+
1814+
func.func @no_fold_extract_slice_into_unpack_rank_reducing(
1815+
%src : tensor<28x2x16xf32>, %dest : tensor<28x32xf32>
1816+
) -> tensor<28xf32> {
1817+
%unpack = linalg.unpack %src
1818+
outer_dims_perm = [0, 1]
1819+
inner_dims_pos = [1]
1820+
inner_tiles = [16]
1821+
into %dest : tensor<28x2x16xf32> -> tensor<28x32xf32>
1822+
%extracted_slice = tensor.extract_slice %unpack
1823+
[0, 0] [1, 28] [1, 1] : tensor<28x32xf32> to tensor<28xf32>
1824+
return %extracted_slice : tensor<28xf32>
1825+
}
1826+
1827+
// CHECK-LABEL: func @no_fold_extract_slice_into_unpack_rank_reducing
1828+
// CHECK-SAME: %[[SRC:.+]]: tensor<28x2x16xf32>
1829+
// CHECK-SAME: %[[DEST:.+]]: tensor<28x32xf32>
1830+
// CHECK: %[[UNPACK:.+]] = linalg.unpack %[[SRC]]
1831+
// CHECK-SAME: into %[[DEST]]
1832+
// CHECK: %[[SLICE:.+]] = tensor.extract_slice %[[UNPACK]]
1833+
// CHECK: return %[[SLICE]]
1834+
1835+
// -----
1836+
1837+
func.func @no_fold_extract_slice_into_unpack_non_zero_offset(
1838+
%src : tensor<28x2x16xf32>, %dest : tensor<28x32xf32>
1839+
) -> tensor<28x28xf32> {
1840+
%unpack = linalg.unpack %src
1841+
outer_dims_perm = [0, 1]
1842+
inner_dims_pos = [1]
1843+
inner_tiles = [16]
1844+
into %dest : tensor<28x2x16xf32> -> tensor<28x32xf32>
1845+
%extracted_slice = tensor.extract_slice %unpack
1846+
[0, 1] [28, 28] [1, 1] : tensor<28x32xf32> to tensor<28x28xf32>
1847+
return %extracted_slice : tensor<28x28xf32>
1848+
}
1849+
// CHECK-LABEL: func @no_fold_extract_slice_into_unpack_non_zero_offset
1850+
// CHECK-SAME: %[[SRC:.+]]: tensor<28x2x16xf32>
1851+
// CHECK-SAME: %[[DEST:.+]]: tensor<28x32xf32>
1852+
// CHECK: %[[UNPACK:.+]] = linalg.unpack %[[SRC]]
1853+
// CHECK-SAME: into %[[DEST]]
1854+
// CHECK: %[[SLICE:.+]] = tensor.extract_slice %[[UNPACK]]
1855+
// CHECK: return %[[SLICE]]
1856+
1857+
// -----
1858+
17581859
// CHECK-LABEL: func.func @fold_cast_unpack_dynamic_tile_size(
17591860
// CHECK-SAME: %[[SRC:.*]]: tensor<1x1x8x1xi32>,
17601861
// CHECK-SAME: %[[DEST:.*]]: tensor<7x?xi32>) -> tensor<7x?xi32> {

mlir/test/Dialect/Linalg/invalid.mlir

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,6 @@ func.func @pack_source_dest_type_mismatch_1(%source: tensor<128x256xf32>, %dest:
16761676
return
16771677
}
16781678

1679-
16801679
// -----
16811680

16821681
func.func @pack_source_dest_type_mismatch_2(%source: memref<128x256xf32>, %dest: tensor<8x16x8x32xf32>) {
@@ -1688,7 +1687,7 @@ func.func @pack_source_dest_type_mismatch_2(%source: memref<128x256xf32>, %dest:
16881687

16891688
// -----
16901689

1691-
func.func @unpack_source_dest_type_mismatch_1(%source: tensor<16x8x8x32xf32>, %dest: memref<128x256xf32>) {
1690+
func.func @unpack_source_dest_type_mismatch_3(%source: tensor<16x8x8x32xf32>, %dest: memref<128x256xf32>) {
16921691
// expected-error@+1 {{mixing tensor and buffer semantics is not allowed}}
16931692
linalg.unpack %source inner_dims_pos = [0, 1] inner_tiles = [8, 32]
16941693
into %dest : tensor<16x8x8x32xf32> -> memref<128x256xf32>
@@ -1697,7 +1696,7 @@ func.func @unpack_source_dest_type_mismatch_1(%source: tensor<16x8x8x32xf32>, %d
16971696

16981697
// -----
16991698

1700-
func.func @unpack_source_dest_type_mismatch_1(%source: memref<16x8x8x32xf32>, %dest: tensor<128x256xf32>) {
1699+
func.func @unpack_source_dest_type_mismatch_4(%source: memref<16x8x8x32xf32>, %dest: tensor<128x256xf32>) {
17011700
// expected-error@+1 {{mixing tensor and buffer semantics is not allowed}}
17021701
%0 = linalg.unpack %source inner_dims_pos = [0, 1] inner_tiles = [8, 32]
17031702
into %dest : memref<16x8x8x32xf32> -> tensor<128x256xf32>

0 commit comments

Comments
 (0)