Open yzhang93 opened 1 month ago
@newling @erwei-xilinx The above is a list of all the original conv shapes in the model without padding.
Do they all have stride = 1?
Do they all have stride = 1?
Good point. I've updated the table to include stride.
@newling The depthwise ops didn't get transposed to channel last, because the pass only support linalg::Conv2DNchwFchwOp
conversion. https://github.com/iree-org/iree/blob/4de493af31e370ca2eb1bb590469ebbf76fc8d5b/compiler/src/iree/compiler/Preprocessing/Common/ConvertConvToChannelsLast.cpp#L452
We have to extend the pass if we need to work on channel last version, otherwise we can directly try lowering for linalg.depthwise_conv_2d_nchw_chw
or linalg.conv_2d_ngchw_gfchw_q
.
Stride 2 conv2d:
%8 = linalg.conv_2d_nhwc_hwcf_q {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>} ins(%3, %4, %c0_i32, %c0_i32 : tensor<1x515x515x3xi8>, tensor<3x3x3x32xi8>, i32, i32) outs(%7 : tensor<1x257x257x32xi32>) -> tensor<1x257x257x32xi32>
Stride 1 conv2d filter 1x1:
%8 = linalg.conv_2d_nhwc_hwcf_q {dilations = dense<1> : vector<2xi64>, strides = dense<1> : vector<2xi64>} ins(%3, %4, %c0_i32, %c0_i32 : tensor<1x257x257x32xi8>, tensor<1x1x32x16xi8>, i32, i32) outs(%7 : tensor<1x257x257x16xi32>) -> tensor<1x257x257x16xi32>
which can be converted to matmul_transpose_b:%8 = linalg.matmul_transpose_b ins(%3, %4 : tensor<66049x32xi8>, tensor<16x32xi8>) outs(%7 : tensor<66049x16xi32>) -> tensor<66049x16xi32>
%7 = linalg.conv_2d_ngchw_gfchw_q {dilations = dense<1> : vector<2xi64>, strides = dense<1> : vector<2xi64>} ins(%3, %4, %c0_i32, %c0_i32 : tensor<1x32x1x259x259xi8>, tensor<32x1x1x3x3xi8>, i32, i32) outs(%6 : tensor<1x32x1x257x257xi32>) -> tensor<1x32x1x257x257xi32>