[Mlir-commits] [mlir] 9593584 - [mlir] Print more verbose message in case of type inference error

Mehdi Amini llvmlistbot at llvm.org
Tue Feb 2 10:27:40 PST 2021


Author: Vladislav Vinogradov
Date: 2021-02-02T18:27:30Z
New Revision: 95935849881c403e6e141da16b41d64dc4e537d3

URL: https://github.com/llvm/llvm-project/commit/95935849881c403e6e141da16b41d64dc4e537d3
DIFF: https://github.com/llvm/llvm-project/commit/95935849881c403e6e141da16b41d64dc4e537d3.diff

LOG: [mlir] Print more verbose message in case of type inference error

Include the types into the error message.

Reviewed By: ftynse

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

Added: 
    

Modified: 
    mlir/lib/Interfaces/InferTypeOpInterface.cpp
    mlir/test/mlir-tblgen/types.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Interfaces/InferTypeOpInterface.cpp b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
index 4712f5f26870..f16c31a017f4 100644
--- a/mlir/lib/Interfaces/InferTypeOpInterface.cpp
+++ b/mlir/lib/Interfaces/InferTypeOpInterface.cpp
@@ -55,7 +55,9 @@ LogicalResult mlir::detail::verifyInferredResultTypes(Operation *op) {
     return failure();
   if (!retTypeFn.isCompatibleReturnTypes(inferredReturnTypes,
                                          op->getResultTypes()))
-    return op->emitOpError(
-        "inferred type incompatible with return type of operation");
+    return op->emitOpError("inferred type(s) ")
+           << inferredReturnTypes
+           << " are incompatible with return type(s) of operation "
+           << op->getResultTypes();
   return success();
 }

diff  --git a/mlir/test/mlir-tblgen/types.mlir b/mlir/test/mlir-tblgen/types.mlir
index 61727d18e68f..33ea3f9d044d 100644
--- a/mlir/test/mlir-tblgen/types.mlir
+++ b/mlir/test/mlir-tblgen/types.mlir
@@ -58,7 +58,7 @@ func @complex_f64_tensor_success() {
 // -----
 
 func @complex_f64_failure() {
-  // expected-error at +1 {{op inferred type incompatible with return type of operation}}
+  // expected-error at +1 {{op inferred type(s) 'complex<f64>' are incompatible with return type(s) of operation 'f64'}}
   "test.complex_f64"() : () -> (f64)
   return
 }
@@ -438,7 +438,7 @@ func @operand_rank_equals_result_size_failure(%arg : tensor<1x2x3x4xi32>) {
 // -----
 
 func @same_types_element_mismatch(%arg0: tensor<* x i32>, %arg1: tensor<* x f32>) {
-  // expected-error at +1 {{type incompatible with return type of operation}}
+  // expected-error at +1 {{op inferred type(s) 'tensor<*xi32>' are incompatible with return type(s) of operation 'tensor<*xf32>'}}
   "test.operand0_and_result_have_same_type"(%arg0, %arg1) : (tensor<* x i32>, tensor<* x f32>) -> tensor<* x f32>
   return
 }
@@ -446,7 +446,7 @@ func @same_types_element_mismatch(%arg0: tensor<* x i32>, %arg1: tensor<* x f32>
 // -----
 
 func @same_types_shape_mismatch(%arg0: tensor<1x2xi32>, %arg1: tensor<2x1xi32>) {
-  // expected-error at +1 {{type incompatible with return type of operation}}
+  // expected-error at +1 {{op inferred type(s) 'tensor<1x2xi32>' are incompatible with return type(s) of operation 'tensor<2x1xi32>'}}
   "test.operand0_and_result_have_same_type"(%arg0, %arg1) : (tensor<1x2xi32>, tensor<2x1xi32>) -> tensor<2x1xi32>
   return
 }


        


More information about the Mlir-commits mailing list