mirror of
https://github.com/intel/llvm.git
synced 2026-01-23 07:58:23 +08:00
[mlir][tensor/memref] Disallow Collapse/ExpandShapeOps that do not reduce/increase the rank
CollapseShapeOp/ExpandShapeOp that do not change the rank (or increase/reduce it) are invalid. Differential Revision: https://reviews.llvm.org/D138498
This commit is contained in:
@@ -1398,10 +1398,22 @@ static LogicalResult verifyTensorReshapeOp(TensorReshapeOp op,
|
||||
}
|
||||
|
||||
LogicalResult ExpandShapeOp::verify() {
|
||||
auto srcType = getSrcType();
|
||||
auto resultType = getResultType();
|
||||
if (srcType.getRank() >= resultType.getRank())
|
||||
return emitOpError("expected rank expansion, but found source rank ")
|
||||
<< srcType.getRank() << " >= result rank " << resultType.getRank();
|
||||
|
||||
return verifyTensorReshapeOp(*this, getResultType(), getSrcType());
|
||||
}
|
||||
|
||||
LogicalResult CollapseShapeOp::verify() {
|
||||
auto srcType = getSrcType();
|
||||
auto resultType = getResultType();
|
||||
if (srcType.getRank() <= resultType.getRank())
|
||||
return emitOpError("expected rank reduction, but found source rank ")
|
||||
<< srcType.getRank() << " <= result rank " << resultType.getRank();
|
||||
|
||||
return verifyTensorReshapeOp(*this, getSrcType(), getResultType());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user