Skip to content

Commit 182dd49

Browse files
committed
Add a test with affine.if to make sure it doesn't get a symbol
1 parent 1b76b91 commit 182dd49

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: mlir-opt -canonicalize %s | FileCheck %s
2+
3+
// Check that linalg.index does not cause folding of affine.if set to
4+
// a symbolic set.
5+
6+
// CHECK: = affine_set<(d0) : (-d0 + 5 >= 0)>
7+
#set = affine_set<(d0) : (-d0 + 5 >= 0)>
8+
9+
func.func @linalg_index_affine_if(%in: tensor<10xf32>) -> tensor<10xf32> {
10+
%empty = tensor.empty() : tensor<10xf32>
11+
%out = linalg.generic {
12+
indexing_maps = [affine_map<(i) -> (i)>, affine_map<(i) -> (i)>],
13+
iterator_types = ["parallel"]}
14+
ins(%in : tensor<10xf32>)
15+
outs(%empty : tensor<10xf32>) {
16+
^bb0(%a: f32, %b: f32):
17+
%c42f = arith.constant 42.0 : f32
18+
%i = linalg.index 0 : index
19+
%ret = affine.if #set(%i) -> f32 {
20+
affine.yield %a : f32
21+
} else {
22+
affine.yield %c42f : f32
23+
}
24+
linalg.yield %ret : f32
25+
} -> tensor<10xf32>
26+
return %out : tensor<10xf32>
27+
}

0 commit comments

Comments
 (0)