Skip to content

Commit

Permalink
Include output shape in shape mismatch error message
Browse files Browse the repository at this point in the history
As discussed in
#2231 (comment),
this will likely help with debugging shape mismatches.
  • Loading branch information
Michael Levesque-Dion committed Apr 29, 2024
1 parent faf995a commit bc2824f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion stablehlo/dialect/TypeInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3795,7 +3795,7 @@ LogicalResult verifyDynamicReshapeOp(std::optional<Location> location,
if (!isCompatibleForHloTypeInference(outputShape, resultType))
return emitOptionalError(
location, "output_shape is incompatible with return type of operation ",
resultType);
resultType, ": ", outputShape);
return success();
}

Expand Down
2 changes: 1 addition & 1 deletion stablehlo/tests/ops_stablehlo.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,7 @@ func.func @dynamic_reshape_incompatible_shapes(%arg0: tensor<?xf32>, %shape: ten
// -----

func.func @dynamic_reshape_output_shape_mismatching_size(%arg0: tensor<4xf32>) -> tensor<1x4xf32> {
// expected-error@+2 {{output_shape is incompatible with return type of operation 'tensor<1x4xf32>'}}
// expected-error@+2 {{output_shape is incompatible with return type of operation 'tensor<1x4xf32>': %0 = "stablehlo.constant"}}
%0 = stablehlo.constant dense<[2, 2]> : tensor<2xi64>
%1 = stablehlo.dynamic_reshape %arg0, %0 : (tensor<4xf32>, tensor<2xi64>) -> tensor<1x4xf32>
return %1 : tensor<1x4xf32>
Expand Down

0 comments on commit bc2824f

Please sign in to comment.