Skip to content

Commit f8d314f

Browse files
[mlir][Interfaces][NFC] Add TableGen test op for value bounds tests (llvm#88717)
This commit is a code cleanup. It defines the test ops the are used for the `ValueBoundsOpInterface` tests in TableGen, along with proper verifiers. --------- Co-authored-by: Benjamin Maxwell <[email protected]>
1 parent 55b6f17 commit f8d314f

File tree

11 files changed

+226
-216
lines changed

11 files changed

+226
-216
lines changed

mlir/test/Dialect/Affine/value-bounds-op-interface-impl.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func.func @composed_affine_apply(%i1 : index) -> (index) {
7474
%i2 = affine.apply affine_map<(d0) -> ((d0 floordiv 32) * 16)>(%i1)
7575
%i3 = affine.apply affine_map<(d0) -> ((d0 floordiv 32) * 16 + 8)>(%i1)
7676
%s = affine.apply affine_map<()[s0, s1] -> (s0 - s1)>()[%i2, %i3]
77-
%reified = "test.reify_constant_bound"(%s) {type = "EQ"} : (index) -> (index)
77+
%reified = "test.reify_bound"(%s) {type = "EQ", constant} : (index) -> (index)
7878
return %reified : index
7979
}
8080

mlir/test/Dialect/Affine/value-bounds-reification.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func.func @reify_slice_bound(%t: tensor<?x?xi32>, %idx: index, %ub: index, %f: f
4747
%bound = "test.reify_bound"(%filled) {dim = 1, type = "UB"} : (tensor<1x?xi32>) -> (index)
4848
"test.some_use"(%bound) : (index) -> ()
4949

50-
%bound_const = "test.reify_constant_bound"(%filled) {dim = 1, type = "UB"} : (tensor<1x?xi32>) -> (index)
50+
%bound_const = "test.reify_bound"(%filled) {dim = 1, type = "UB", constant} : (tensor<1x?xi32>) -> (index)
5151
"test.some_use"(%bound_const) : (index) -> ()
5252
}
5353
return
@@ -93,7 +93,7 @@ func.func @reify_slice_bound2(%lb0: index, %ub0: index, %step0: index,
9393

9494
// CHECK: %[[c129:.*]] = arith.constant 129 : index
9595
// CHECK: "test.some_use"(%[[c129]])
96-
%lb1_ub_const = "test.reify_constant_bound"(%lb1) {type = "UB"} : (index) -> (index)
96+
%lb1_ub_const = "test.reify_bound"(%lb1) {type = "UB", constant} : (index) -> (index)
9797
"test.some_use"(%lb1_ub_const) : (index) -> ()
9898

9999
scf.for %iv1 = %lb1 to %ub1 step %c32 {
@@ -116,7 +116,7 @@ func.func @reify_slice_bound2(%lb0: index, %ub0: index, %step0: index,
116116

117117
// CHECK: %[[c32:.*]] = arith.constant 32 : index
118118
// CHECK: "test.some_use"(%[[c32]])
119-
%matmul_ub_const = "test.reify_constant_bound"(%matmul) {dim = 1, type = "UB"} : (tensor<1x?xi32>) -> (index)
119+
%matmul_ub_const = "test.reify_bound"(%matmul) {dim = 1, type = "UB", constant} : (tensor<1x?xi32>) -> (index)
120120
"test.some_use"(%matmul_ub_const) : (index) -> ()
121121
}
122122
}

mlir/test/Dialect/Tensor/value-bounds-op-interface-impl.mlir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func.func @extract_slice_static(%t: tensor<?xf32>) -> index {
8383
func.func @extract_slice_dynamic_constant(%t: tensor<?xf32>, %sz: index) -> index {
8484
%0 = tensor.extract_slice %t[2][%sz][1] : tensor<?xf32> to tensor<?xf32>
8585
// expected-error @below{{could not reify bound}}
86-
%1 = "test.reify_constant_bound"(%0) {dim = 0} : (tensor<?xf32>) -> (index)
86+
%1 = "test.reify_bound"(%0) {dim = 0, constant} : (tensor<?xf32>) -> (index)
8787
return %1 : index
8888
}
8989

@@ -95,7 +95,7 @@ func.func @extract_slice_dynamic_constant(%t: tensor<?xf32>, %sz: index) -> inde
9595
// CHECK: return %[[c5]]
9696
func.func @extract_slice_static_constant(%t: tensor<?xf32>) -> index {
9797
%0 = tensor.extract_slice %t[2][5][1] : tensor<?xf32> to tensor<5xf32>
98-
%1 = "test.reify_constant_bound"(%0) {dim = 0} : (tensor<5xf32>) -> (index)
98+
%1 = "test.reify_bound"(%0) {dim = 0, constant} : (tensor<5xf32>) -> (index)
9999
return %1 : index
100100
}
101101

mlir/test/Dialect/Vector/test-scalable-bounds.mlir

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ func.func @fixed_size_loop_nest() {
2626
%min_i = affine.min #map_dim_i(%i)[%c4_vscale]
2727
scf.for %j = %c0 to %c16 step %c4_vscale {
2828
%min_j = affine.min #map_dim_j(%j)[%c4_vscale]
29-
%bound_i = "test.reify_scalable_bound"(%min_i) {type = "UB", vscale_min = 1, vscale_max = 16} : (index) -> index
30-
%bound_j = "test.reify_scalable_bound"(%min_j) {type = "UB", vscale_min = 1, vscale_max = 16} : (index) -> index
29+
%bound_i = "test.reify_bound"(%min_i) {type = "UB", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
30+
%bound_j = "test.reify_bound"(%min_j) {type = "UB", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
3131
"test.some_use"(%bound_i, %bound_j) : (index, index) -> ()
3232
}
3333
}
@@ -58,8 +58,8 @@ func.func @dynamic_size_loop_nest(%dim0: index, %dim1: index) {
5858
%min_i = affine.min #map_dynamic_dim(%i)[%c4_vscale, %dim0]
5959
scf.for %j = %c0 to %dim1 step %c4_vscale {
6060
%min_j = affine.min #map_dynamic_dim(%j)[%c4_vscale, %dim1]
61-
%bound_i = "test.reify_scalable_bound"(%min_i) {type = "UB", vscale_min = 1, vscale_max = 16} : (index) -> index
62-
%bound_j = "test.reify_scalable_bound"(%min_j) {type = "UB", vscale_min = 1, vscale_max = 16} : (index) -> index
61+
%bound_i = "test.reify_bound"(%min_i) {type = "UB", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
62+
%bound_j = "test.reify_bound"(%min_j) {type = "UB", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
6363
"test.some_use"(%bound_i, %bound_j) : (index, index) -> ()
6464
}
6565
}
@@ -80,7 +80,7 @@ func.func @add_to_vscale() {
8080
%vscale = vector.vscale
8181
%c8 = arith.constant 8 : index
8282
%vscale_plus_c8 = arith.addi %vscale, %c8 : index
83-
%bound = "test.reify_scalable_bound"(%vscale_plus_c8) {type = "EQ", vscale_min = 1, vscale_max = 16} : (index) -> index
83+
%bound = "test.reify_bound"(%vscale_plus_c8) {type = "EQ", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
8484
"test.some_use"(%bound) : (index) -> ()
8585
return
8686
}
@@ -94,7 +94,7 @@ func.func @add_to_vscale() {
9494
// CHECK: "test.some_use"(%[[C2]]) : (index) -> ()
9595
func.func @vscale_fixed_size() {
9696
%vscale = vector.vscale
97-
%bound = "test.reify_scalable_bound"(%vscale) {type = "EQ", vscale_min = 2, vscale_max = 2} : (index) -> index
97+
%bound = "test.reify_bound"(%vscale) {type = "EQ", vscale_min = 2, vscale_max = 2, scalable} : (index) -> index
9898
"test.some_use"(%bound) : (index) -> ()
9999
return
100100
}
@@ -107,7 +107,7 @@ func.func @unknown_bound(%a: index) {
107107
%vscale = vector.vscale
108108
%vscale_plus_a = arith.muli %vscale, %a : index
109109
// expected-error @below{{could not reify bound}}
110-
%bound = "test.reify_scalable_bound"(%vscale_plus_a) {type = "UB", vscale_min = 1, vscale_max = 16} : (index) -> index
110+
%bound = "test.reify_bound"(%vscale_plus_a) {type = "UB", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
111111
"test.some_use"(%bound) : (index) -> ()
112112
return
113113
}
@@ -134,7 +134,7 @@ func.func @duplicate_vscale_values() {
134134
%c2_vscale = arith.muli %vscale_1, %c2 : index
135135
%add = arith.addi %c2_vscale, %c4_vscale : index
136136

137-
%bound = "test.reify_scalable_bound"(%add) {type = "EQ", vscale_min = 1, vscale_max = 16} : (index) -> index
137+
%bound = "test.reify_bound"(%add) {type = "EQ", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
138138
"test.some_use"(%bound) : (index) -> ()
139139
return
140140
}
@@ -154,7 +154,7 @@ func.func @non_scalable_code() {
154154
%c0 = arith.constant 0 : index
155155
scf.for %i = %c0 to %c1024 step %c4 {
156156
%min_i = affine.min #map_dim_i(%i)[%c4]
157-
%bound_i = "test.reify_scalable_bound"(%min_i) {type = "UB", vscale_min = 1, vscale_max = 16} : (index) -> index
157+
%bound_i = "test.reify_bound"(%min_i) {type = "UB", vscale_min = 1, vscale_max = 16, scalable} : (index) -> index
158158
"test.some_use"(%bound_i) : (index) -> ()
159159
}
160160
return

mlir/test/lib/Dialect/Affine/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,13 @@ add_mlir_library(MLIRAffineTransformsTestPasses
3030
MLIRSupport
3131
MLIRMemRefDialect
3232
MLIRTensorDialect
33+
MLIRTestDialect
3334
MLIRVectorUtils
3435
)
36+
37+
target_include_directories(MLIRAffineTransformsTestPasses
38+
PRIVATE
39+
${CMAKE_CURRENT_SOURCE_DIR}/../Test
40+
${CMAKE_CURRENT_BINARY_DIR}/../Test
41+
)
42+

0 commit comments

Comments
 (0)