[Mlir-commits] [mlir] 8184737 - [mlir][Linalg] Clarify error message in YieldOp verification NFC

Mehdi Amini llvmlistbot at llvm.org
Mon Aug 7 22:12:28 PDT 2023


Author: Felix Schneider
Date: 2023-08-07T22:12:05-07:00
New Revision: 8184737ce70fa2dcaee1a030c1b6df8f1f5550ae

URL: https://github.com/llvm/llvm-project/commit/8184737ce70fa2dcaee1a030c1b6df8f1f5550ae
DIFF: https://github.com/llvm/llvm-project/commit/8184737ce70fa2dcaee1a030c1b6df8f1f5550ae.diff

LOG: [mlir][Linalg] Clarify error message in YieldOp verification NFC

The number of values yielded from a LinalgOp's payload has to match
the number of inits / outs operands of the LinalgOp.
These two numbers got mixed up in the respective error message, this
patch clarifies the message and updates the tests.

Reviewed By: nicolasvasilache, mehdi_amini

Differential Revision: https://reviews.llvm.org/D153124

Added: 
    

Modified: 
    mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
    mlir/test/Dialect/Linalg/invalid.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index 6923f55591fc8a..7cee8c616a239d 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -1874,9 +1874,9 @@ ParseResult YieldOp::parse(OpAsmParser &parser, OperationState &result) {
 static LogicalResult verifyYield(linalg::YieldOp op, LinalgOp linalgOp) {
   if (op.getNumOperands() != linalgOp.getNumDpsInits())
     return op.emitOpError("expected number of yield values (")
-           << linalgOp.getNumDpsInits()
-           << ") to match the number of operands of the enclosing "
-           << "LinalgOp (" << op.getNumOperands() << ")";
+           << op.getNumOperands()
+           << ") to match the number of inits / outs operands of the enclosing "
+           << "LinalgOp (" << linalgOp.getNumDpsInits() << ")";
 
   for (OpOperand &opOperand : op->getOpOperands()) {
     OpOperand *outputOperand =

diff  --git a/mlir/test/Dialect/Linalg/invalid.mlir b/mlir/test/Dialect/Linalg/invalid.mlir
index 88f070a3252ed3..09acce04cd6a18 100644
--- a/mlir/test/Dialect/Linalg/invalid.mlir
+++ b/mlir/test/Dialect/Linalg/invalid.mlir
@@ -70,7 +70,7 @@ func.func @generic_no_region(%arg0: memref<f32>) {
 // -----
 
 func.func @generic_mismatched_num_returns(%arg0: memref<f32>) {
-  // expected-error @+6 {{op expected number of yield values (1) to match the number of operands of the enclosing LinalgOp (0)}}
+  // expected-error @+6 {{op expected number of yield values (0) to match the number of inits / outs operands of the enclosing LinalgOp (1)}}
   linalg.generic {
       indexing_maps =  [ affine_map<() -> ()> ],
       iterator_types = []}
@@ -202,7 +202,7 @@ func.func @generic_empty_region(%arg0: memref<f32>) {
 // -----
 
 func.func @generic_mismatched_num_arguments(%arg0: memref<f32>) {
-  // expected-error @+6 {{'linalg.yield' op expected number of yield values (2) to match the number of operands of the enclosing LinalgOp (1)}}
+  // expected-error @+6 {{'linalg.yield' op expected number of yield values (1) to match the number of inits / outs operands of the enclosing LinalgOp (2)}}
   linalg.generic {
       indexing_maps =  [ affine_map<() -> ()>, affine_map<() -> ()> ],
       iterator_types = []}
@@ -399,7 +399,7 @@ func.func @map_binary_wrong_yield_operands(
           outs(%init:tensor<64xf32>)
           (%lhs_elem: f32, %rhs_elem: f32) {
             %0 = arith.addf %lhs_elem, %rhs_elem: f32
-            // expected-error @+1{{'linalg.yield' op expected number of yield values (1) to match the number of operands of the enclosing LinalgOp (2)}}
+            // expected-error @+1{{'linalg.yield' op expected number of yield values (2) to match the number of inits / outs operands of the enclosing LinalgOp (1)}}
             linalg.yield %0, %0: f32, f32
           }
   func.return %add : tensor<64xf32>


        


More information about the Mlir-commits mailing list