Skip to content

Commit 66acd04

Browse files
authored
[MemRef] Fix value bounds interface for ExpandShapeOp (llvm#165333)
We shouldn't just consider the dynamic dimensions, but all output dimensions for the value bounds constraints. The previous test just worked because the dynamic dimension was on the first position.
1 parent 31417ba commit 66acd04

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

mlir/lib/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct ExpandShapeOpInterface
6666
ValueBoundsConstraintSet &cstr) const {
6767
auto expandOp = cast<memref::ExpandShapeOp>(op);
6868
assert(value == expandOp.getResult() && "invalid value");
69-
cstr.bound(value)[dim] == expandOp.getOutputShape()[dim];
69+
cstr.bound(value)[dim] == expandOp.getMixedOutputShape()[dim];
7070
}
7171
};
7272

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ func.func @memref_dim_all_positive(%m: memref<?xf32>, %x: index) {
6767
// CHECK-SAME: %[[m:[a-zA-Z0-9]+]]: memref<?xf32>
6868
// CHECK-SAME: %[[sz:[a-zA-Z0-9]+]]: index
6969
// CHECK: %[[c4:.*]] = arith.constant 4 : index
70-
// CHECK: return %[[sz]], %[[c4]]
70+
// CHECK: return %[[c4]], %[[sz]]
7171
func.func @memref_expand(%m: memref<?xf32>, %sz: index) -> (index, index) {
72-
%0 = memref.expand_shape %m [[0, 1]] output_shape [%sz, 4]: memref<?xf32> into memref<?x4xf32>
73-
%1 = "test.reify_bound"(%0) {dim = 0} : (memref<?x4xf32>) -> (index)
74-
%2 = "test.reify_bound"(%0) {dim = 1} : (memref<?x4xf32>) -> (index)
72+
%0 = memref.expand_shape %m [[0, 1]] output_shape [4, %sz]: memref<?xf32> into memref<4x?xf32>
73+
%1 = "test.reify_bound"(%0) {dim = 0} : (memref<4x?xf32>) -> (index)
74+
%2 = "test.reify_bound"(%0) {dim = 1} : (memref<4x?xf32>) -> (index)
7575
return %1, %2 : index, index
7676
}
7777

0 commit comments

Comments
 (0)