[mlir] Print more verbose message in case of type inference error
authorVladislav Vinogradov <vlad.vinogradov@intel.com>
Tue, 2 Feb 2021 18:27:26 +0000 (18:27 +0000)
committerMehdi Amini <joker.eph@gmail.com>
Tue, 2 Feb 2021 18:27:30 +0000 (18:27 +0000)
Include the types into the error message.

Reviewed By: ftynse

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

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

index 4712f5f..f16c31a 100644 (file)
@@ -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();
 }
index 61727d1..33ea3f9 100644 (file)
@@ -58,7 +58,7 @@ func @complex_f64_tensor_success() {
 // -----
 
 func @complex_f64_failure() {
-  // expected-error@+1 {{op inferred type incompatible with return type of operation}}
+  // expected-error@+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@+1 {{type incompatible with return type of operation}}
+  // expected-error@+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@+1 {{type incompatible with return type of operation}}
+  // expected-error@+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
 }