Add verification error message for ops that require at least one operand or result.
PiperOrigin-RevId: 272153634
This commit is contained in:
parent
de2b75069b
commit
a40bd3f49c
third_party/mlir
13
third_party/mlir/lib/IR/Operation.cpp
vendored
13
third_party/mlir/lib/IR/Operation.cpp
vendored
@ -767,7 +767,7 @@ static LogicalResult verifyShapeMatch(Type type1, Type type2) {
|
||||
}
|
||||
|
||||
LogicalResult OpTrait::impl::verifySameOperandsShape(Operation *op) {
|
||||
if (op->getNumOperands() == 0)
|
||||
if (failed(verifyAtLeastNOperands(op, 1)))
|
||||
return failure();
|
||||
|
||||
auto type = op->getOperand(0)->getType();
|
||||
@ -779,7 +779,8 @@ LogicalResult OpTrait::impl::verifySameOperandsShape(Operation *op) {
|
||||
}
|
||||
|
||||
LogicalResult OpTrait::impl::verifySameOperandsAndResultShape(Operation *op) {
|
||||
if (op->getNumOperands() == 0 || op->getNumResults() == 0)
|
||||
if (failed(verifyAtLeastNOperands(op, 1)) ||
|
||||
failed(verifyAtLeastNResults(op, 1)))
|
||||
return failure();
|
||||
|
||||
auto type = op->getOperand(0)->getType();
|
||||
@ -797,7 +798,7 @@ LogicalResult OpTrait::impl::verifySameOperandsAndResultShape(Operation *op) {
|
||||
}
|
||||
|
||||
LogicalResult OpTrait::impl::verifySameOperandsElementType(Operation *op) {
|
||||
if (op->getNumOperands() == 0)
|
||||
if (failed(verifyAtLeastNOperands(op, 1)))
|
||||
return failure();
|
||||
|
||||
auto type = op->getOperand(0)->getType().dyn_cast<ShapedType>();
|
||||
@ -818,7 +819,8 @@ LogicalResult OpTrait::impl::verifySameOperandsElementType(Operation *op) {
|
||||
|
||||
LogicalResult
|
||||
OpTrait::impl::verifySameOperandsAndResultElementType(Operation *op) {
|
||||
if (op->getNumOperands() == 0 || op->getNumResults() == 0)
|
||||
if (failed(verifyAtLeastNOperands(op, 1)) ||
|
||||
failed(verifyAtLeastNResults(op, 1)))
|
||||
return failure();
|
||||
|
||||
auto type = op->getResult(0)->getType().dyn_cast<ShapedType>();
|
||||
@ -850,7 +852,8 @@ OpTrait::impl::verifySameOperandsAndResultElementType(Operation *op) {
|
||||
}
|
||||
|
||||
LogicalResult OpTrait::impl::verifySameOperandsAndResultType(Operation *op) {
|
||||
if (op->getNumOperands() == 0 || op->getNumResults() == 0)
|
||||
if (failed(verifyAtLeastNOperands(op, 1)) ||
|
||||
failed(verifyAtLeastNResults(op, 1)))
|
||||
return failure();
|
||||
|
||||
auto type = op->getResult(0)->getType();
|
||||
|
10
third_party/mlir/test/lib/TestDialect/TestOps.td
vendored
10
third_party/mlir/test/lib/TestDialect/TestOps.td
vendored
@ -219,19 +219,19 @@ def SameOperandElementTypeOp : TEST_Op<"same_operand_type",
|
||||
|
||||
def SameOperandAndResultElementTypeOp : TEST_Op<"same_operand_and_result_type",
|
||||
[SameOperandsAndResultElementType]> {
|
||||
let arguments = (ins AnyVectorOrTensor:$x, AnyVectorOrTensor:$y);
|
||||
let results = (outs AnyVectorOrTensor:$res);
|
||||
let arguments = (ins Variadic<AnyVectorOrTensor>:$args);
|
||||
let results = (outs Variadic<AnyVectorOrTensor>:$res);
|
||||
}
|
||||
|
||||
def SameOperandShapeOp : TEST_Op<"same_operand_shape", [SameOperandsShape]> {
|
||||
let arguments = (ins AnyVectorOrTensor:$x, AnyVectorOrTensor:$y);
|
||||
let arguments = (ins Variadic<AnyVectorOrTensor>:$args);
|
||||
let results = (outs AnyVectorOrTensor:$res);
|
||||
}
|
||||
|
||||
def SameOperandAndResultShapeOp : TEST_Op<"same_operand_and_result_shape",
|
||||
[SameOperandsAndResultShape]> {
|
||||
let arguments = (ins AnyVectorOrTensor:$x, AnyVectorOrTensor:$y);
|
||||
let results = (outs AnyVectorOrTensor:$res);
|
||||
let arguments = (ins Variadic<AnyVectorOrTensor>:$args);
|
||||
let results = (outs Variadic<AnyVectorOrTensor>:$res);
|
||||
}
|
||||
|
||||
def ArgAndResHaveFixedElementTypesOp :
|
||||
|
Loading…
Reference in New Issue
Block a user