Invalid input/output shapes

Hi all,
I’ve worked with @hanhan to add static verification for linalg operations to check if the shaped operands are valid. And I found IREE had some invalid test cases. For example:
%res = “mhlo.convolution”(%inputs, %weights) {
batch_group_count = 1 : i64,
dimension_numbers = {
input_batch_dimension = 0 : i64,
input_feature_dimension = 3 : i64,
input_spatial_dimensions = dense<[1, 2]> : tensor<2xi64>,
kernel_input_feature_dimension = 2 : i64,
kernel_output_feature_dimension = 3 : i64,
kernel_spatial_dimensions = dense<[0, 1]> : tensor<2xi64>,
output_batch_dimension = 0 : i64,
output_feature_dimension = 3 : i64,
output_spatial_dimensions = dense<[1, 2]> : tensor<2xi64>},
feature_group_count = 1 : i64,
rhs_dilation = dense<1> : tensor<2xi64>,
window_strides = dense<1> : tensor<2xi64>} : (tensor<1x4x5x2xf32>, tensor<3x2x2x1xf32>) → tensor<1x2x3x1xf32>

I think the input shape should be 1x4x4x2xf32, or the output shape should be 1x2x4x1xf32 to make it valid.
The problem was that the directories under iree/test/e2e/ had also invalid tests. I heard the tests under the directory got generated from frontends of IREE, And Hanhan also found some invalid tests in TF dialect. So, it might be invalid already before converting a ML model to TF dialect because the MHLO pass is generated from python program through TF dialect to MHLO Dialect.
Hanhan thought this issue would be in input/output shapes configuration or tensorflow shape inference system.

An easy way to check is to run it through XLA’s shape inference.

Just found one issue was in IREE. The padding attribute was not extracted out and mhlo → Linalg conversion forgot to check the condition.