From: Vladislav Vinogradov Date: Tue, 2 Feb 2021 18:27:26 +0000 (+0000) Subject: [mlir] Print more verbose message in case of type inference error X-Git-Tag: llvmorg-14-init~16239 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=95935849881c403e6e141da16b41d64dc4e537d3;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/mlir/lib/Interfaces/InferTypeOpInterface.cpp b/mlir/lib/Interfaces/InferTypeOpInterface.cpp index 4712f5f..f16c31a 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 61727d1..33ea3f9 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@+1 {{op inferred type incompatible with return type of operation}} + // expected-error@+1 {{op inferred type(s) 'complex' 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 }