Add verification error message for ops that require at least one operand or result.

PiperOrigin-RevId: 272153634
This commit is contained in:
Christian Sigg 2019-10-01 00:56:38 -07:00 committed by TensorFlower Gardener
parent de2b75069b
commit a40bd3f49c
2 changed files with 13 additions and 10 deletions
third_party/mlir
lib/IR
test/lib/TestDialect

View File

@ -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();

View File

@ -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 :