}
LogicalResult OpTrait::impl::verifySameOperandsShape(Operation *op) {
- if (op->getNumOperands() == 0)
+ if (failed(verifyAtLeastNOperands(op, 1)))
return failure();
auto type = op->getOperand(0)->getType();
}
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();
}
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>();
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>();
}
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();
// -----
+func @failedSameOperandAndResultElementType() {
+ // expected-error@+1 {{expected 1 or more operands}}
+ %0 = "test.same_operand_and_result_type"() : () -> tensor<1xf32>
+}
+
+// -----
+
+func @failedSameOperandAndResultElementType(%t1: tensor<1xf32>) {
+ // expected-error@+1 {{expected 1 or more results}}
+ "test.same_operand_and_result_type"(%t1) : (tensor<1xf32>) -> ()
+}
+
+// -----
+
// CHECK: succeededSameOperandShape
func @succeededSameOperandShape(%t10x10 : tensor<10x10xf32>, %t1: tensor<1xf32>, %tr: tensor<*xf32>) {
%0 = "test.same_operand_shape"(%t1, %t1) : (tensor<1xf32>, tensor<1xf32>) -> (tensor<10x10xf32>)
// -----
+func @failedSameOperandShape() {
+ // expected-error@+1 {{expected 1 or more operands}}
+ %0 = "test.same_operand_shape"() : () -> (tensor<1xf32>)
+}
+
+// -----
+
// CHECK: succeededSameOperandAndResultShape
func @succeededSameOperandAndResultShape(%t10x10 : tensor<10x10xf32>, %t1: tensor<1xf32>, %tr: tensor<*xf32>) {
%0 = "test.same_operand_and_result_shape"(%t1, %t1) : (tensor<1xf32>, tensor<1xf32>) -> tensor<1xf32>
// -----
+func @failedSameOperandAndResultShape() {
+ // expected-error@+1 {{expected 1 or more operands}}
+ %0 = "test.same_operand_and_result_shape"() : () -> (tensor<1xf32>)
+}
+
+// -----
+
+func @failedSameOperandAndResultShape(%t1: tensor<1xf32>) {
+ // expected-error@+1 {{expected 1 or more results}}
+ "test.same_operand_and_result_shape"(%t1) : (tensor<1xf32>) -> ()
+}
+
+// -----
+
func @hasParent() {
"some.op"() ({
// expected-error@+1 {{'test.child' op expects parent op 'test.parent'}}
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 :