File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -2224,6 +2224,14 @@ LogicalResult ExpandShapeOp::verify() {
2224
2224
MemRefType srcType = getSrcType ();
2225
2225
MemRefType resultType = getResultType ();
2226
2226
2227
+ if (srcType.getRank () > resultType.getRank ()) {
2228
+ auto r0 = srcType.getRank ();
2229
+ auto r1 = resultType.getRank ();
2230
+ return emitOpError (" has source rank " )
2231
+ << r0 << " and result rank " << r1 << " . This is not an expansion ("
2232
+ << r0 << " > " << r1 << " )." ;
2233
+ }
2234
+
2227
2235
// Verify result shape.
2228
2236
if (failed (verifyCollapsedShape (getOperation (), srcType.getShape (),
2229
2237
resultType.getShape (),
@@ -2374,6 +2382,14 @@ LogicalResult CollapseShapeOp::verify() {
2374
2382
MemRefType srcType = getSrcType ();
2375
2383
MemRefType resultType = getResultType ();
2376
2384
2385
+ if (srcType.getRank () < resultType.getRank ()) {
2386
+ auto r0 = srcType.getRank ();
2387
+ auto r1 = resultType.getRank ();
2388
+ return emitOpError (" has source rank " )
2389
+ << r0 << " and result rank " << r1 << " . This is not a collapse ("
2390
+ << r0 << " < " << r1 << " )." ;
2391
+ }
2392
+
2377
2393
// Verify result shape.
2378
2394
if (failed (verifyCollapsedShape (getOperation (), resultType.getShape (),
2379
2395
srcType.getShape (), getReassociationIndices (),
Original file line number Diff line number Diff line change @@ -451,7 +451,7 @@ func.func @collapse_shape_invalid_reassociation(%arg0: memref<?x?x?xf32>) {
451
451
// An (invalid) attempt at using collapse_shape to increase the rank might look
452
452
// like this. Verify that a sensible error is emitted in this case.
453
453
func.func @collapse_shape_invalid_reassociation_expansion (%arg0: memref <?xf32 >) {
454
- // expected-error @+1 {{reassociation indices must be contiguous }}
454
+ // expected-error @+1 {{'memref.collapse_shape' op has source rank 1 and result rank 2. This is not a collapse (1 < 2) }}
455
455
%0 = memref.collapse_shape %arg0 [[0 ], [0 ]] :
456
456
memref <?xf32 > into memref <?x?xf32 >
457
457
}
@@ -461,7 +461,7 @@ func.func @collapse_shape_invalid_reassociation_expansion(%arg0: memref<?xf32>)
461
461
// An (invalid) attempt at using expand_shape to reduce the rank might look
462
462
// like this. Verify that a sensible error is emitted in this case.
463
463
func.func @expand_shape_invalid_reassociation (%arg0: memref <2 x3 x1 xf32 >) {
464
- // expected-error @+1 {{reassociation indices must be contiguous }}
464
+ // expected-error @+1 {{'memref.expand_shape' op has source rank 3 and result rank 2. This is not an expansion (3 > 2) }}
465
465
%0 = memref.expand_shape %arg0 [[0 ], [1 ], [1 ]] :
466
466
memref <2 x3 x1 xf32 > into memref <2 x3 xf32 >
467
467
}
You can’t perform that action at this time.
0 commit comments