2848 lines · plain
1// RUN: mlir-opt -split-input-file -verify-diagnostics %s | FileCheck %s2 3// CHECK-LABEL: func @depthwise_conv_1d_nwc_wcm4func.func @depthwise_conv_1d_nwc_wcm(%input: tensor<1x12x8xf32>, %filter: tensor<3x8x8xf32>) -> tensor<1x10x8x8xf32> {5 %zero = arith.constant 0.000000e+00 : f326 %init = tensor.empty() : tensor<1x10x8x8xf32>7 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<1x10x8x8xf32>) -> tensor<1x10x8x8xf32>8 // CHECK: depthwise_conv_1d_nwc_wcm9 %0 = linalg.depthwise_conv_1d_nwc_wcm {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}10 ins(%input, %filter : tensor<1x12x8xf32>, tensor<3x8x8xf32>)11 outs(%fill : tensor<1x10x8x8xf32>) -> tensor<1x10x8x8xf32>12 return %0 : tensor<1x10x8x8xf32>13}14 15// -----16 17// CHECK-LABEL: func @depthwise_conv_1d_nwc_wc18func.func @depthwise_conv_1d_nwc_wc(%input: tensor<1x12x8xf32>, %filter: tensor<3x8xf32>) -> tensor<1x10x8xf32> {19 %zero = arith.constant 0.000000e+00 : f3220 %init = tensor.empty() : tensor<1x10x8xf32>21 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<1x10x8xf32>) -> tensor<1x10x8xf32>22 // CHECK: depthwise_conv_1d_nwc_wc23 %0 = linalg.depthwise_conv_1d_nwc_wc {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}24 ins(%input, %filter : tensor<1x12x8xf32>, tensor<3x8xf32>)25 outs(%fill : tensor<1x10x8xf32>) -> tensor<1x10x8xf32>26 return %0 : tensor<1x10x8xf32>27}28 29// -----30 31// CHECK-LABEL: func @depthwise_conv_1d_ncw_cw32func.func @depthwise_conv_1d_ncw_cw(%input: tensor<1x8x12xf32>, %filter: tensor<8x3xf32>) -> tensor<1x8x10xf32> {33 %zero = arith.constant 0.000000e+00 : f3234 %init = tensor.empty() : tensor<1x8x10xf32>35 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<1x8x10xf32>) -> tensor<1x8x10xf32>36 // CHECK: depthwise_conv_1d_ncw_cw37 %0 = linalg.depthwise_conv_1d_ncw_cw {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}38 ins(%input, %filter : tensor<1x8x12xf32>, tensor<8x3xf32>)39 outs(%fill : tensor<1x8x10xf32>) -> tensor<1x8x10xf32>40 return %0 : tensor<1x8x10xf32>41}42 43// -----44 45// CHECK-LABEL: func @depthwise_conv_2d_nhwc_hwcm_tensor46func.func @depthwise_conv_2d_nhwc_hwcm_tensor(%input: tensor<2x4x5x2xf32>, %filter: tensor<2x2x2x3xf32>) -> tensor<2x3x4x2x3xf32> {47 %zero = arith.constant 0.000000e+00 : f3248 %init = tensor.empty() : tensor<2x3x4x2x3xf32>49 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<2x3x4x2x3xf32>) -> tensor<2x3x4x2x3xf32>50 // CHECK: %{{.+}} = linalg.depthwise_conv_2d_nhwc_hwcm51 // CHECK-SAME: {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}52 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<2x4x5x2xf32>, tensor<2x2x2x3xf32>)53 // CHECK-SAME: outs(%{{.+}} : tensor<2x3x4x2x3xf32>)54 %0 = linalg.depthwise_conv_2d_nhwc_hwcm55 { dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64> }56 ins(%input, %filter : tensor<2x4x5x2xf32>, tensor<2x2x2x3xf32>)57 outs(%fill : tensor<2x3x4x2x3xf32>) -> tensor<2x3x4x2x3xf32>58 return %0 : tensor<2x3x4x2x3xf32>59}60 61// CHECK-LABEL: func @depthwise_conv_2d_nhwc_hwcm_memref62func.func @depthwise_conv_2d_nhwc_hwcm_memref(%input: memref<2x4x5x2xf32>, %filter: memref<2x2x2x3xf32>, %output: memref<2x3x4x2x3xf32>) {63 // CHECK: linalg.depthwise_conv_2d_nhwc_hwcm64 // CHECK-SAME: {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}65 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<2x4x5x2xf32>, memref<2x2x2x3xf32>)66 // CHECK-SAME: outs(%{{.+}} : memref<2x3x4x2x3xf32>)67 linalg.depthwise_conv_2d_nhwc_hwcm68 { dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64> }69 ins(%input, %filter : memref<2x4x5x2xf32>, memref<2x2x2x3xf32>)70 outs(%output : memref<2x3x4x2x3xf32>)71 return72}73 74// CHECK-LABEL: func @depthwise_conv_1d_nw_tensor75func.func @depthwise_conv_1d_nw_tensor(%input: tensor<1x113x96xf32>, %filter: tensor<3x96xf32>) -> tensor<1x56x96xf32> {76 %init = tensor.empty() : tensor<1x56x96xf32>77 // CHECK: %{{.+}} = linalg.depthwise_conv_1d_nw78 // CHECK-SAME: {dilations = dense<1> : vector<1xi64>, strides = dense<2> : vector<1xi64>}79 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x113x96xf32>, tensor<3x96xf32>)80 // CHECK-SAME: outs(%{{.+}} : tensor<1x56x96xf32>) -> tensor<1x56x96xf32>81 %0 = linalg.depthwise_conv_1d_nwc_wc {dilations = dense<1> : vector<1xi64>, strides = dense<2> : vector<1xi64>}82 ins(%input, %filter: tensor<1x113x96xf32>, tensor<3x96xf32>)83 outs(%init: tensor<1x56x96xf32>) -> tensor<1x56x96xf32>84 return %0: tensor<1x56x96xf32>85}86 87// CHECK-LABEL: func @depthwise_conv_2d_nhwc_hwc_tensor88func.func @depthwise_conv_2d_nhwc_hwc_tensor(%input: tensor<1x113x113x96xf32>, %filter: tensor<3x3x96xf32>) -> tensor<1x56x56x96xf32> {89 %init = tensor.empty() : tensor<1x56x56x96xf32>90 // CHECK: %{{.+}} = linalg.depthwise_conv_2d_nhwc_hwc91 // CHECK-SAME: {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}92 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x113x113x96xf32>, tensor<3x3x96xf32>)93 // CHECK-SAME: outs(%{{.+}} : tensor<1x56x56x96xf32>) -> tensor<1x56x56x96xf32>94 %0 = linalg.depthwise_conv_2d_nhwc_hwc {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}95 ins(%input, %filter: tensor<1x113x113x96xf32>, tensor<3x3x96xf32>)96 outs(%init: tensor<1x56x56x96xf32>) -> tensor<1x56x56x96xf32>97 return %0: tensor<1x56x56x96xf32>98}99 100// CHECK-LABEL: func @depthwise_conv_2d_nhwc_hwc_memref101func.func @depthwise_conv_2d_nhwc_hwc_memref(%input: memref<1x113x113x96xf32>, %filter: memref<3x3x96xf32>, %output: memref<1x56x56x96xf32>) {102 // CHECK: linalg.depthwise_conv_2d_nhwc_hwc103 // CHECK-SAME: {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}104 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x113x113x96xf32>, memref<3x3x96xf32>)105 // CHECK-SAME: outs(%{{.+}} : memref<1x56x56x96xf32>)106 linalg.depthwise_conv_2d_nhwc_hwc {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}107 ins(%input, %filter: memref<1x113x113x96xf32>, memref<3x3x96xf32>)108 outs(%output: memref<1x56x56x96xf32>)109 return110}111 112// CHECK-LABEL: func @depthwise_conv_2d_nchw_chw_tensor113func.func @depthwise_conv_2d_nchw_chw_tensor(%input: tensor<1x96x113x113xf32>, %filter: tensor<96x3x3xf32>) -> tensor<1x96x56x56xf32> {114 %init = tensor.empty() : tensor<1x96x56x56xf32>115 // CHECK: %{{.+}} = linalg.depthwise_conv_2d_nchw_chw116 // CHECK-SAME: {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}117 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x96x113x113xf32>, tensor<96x3x3xf32>)118 // CHECK-SAME: outs(%{{.+}} : tensor<1x96x56x56xf32>) -> tensor<1x96x56x56xf32>119 %0 = linalg.depthwise_conv_2d_nchw_chw {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}120 ins(%input, %filter: tensor<1x96x113x113xf32>, tensor<96x3x3xf32>)121 outs(%init: tensor<1x96x56x56xf32>) -> tensor<1x96x56x56xf32>122 return %0: tensor<1x96x56x56xf32>123}124 125// CHECK-LABEL: func @depthwise_conv_2d_nchw_chw_memref126func.func @depthwise_conv_2d_nchw_chw_memref(%input: memref<1x96x113x113xf32>, %filter: memref<96x3x3xf32>, %output: memref<1x96x56x56xf32>) {127 // CHECK: linalg.depthwise_conv_2d_nchw_chw128 // CHECK-SAME: {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}129 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x96x113x113xf32>, memref<96x3x3xf32>)130 // CHECK-SAME: outs(%{{.+}} : memref<1x96x56x56xf32>)131 linalg.depthwise_conv_2d_nchw_chw {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<2xi64>}132 ins(%input, %filter: memref<1x96x113x113xf32>, memref<96x3x3xf32>)133 outs(%output: memref<1x96x56x56xf32>)134 return135}136 137func.func @depthwise_conv_2d_nhwc_hwcm_tensor_dilated(%input: tensor<2x8x9x2xf32>, %filter: tensor<2x2x2x3xf32>) -> tensor<2x6x7x2x3xf32> {138 %zero = arith.constant 0.000000e+00 : f32139 %init = tensor.empty() : tensor<2x6x7x2x3xf32>140 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<2x6x7x2x3xf32>) -> tensor<2x6x7x2x3xf32>141 // CHECK: %{{.+}} = linalg.depthwise_conv_2d_nhwc_hwcm142 // CHECK-SAME: {dilations = dense<2> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}143 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<2x8x9x2xf32>, tensor<2x2x2x3xf32>)144 // CHECK-SAME: outs(%{{.+}} : tensor<2x6x7x2x3xf32>)145 %0 = linalg.depthwise_conv_2d_nhwc_hwcm146 { dilations = dense<2> : tensor<2xi64>, strides = dense<1> : tensor<2xi64> }147 ins(%input, %filter : tensor<2x8x9x2xf32>, tensor<2x2x2x3xf32>)148 outs(%fill : tensor<2x6x7x2x3xf32>) -> tensor<2x6x7x2x3xf32>149 return %0 : tensor<2x6x7x2x3xf32>150}151 152// CHECK-LABEL: func @depthwise_conv_2d_nhwc_hwcm_memref_dilated153func.func @depthwise_conv_2d_nhwc_hwcm_memref_dilated(%input: memref<2x8x9x2xf32>, %filter: memref<2x2x2x3xf32>, %output: memref<2x6x7x2x3xf32>) {154 // CHECK: linalg.depthwise_conv_2d_nhwc_hwcm155 // CHECK-SAME: {dilations = dense<2> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}156 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<2x8x9x2xf32>, memref<2x2x2x3xf32>)157 // CHECK-SAME: outs(%{{.+}} : memref<2x6x7x2x3xf32>)158 linalg.depthwise_conv_2d_nhwc_hwcm159 { dilations = dense<2> : tensor<2xi64>, strides = dense<1> : tensor<2xi64> }160 ins(%input, %filter : memref<2x8x9x2xf32>, memref<2x2x2x3xf32>)161 outs(%output : memref<2x6x7x2x3xf32>)162 return163}164 165// -----166 167// CHECK-LABEL: func @depthwise_conv_2d_input_nhwc_filter_default_attributes168func.func @depthwise_conv_2d_input_nhwc_filter_default_attributes(%input: memref<1x113x113x96xf32>, %filter: memref<3x3x96xf32>, %output: memref<1x56x56x96xf32>) {169 // CHECK: linalg.depthwise_conv_2d_nhwc_hwc170 // CHECK-NOT: strides =171 // CHECK-NOT: dilations =172 linalg.depthwise_conv_2d_nhwc_hwc173 ins(%input, %filter: memref<1x113x113x96xf32>, memref<3x3x96xf32>)174 outs(%output: memref<1x56x56x96xf32>)175 return176}177 178// -----179 180func.func @depthwise_conv_2d_input_nhwc_filter_wrong_stride_element_type_properties(%input: memref<1x113x113x96xf32>, %filter: memref<3x3x96xf32>, %output: memref<1x56x56x96xf32>) {181 // expected-error @+1 {{invalid properties {dilations = dense<1> : vector<2xi64>, operandSegmentSizes = array<i32: 2, 1>, strides = dense<2.000000e+00> : vector<2xf32>} for op linalg.depthwise_conv_2d_nhwc_hwc: Invalid attribute `strides` in property conversion: dense<2.000000e+00> : vector<2xf32>}}182 linalg.depthwise_conv_2d_nhwc_hwc <{dilations = dense<1> : vector<2xi64>, strides = dense<2.0> : vector<2xf32>}>183 ins(%input, %filter: memref<1x113x113x96xf32>, memref<3x3x96xf32>)184 outs(%output: memref<1x56x56x96xf32>)185 return186}187 188// -----189 190func.func @depthwise_conv_2d_input_nhwc_filter_wrong_stride_element_type(%input: memref<1x113x113x96xf32>, %filter: memref<3x3x96xf32>, %output: memref<1x56x56x96xf32>) {191 // expected-error @+1 {{op attribute 'strides' failed to satisfy constraint: 64-bit signless int elements attribute of shape [2]}}192 linalg.depthwise_conv_2d_nhwc_hwc {dilations = dense<1> : vector<2xi64>, strides = dense<2.0> : vector<2xf32>}193 ins(%input, %filter: memref<1x113x113x96xf32>, memref<3x3x96xf32>)194 outs(%output: memref<1x56x56x96xf32>)195 return196}197 198// -----199 200func.func @depthwise_conv_2d_input_nhwc_filter_wrong_stride_size(%input: memref<1x113x113x96xf32>, %filter: memref<3x3x96xf32>, %output: memref<1x56x56x96xf32>) {201 // expected-error @+1 {{op attribute 'strides' failed to satisfy constraint: 64-bit signless int elements attribute of shape [2]}}202 linalg.depthwise_conv_2d_nhwc_hwc {dilations = dense<1> : vector<2xi64>, strides = dense<2> : vector<3xi64> }203 ins(%input, %filter: memref<1x113x113x96xf32>, memref<3x3x96xf32>)204 outs(%output: memref<1x56x56x96xf32>)205 return206}207 208// -----209 210// CHECK-LABEL: func @depthwise_conv_3d_ndhwc_dhwcm211func.func @depthwise_conv_3d_ndhwc_dhwcm(%input: tensor<2x6x13x12x6xf32>, %filter: tensor<2x1x3x6x6xf32>) -> tensor<2x3x13x4x6x6xf32> {212 %zero = arith.constant 0.000000e+00 : f32213 %init = tensor.empty() : tensor<2x3x13x4x6x6xf32>214 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<2x3x13x4x6x6xf32>) -> tensor<2x3x13x4x6x6xf32>215 // CHECK: depthwise_conv_3d_ndhwc_dhwcm216 %0 = linalg.depthwise_conv_3d_ndhwc_dhwcm {dilations = dense<1> : tensor<3xi64>, strides = dense<[2, 1, 3]> : tensor<3xi64>}217 ins(%input, %filter : tensor<2x6x13x12x6xf32>, tensor<2x1x3x6x6xf32>)218 outs(%fill : tensor<2x3x13x4x6x6xf32>) -> tensor<2x3x13x4x6x6xf32>219 return %0 : tensor<2x3x13x4x6x6xf32>220}221 222// -----223 224// CHECK-LABEL: func @depthwise_conv_3d_ndhwc_dhwc225func.func @depthwise_conv_3d_ndhwc_dhwc(%input: tensor<2x6x13x12x6xf32>, %filter: tensor<2x1x3x6xf32>) -> tensor<2x3x13x4x6xf32> {226 %zero = arith.constant 0.000000e+00 : f32227 %init = tensor.empty() : tensor<2x3x13x4x6xf32>228 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<2x3x13x4x6xf32>) -> tensor<2x3x13x4x6xf32>229 // CHECK: depthwise_conv_3d_ndhwc_dhwc230 %0 = linalg.depthwise_conv_3d_ndhwc_dhwc {dilations = dense<1> : tensor<3xi64>, strides = dense<[2, 1, 3]> : tensor<3xi64>}231 ins(%input, %filter : tensor<2x6x13x12x6xf32>, tensor<2x1x3x6xf32>)232 outs(%fill : tensor<2x3x13x4x6xf32>) -> tensor<2x3x13x4x6xf32>233 return %0 : tensor<2x3x13x4x6xf32>234}235 236// -----237 238// CHECK-LABEL: func @depthwise_conv_3d_ncdhw_cdhw239func.func @depthwise_conv_3d_ncdhw_cdhw(%input: tensor<2x6x6x13x12xf32>, %filter: tensor<6x2x1x3xf32>) -> tensor<2x6x3x13x4xf32> {240 %zero = arith.constant 0.000000e+00 : f32241 %init = tensor.empty() : tensor<2x6x3x13x4xf32>242 %fill = linalg.fill ins(%zero : f32) outs(%init : tensor<2x6x3x13x4xf32>) -> tensor<2x6x3x13x4xf32>243 // CHECK: depthwise_conv_3d_ncdhw_cdhw244 %0 = linalg.depthwise_conv_3d_ncdhw_cdhw {dilations = dense<1> : tensor<3xi64>, strides = dense<[2, 1, 3]> : tensor<3xi64>}245 ins(%input, %filter : tensor<2x6x6x13x12xf32>, tensor<6x2x1x3xf32>)246 outs(%fill : tensor<2x6x3x13x4xf32>) -> tensor<2x6x3x13x4xf32>247 return %0 : tensor<2x6x3x13x4xf32>248}249 250// -----251 252// CHECK-LABEL: func @conv_1d_nwc_wcf253func.func @conv_1d_nwc_wcf(%input: tensor<?x?x?xf32>, %filter: tensor<?x?x?xf32>, %init: tensor<?x?x?xf32>) -> tensor<?x?x?xf32> {254 // CHECK: %{{.+}} = linalg.conv_1d_nwc_wcf255 // CHECK-SAME: dilations = dense<1> : tensor<1xi64>256 // CHECK-SAME: strides = dense<1> : tensor<1xi64>257 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x?x?xf32>, tensor<?x?x?xf32>)258 // CHECK-SAME: outs(%{{.+}} : tensor<?x?x?xf32>) -> tensor<?x?x?xf32>259 %0 = linalg.conv_1d_nwc_wcf {dilations = dense<1> : tensor<1xi64>,260 strides = dense<1> : tensor<1xi64>}261 ins (%input, %filter: tensor<?x?x?xf32>, tensor<?x?x?xf32>)262 outs (%init: tensor<?x?x?xf32>) -> tensor<?x?x?xf32>263 return %0 : tensor<?x?x?xf32>264}265 266// -----267 268// CHECK-LABEL: func @conv_1d_nwc_wcf269func.func @conv_1d_nwc_wcf(%input: memref<?x?x?xf32>, %filter: memref<?x?x?xf32>, %output: memref<?x?x?xf32>) {270 // CHECK: linalg.conv_1d_nwc_wcf271 // CHECK-SAME: dilations = dense<1> : tensor<1xi64>272 // CHECK-SAME: strides = dense<1> : tensor<1xi64>273 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)274 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)275 linalg.conv_1d_nwc_wcf {dilations = dense<1> : tensor<1xi64>,276 strides = dense<1> : tensor<1xi64>}277 ins (%input, %filter: memref<?x?x?xf32>, memref<?x?x?xf32>)278 outs (%output: memref<?x?x?xf32>)279 return280}281 282// -----283 284// CHECK-LABEL: func @conv_1d_ncw_fcw285func.func @conv_1d_ncw_fcw(%input: tensor<?x?x?xf32>, %filter: tensor<?x?x?xf32>, %init: tensor<?x?x?xf32>) -> tensor<?x?x?xf32> {286 // CHECK: %{{.+}} = linalg.conv_1d_ncw_fcw287 // CHECK-SAME: dilations = dense<1> : tensor<1xi64>288 // CHECK-SAME: strides = dense<1> : tensor<1xi64>289 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x?x?xf32>, tensor<?x?x?xf32>)290 // CHECK-SAME: outs(%{{.+}} : tensor<?x?x?xf32>) -> tensor<?x?x?xf32>291 %0 = linalg.conv_1d_ncw_fcw {dilations = dense<1> : tensor<1xi64>,292 strides = dense<1> : tensor<1xi64>}293 ins (%input, %filter: tensor<?x?x?xf32>, tensor<?x?x?xf32>)294 outs (%init: tensor<?x?x?xf32>) -> tensor<?x?x?xf32>295 return %0 : tensor<?x?x?xf32>296}297 298// -----299 300// CHECK-LABEL: func @conv_1d_ncw_fcw301func.func @conv_1d_ncw_fcw(%input: memref<?x?x?xf32>, %filter: memref<?x?x?xf32>, %output: memref<?x?x?xf32>) {302 // CHECK: linalg.conv_1d_ncw_fcw303 // CHECK-SAME: dilations = dense<1> : tensor<1xi64>304 // CHECK-SAME: strides = dense<1> : tensor<1xi64>305 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)306 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)307 linalg.conv_1d_ncw_fcw {dilations = dense<1> : tensor<1xi64>,308 strides = dense<1> : tensor<1xi64>}309 ins (%input, %filter: memref<?x?x?xf32>, memref<?x?x?xf32>)310 outs (%output: memref<?x?x?xf32>)311 return312}313 314// -----315 316// CHECK-LABEL: func @conv_2d_nhwc_hwcf317func.func @conv_2d_nhwc_hwcf(%input: tensor<?x?x?x?xf32>, %filter: tensor<?x?x?x?xf32>, %init: tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32> {318 // CHECK: %{{.+}} = linalg.conv_2d_nhwc_hwcf319 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>320 // CHECK-SAME: strides = dense<1> : tensor<2xi64>321 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>)322 // CHECK-SAME: outs(%{{.+}} : tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>323 %0 = linalg.conv_2d_nhwc_hwcf {dilations = dense<1> : tensor<2xi64>,324 strides = dense<1> : tensor<2xi64>}325 ins (%input, %filter: tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>)326 outs (%init: tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>327 return %0 : tensor<?x?x?x?xf32>328}329 330// -----331 332// CHECK-LABEL: func @conv_2d_ngchw_fgchw333func.func @conv_2d_ngchw_fgchw(%input: tensor<?x?x?x?x?xf32>, %filter: tensor<?x?x?x?x?xf32>, %init: tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32> {334 // CHECK: %{{.+}} = linalg.conv_2d_ngchw_fgchw335 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>336 // CHECK-SAME: strides = dense<1> : tensor<2xi64>337 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x?x?x?x?xf32>, tensor<?x?x?x?x?xf32>)338 // CHECK-SAME: outs(%{{.+}} : tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32>339 %0 = linalg.conv_2d_ngchw_fgchw {dilations = dense<1> : tensor<2xi64>,340 strides = dense<1> : tensor<2xi64>}341 ins (%input, %filter: tensor<?x?x?x?x?xf32>, tensor<?x?x?x?x?xf32>)342 outs (%init: tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32>343 return %0 : tensor<?x?x?x?x?xf32>344}345 346// -----347 348// CHECK-LABEL: func @conv_2d_nhwc_fhwc349func.func @conv_2d_nhwc_fhwc(%input: tensor<?x?x?x?xf32>, %filter: tensor<?x?x?x?xf32>, %init: tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32> {350 // CHECK: %{{.+}} = linalg.conv_2d_nhwc_fhwc351 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>352 // CHECK-SAME: strides = dense<1> : tensor<2xi64>353 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>)354 // CHECK-SAME: outs(%{{.+}} : tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>355 %0 = linalg.conv_2d_nhwc_fhwc {dilations = dense<1> : tensor<2xi64>,356 strides = dense<1> : tensor<2xi64>}357 ins (%input, %filter: tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>)358 outs (%init: tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>359 return %0 : tensor<?x?x?x?xf32>360}361 362// -----363 364// CHECK-LABEL: func @conv_2d_nhwc_fhwc_static365func.func @conv_2d_nhwc_fhwc_static(%input: tensor<?x128x128x32xf32>, %filter: tensor<64x3x3x32xf32>, %init: tensor<?x126x126x64xf32>) -> tensor<?x126x126x64xf32> {366 // CHECK: %{{.+}} = linalg.conv_2d_nhwc_fhwc367 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>368 // CHECK-SAME: strides = dense<1> : tensor<2xi64>369 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x128x128x32xf32>, tensor<64x3x3x32xf32>)370 // CHECK-SAME: outs(%{{.+}} : tensor<?x126x126x64xf32>) -> tensor<?x126x126x64xf32>371 %0 = linalg.conv_2d_nhwc_fhwc {dilations = dense<1> : tensor<2xi64>,372 strides = dense<1> : tensor<2xi64>}373 ins (%input, %filter: tensor<?x128x128x32xf32>, tensor<64x3x3x32xf32>)374 outs (%init: tensor<?x126x126x64xf32>) -> tensor<?x126x126x64xf32>375 return %0 : tensor<?x126x126x64xf32>376}377 378// -----379 380// CHECK-LABEL: func @conv_2d_nhwc_hwcf381func.func @conv_2d_nhwc_hwcf(%input: memref<?x?x?x?xf32>, %filter: memref<?x?x?x?xf32>, %output: memref<?x?x?x?xf32>) {382 // CHECK: linalg.conv_2d_nhwc_hwcf383 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>384 // CHECK-SAME: strides = dense<1> : tensor<2xi64>385 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?x?xf32>, memref<?x?x?x?xf32>)386 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?x?xf32>)387 linalg.conv_2d_nhwc_hwcf {dilations = dense<1> : tensor<2xi64>,388 strides = dense<1> : tensor<2xi64>}389 ins (%input, %filter: memref<?x?x?x?xf32>, memref<?x?x?x?xf32>)390 outs (%output: memref<?x?x?x?xf32>)391 return392}393 394// -----395 396// CHECK-LABEL: func @conv_2d_ngchw_fgchw397func.func @conv_2d_ngchw_fgchw(%input: memref<?x?x?x?x?xf32>, %filter: memref<?x?x?x?x?xf32>, %output: memref<?x?x?x?x?xf32>) {398 // CHECK: linalg.conv_2d_ngchw_fgchw399 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>400 // CHECK-SAME: strides = dense<1> : tensor<2xi64>401 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)402 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?x?x?xf32>)403 linalg.conv_2d_ngchw_fgchw {dilations = dense<1> : tensor<2xi64>,404 strides = dense<1> : tensor<2xi64>}405 ins (%input, %filter: memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)406 outs (%output: memref<?x?x?x?x?xf32>)407 return408}409 410// -----411 412// CHECK-LABEL: func @conv_2d_nhwgc_gfhwc413func.func @conv_2d_nhwgc_gfhwc(%input: memref<?x?x?x?x?xf32>, %filter: memref<?x?x?x?x?xf32>, %output: memref<?x?x?x?x?xf32>) {414 // CHECK: linalg.conv_2d_nhwgc_gfhwc415 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>416 // CHECK-SAME: strides = dense<1> : tensor<2xi64>417 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)418 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?x?x?xf32>)419 linalg.conv_2d_nhwgc_gfhwc {dilations = dense<1> : tensor<2xi64>,420 strides = dense<1> : tensor<2xi64>}421 ins (%input, %filter: memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)422 outs (%output: memref<?x?x?x?x?xf32>)423 return424}425 426// -----427 428// CHECK-LABEL: func @conv_2d_nhwgc_gfhwc_tensor429func.func @conv_2d_nhwgc_gfhwc_tensor(%input: tensor<1x28x28x2x3xf32>, %filter: tensor<2x8x3x3x3xf32>, %output: tensor<1x26x26x2x8xf32>) -> tensor<1x26x26x2x8xf32> {430 // CHECK: linalg.conv_2d_nhwgc_gfhwc431 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>432 // CHECK-SAME: strides = dense<1> : tensor<2xi64>433 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x28x28x2x3xf32>, tensor<2x8x3x3x3xf32>)434 // CHECK-SAME: outs(%{{.+}} : tensor<1x26x26x2x8xf32>) -> tensor<1x26x26x2x8xf32>435 %0 = linalg.conv_2d_nhwgc_gfhwc {dilations = dense<1> : tensor<2xi64>,436 strides = dense<1> : tensor<2xi64>}437 ins (%input, %filter: tensor<1x28x28x2x3xf32>, tensor<2x8x3x3x3xf32>)438 outs (%output: tensor<1x26x26x2x8xf32>) -> tensor<1x26x26x2x8xf32>439 return %0 : tensor<1x26x26x2x8xf32>440}441 442// -----443 444// CHECK-LABEL: func @conv_2d_ngchw_fgchw_dimensions445func.func @conv_2d_ngchw_fgchw_dimensions(%input: tensor<1x5x3x32x32xf32>, %filter: tensor<2x5x3x3x3xf32>, %init: tensor<1x5x2x30x30xf32>) -> tensor<1x5x2x30x30xf32> {446 // CHECK: linalg.conv_2d_ngchw_fgchw447 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>448 // CHECK-SAME: strides = dense<1> : tensor<2xi64>449 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x5x3x32x32xf32>, tensor<2x5x3x3x3xf32>)450 // CHECK-SAME: outs(%{{.+}} : tensor<1x5x2x30x30xf32>) -> tensor<1x5x2x30x30xf32>451 %0 = linalg.conv_2d_ngchw_fgchw {dilations = dense<1> : tensor<2xi64>,452 strides = dense<1> : tensor<2xi64>}453 ins (%input, %filter: tensor<1x5x3x32x32xf32>, tensor<2x5x3x3x3xf32>)454 outs (%init: tensor<1x5x2x30x30xf32>) -> tensor<1x5x2x30x30xf32>455 return %0 : tensor<1x5x2x30x30xf32>456}457 458// -----459 460// CHECK-LABEL: func @conv_2d_ngchw_gfchw461func.func @conv_2d_ngchw_gfchw(%input: tensor<1x5x3x32x32xf32>, %filter: tensor<5x2x3x3x3xf32>, %init: tensor<1x5x2x30x30xf32>) -> tensor<1x5x2x30x30xf32> {462 // CHECK: linalg.conv_2d_ngchw_gfchw463 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>464 // CHECK-SAME: strides = dense<1> : tensor<2xi64>465 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x5x3x32x32xf32>, tensor<5x2x3x3x3xf32>)466 // CHECK-SAME: outs(%{{.+}} : tensor<1x5x2x30x30xf32>) -> tensor<1x5x2x30x30xf32>467 %0 = linalg.conv_2d_ngchw_gfchw {dilations = dense<1> : tensor<2xi64>,468 strides = dense<1> : tensor<2xi64>}469 ins (%input, %filter: tensor<1x5x3x32x32xf32>, tensor<5x2x3x3x3xf32>)470 outs (%init: tensor<1x5x2x30x30xf32>) -> tensor<1x5x2x30x30xf32>471 return %0 : tensor<1x5x2x30x30xf32>472}473 474// -----475 476// CHECK-LABEL: func @conv_2d_ngchw_gfchw_q477func.func @conv_2d_ngchw_gfchw_q(%input: tensor<1x5x3x32x32xi8>, %filter: tensor<5x2x3x3x3xi8>, %inputzp: i32, %filterzp: i32, %init: tensor<1x5x2x30x30xi32>) -> tensor<1x5x2x30x30xi32> {478 // CHECK: linalg.conv_2d_ngchw_gfchw_q479 // CHECK-SAME: dilations = dense<1> : tensor<2xi64>480 // CHECK-SAME: strides = dense<1> : tensor<2xi64>481 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x5x3x32x32xi8>, tensor<5x2x3x3x3xi8>, i32, i32)482 // CHECK-SAME: outs(%{{.+}} : tensor<1x5x2x30x30xi32>) -> tensor<1x5x2x30x30xi32>483 %0 = linalg.conv_2d_ngchw_gfchw_q {dilations = dense<1> : tensor<2xi64>,484 strides = dense<1> : tensor<2xi64>}485 ins (%input, %filter, %inputzp, %filterzp: tensor<1x5x3x32x32xi8>, tensor<5x2x3x3x3xi8>, i32, i32)486 outs (%init: tensor<1x5x2x30x30xi32>) -> tensor<1x5x2x30x30xi32>487 return %0 : tensor<1x5x2x30x30xi32>488}489// -----490 491// CHECK-LABEL: func @conv_3d_ndhwc_dhwcf492func.func @conv_3d_ndhwc_dhwcf(%input: tensor<?x?x?x?x?xf32>, %filter: tensor<?x?x?x?x?xf32>, %init: tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32> {493 // CHECK: %{{.+}} = linalg.conv_3d_ndhwc_dhwcf494 // CHECK-SAME: dilations = dense<1> : tensor<3xi64>495 // CHECK-SAME: strides = dense<1> : tensor<3xi64>496 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x?x?x?x?xf32>, tensor<?x?x?x?x?xf32>)497 // CHECK-SAME: outs(%{{.+}} : tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32>498 %0 = linalg.conv_3d_ndhwc_dhwcf {dilations = dense<1> : tensor<3xi64>,499 strides = dense<1> : tensor<3xi64>}500 ins (%input, %filter: tensor<?x?x?x?x?xf32>, tensor<?x?x?x?x?xf32>)501 outs (%init: tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32>502 return %0 : tensor<?x?x?x?x?xf32>503}504 505// -----506 507// CHECK-LABEL: func @conv_3d_ndhwc_dhwcf508func.func @conv_3d_ndhwc_dhwcf(%input: memref<?x?x?x?x?xf32>, %filter: memref<?x?x?x?x?xf32>, %output: memref<?x?x?x?x?xf32>) {509 // CHECK: linalg.conv_3d_ndhwc_dhwcf510 // CHECK-SAME: dilations = dense<1> : tensor<3xi64>511 // CHECK-SAME: strides = dense<1> : tensor<3xi64>512 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)513 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?x?x?xf32>)514 linalg.conv_3d_ndhwc_dhwcf {dilations = dense<1> : tensor<3xi64>,515 strides = dense<1> : tensor<3xi64>}516 ins (%input, %filter: memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)517 outs (%output: memref<?x?x?x?x?xf32>)518 return519}520 521// -----522 523// CHECK-LABEL: func @conv_3d_ncdhw_fcdhw524func.func @conv_3d_ncdhw_fcdhw(%input: tensor<?x?x?x?x?xf32>, %filter: tensor<?x?x?x?x?xf32>, %init: tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32> {525 // CHECK: %{{.+}} = linalg.conv_3d_ncdhw_fcdhw526 // CHECK-SAME: dilations = dense<1> : tensor<3xi64>527 // CHECK-SAME: strides = dense<1> : tensor<3xi64>528 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<?x?x?x?x?xf32>, tensor<?x?x?x?x?xf32>)529 // CHECK-SAME: outs(%{{.+}} : tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32>530 %0 = linalg.conv_3d_ncdhw_fcdhw {dilations = dense<1> : tensor<3xi64>,531 strides = dense<1> : tensor<3xi64>}532 ins (%input, %filter: tensor<?x?x?x?x?xf32>, tensor<?x?x?x?x?xf32>)533 outs (%init: tensor<?x?x?x?x?xf32>) -> tensor<?x?x?x?x?xf32>534 return %0 : tensor<?x?x?x?x?xf32>535}536 537// -----538 539// CHECK-LABEL: func @conv_3d_ncdhw_fcdhw540func.func @conv_3d_ncdhw_fcdhw(%input: memref<?x?x?x?x?xf32>, %filter: memref<?x?x?x?x?xf32>, %output: memref<?x?x?x?x?xf32>) {541 // CHECK: linalg.conv_3d_ncdhw_fcdhw542 // CHECK-SAME: dilations = dense<1> : tensor<3xi64>543 // CHECK-SAME: strides = dense<1> : tensor<3xi64>544 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)545 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?x?x?xf32>)546 linalg.conv_3d_ncdhw_fcdhw {dilations = dense<1> : tensor<3xi64>,547 strides = dense<1> : tensor<3xi64>}548 ins (%input, %filter: memref<?x?x?x?x?xf32>, memref<?x?x?x?x?xf32>)549 outs (%output: memref<?x?x?x?x?xf32>)550 return551}552 553// -----554 555// CHECK-LABEL: func @pooling_nhwc_sum_tensor556// CHECK: %{{.+}} = linalg.pooling_nhwc_sum557// CHECK-SAME: dilations = dense<1> : tensor<2xi64>558// CHECK-SAME: strides = dense<1> : tensor<2xi64>559// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xf32>, tensor<3x3xf32>)560// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>561func.func @pooling_nhwc_sum_tensor(%input: tensor<1x4x4x1xf32>) -> tensor<1x2x2x1xf32> {562 %fake = tensor.empty() : tensor<3x3xf32>563 %init = tensor.empty() : tensor<1x2x2x1xf32>564 %cst = arith.constant 0.000000e+00 : f32565 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>566 %res = linalg.pooling_nhwc_sum {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}567 ins(%input, %fake: tensor<1x4x4x1xf32>, tensor<3x3xf32>)568 outs(%fill: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>569 return %res : tensor<1x2x2x1xf32>570}571 572// -----573 574// CHECK-LABEL: func @pooling_nwc_sum_tensor575// CHECK: %{{.+}} = linalg.pooling_nwc_sum576// CHECK-SAME: dilations = dense<1> : tensor<1xi64>577// CHECK-SAME: strides = dense<1> : tensor<1xi64>578// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xf32>, tensor<3xf32>)579// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xf32>) -> tensor<1x2x1xf32>580func.func @pooling_nwc_sum_tensor(%input: tensor<1x4x1xf32>) -> tensor<1x2x1xf32> {581 %fake = tensor.empty() : tensor<3xf32>582 %init = tensor.empty() : tensor<1x2x1xf32>583 %cst = arith.constant 0.000000e+00 : f32584 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x1xf32>) -> tensor<1x2x1xf32>585 %res = linalg.pooling_nwc_sum {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}586 ins(%input, %fake: tensor<1x4x1xf32>, tensor<3xf32>)587 outs(%fill: tensor<1x2x1xf32>) -> tensor<1x2x1xf32>588 return %res : tensor<1x2x1xf32>589}590 591// -----592 593// CHECK-LABEL: func @pooling_nhwc_sum594// CHECK: linalg.pooling_nhwc_sum595// CHECK-SAME: dilations = dense<1> : tensor<2xi64>596// CHECK-SAME: strides = dense<1> : tensor<2xi64>597// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x1xf32>, memref<3x3xf32>)598// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x1xf32>)599func.func @pooling_nhwc_sum(%input: memref<1x4x4x1xf32>, %fake: memref<3x3xf32>, %output: memref<1x2x2x1xf32>) {600 linalg.pooling_nhwc_sum {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}601 ins(%input, %fake: memref<1x4x4x1xf32>, memref<3x3xf32>)602 outs(%output: memref<1x2x2x1xf32>)603 return604}605 606// -----607 608// CHECK-LABEL: func @pooling_nwc_sum609// CHECK: linalg.pooling_nwc_sum610// CHECK-SAME: dilations = dense<1> : tensor<1xi64>611// CHECK-SAME: strides = dense<1> : tensor<1xi64>612// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x1xf32>, memref<3xf32>)613// CHECK-SAME: outs(%{{.+}} : memref<1x2x1xf32>)614func.func @pooling_nwc_sum(%input: memref<1x4x1xf32>, %fake: memref<3xf32>, %output: memref<1x2x1xf32>) {615 linalg.pooling_nwc_sum {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}616 ins(%input, %fake: memref<1x4x1xf32>, memref<3xf32>)617 outs(%output: memref<1x2x1xf32>)618 return619}620 621// -----622 623// CHECK-LABEL: func @pooling_nchw_sum_tensor624// CHECK: %{{.+}} = linalg.pooling_nchw_sum625// CHECK-SAME: dilations = dense<1> : tensor<2xi64>626// CHECK-SAME: strides = dense<1> : tensor<2xi64>627// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x1x4x4xf32>, tensor<3x3xf32>)628// CHECK-SAME: outs(%{{.+}} : tensor<1x1x2x2xf32>) -> tensor<1x1x2x2xf32>629func.func @pooling_nchw_sum_tensor(%input: tensor<1x1x4x4xf32>) -> tensor<1x1x2x2xf32> {630 %fake = tensor.empty() : tensor<3x3xf32>631 %init = tensor.empty() : tensor<1x1x2x2xf32>632 %cst = arith.constant 0.000000e+00 : f32633 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x1x2x2xf32>) -> tensor<1x1x2x2xf32>634 %res = linalg.pooling_nchw_sum {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}635 ins(%input, %fake: tensor<1x1x4x4xf32>, tensor<3x3xf32>)636 outs(%fill: tensor<1x1x2x2xf32>) -> tensor<1x1x2x2xf32>637 return %res : tensor<1x1x2x2xf32>638}639 640// -----641 642// CHECK-LABEL: func @pooling_ncw_sum_tensor643// CHECK: %{{.+}} = linalg.pooling_ncw_sum644// CHECK-SAME: dilations = dense<1> : tensor<1xi64>645// CHECK-SAME: strides = dense<1> : tensor<1xi64>646// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x1x4xf32>, tensor<3xf32>)647// CHECK-SAME: outs(%{{.+}} : tensor<1x1x2xf32>) -> tensor<1x1x2xf32>648func.func @pooling_ncw_sum_tensor(%input: tensor<1x1x4xf32>) -> tensor<1x1x2xf32> {649 %fake = tensor.empty() : tensor<3xf32>650 %init = tensor.empty() : tensor<1x1x2xf32>651 %cst = arith.constant 0.000000e+00 : f32652 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x1x2xf32>) -> tensor<1x1x2xf32>653 %res = linalg.pooling_ncw_sum {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}654 ins(%input, %fake: tensor<1x1x4xf32>, tensor<3xf32>)655 outs(%fill: tensor<1x1x2xf32>) -> tensor<1x1x2xf32>656 return %res : tensor<1x1x2xf32>657}658 659// -----660 661// CHECK-LABEL: func @pooling_nchw_sum662// CHECK: linalg.pooling_nchw_sum663// CHECK-SAME: dilations = dense<1> : tensor<2xi64>664// CHECK-SAME: strides = dense<1> : tensor<2xi64>665// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x1x4x4xf32>, memref<3x3xf32>)666// CHECK-SAME: outs(%{{.+}} : memref<1x1x2x2xf32>)667func.func @pooling_nchw_sum(%input: memref<1x1x4x4xf32>, %fake: memref<3x3xf32>, %output: memref<1x1x2x2xf32>) {668 linalg.pooling_nchw_sum {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}669 ins(%input, %fake: memref<1x1x4x4xf32>, memref<3x3xf32>)670 outs(%output: memref<1x1x2x2xf32>)671 return672}673 674// -----675 676// CHECK-LABEL: func @pooling_ncw_sum677// CHECK: linalg.pooling_ncw_sum678// CHECK-SAME: dilations = dense<1> : tensor<1xi64>679// CHECK-SAME: strides = dense<1> : tensor<1xi64>680// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x1x4xf32>, memref<3xf32>)681// CHECK-SAME: outs(%{{.+}} : memref<1x1x2xf32>)682func.func @pooling_ncw_sum(%input: memref<1x1x4xf32>, %fake: memref<3xf32>, %output: memref<1x1x2xf32>) {683 linalg.pooling_ncw_sum {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}684 ins(%input, %fake: memref<1x1x4xf32>, memref<3xf32>)685 outs(%output: memref<1x1x2xf32>)686 return687}688 689// -----690 691// CHECK-LABEL: func @pooling_nhwc_max_tensor692// CHECK: %{{.+}} = linalg.pooling_nhwc_max693// CHECK-SAME: dilations = dense<1> : tensor<2xi64>694// CHECK-SAME: strides = dense<1> : tensor<2xi64>695// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xf32>, tensor<3x3xf32>)696// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>697func.func @pooling_nhwc_max_tensor(%input: tensor<1x4x4x1xf32>) -> tensor<1x2x2x1xf32> {698 %fake = tensor.empty() : tensor<3x3xf32>699 %init = tensor.empty() : tensor<1x2x2x1xf32>700 %cst = arith.constant 0.000000e+00 : f32701 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>702 %res = linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}703 ins(%input, %fake: tensor<1x4x4x1xf32>, tensor<3x3xf32>)704 outs(%fill: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>705 return %res : tensor<1x2x2x1xf32>706}707 708// -----709// CHECK-LABEL: func @pooling_nwc_max_tensor710// CHECK: %{{.+}} = linalg.pooling_nwc_max711// CHECK-SAME: dilations = dense<1> : tensor<1xi64>712// CHECK-SAME: strides = dense<1> : tensor<1xi64>713// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xf32>, tensor<3xf32>)714// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xf32>) -> tensor<1x2x1xf32>715func.func @pooling_nwc_max_tensor(%input: tensor<1x4x1xf32>) -> tensor<1x2x1xf32> {716 %fake = tensor.empty() : tensor<3xf32>717 %init = tensor.empty() : tensor<1x2x1xf32>718 %cst = arith.constant 0.000000e+00 : f32719 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x1xf32>) -> tensor<1x2x1xf32>720 %res = linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}721 ins(%input, %fake: tensor<1x4x1xf32>, tensor<3xf32>)722 outs(%fill: tensor<1x2x1xf32>) -> tensor<1x2x1xf32>723 return %res : tensor<1x2x1xf32>724}725 726// -----727// CHECK-LABEL: func @pooling_nchw_max_tensor728// CHECK: %{{.+}} = linalg.pooling_nchw_max729// CHECK-SAME: dilations = dense<1> : tensor<2xi64>730// CHECK-SAME: strides = dense<1> : tensor<2xi64>731// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x1x4x4xf32>, tensor<3x3xf32>)732// CHECK-SAME: outs(%{{.+}} : tensor<1x1x2x2xf32>) -> tensor<1x1x2x2xf32>733 734func.func @pooling_nchw_max_tensor(%input: tensor<1x1x4x4xf32>) -> tensor<1x1x2x2xf32> {735 %fake = tensor.empty() : tensor<3x3xf32>736 %init = tensor.empty() : tensor<1x1x2x2xf32>737 %cst = arith.constant 0.000000e+00 : f32738 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x1x2x2xf32>) -> tensor<1x1x2x2xf32>739 %res = linalg.pooling_nchw_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}740 ins(%input, %fake: tensor<1x1x4x4xf32>, tensor<3x3xf32>)741 outs(%fill: tensor<1x1x2x2xf32>) -> tensor<1x1x2x2xf32>742 return %res : tensor<1x1x2x2xf32>743}744 745// -----746// CHECK-LABEL: func @pooling_ncw_max_tensor747// CHECK: %{{.+}} = linalg.pooling_ncw_max748// CHECK-SAME: dilations = dense<1> : tensor<1xi64>749// CHECK-SAME: strides = dense<1> : tensor<1xi64>750// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x1x4xf32>, tensor<3xf32>)751// CHECK-SAME: outs(%{{.+}} : tensor<1x1x2xf32>) -> tensor<1x1x2xf32>752 753func.func @pooling_ncw_max_tensor(%input: tensor<1x1x4xf32>) -> tensor<1x1x2xf32> {754 %fake = tensor.empty() : tensor<3xf32>755 %init = tensor.empty() : tensor<1x1x2xf32>756 %cst = arith.constant 0.000000e+00 : f32757 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x1x2xf32>) -> tensor<1x1x2xf32>758 %res = linalg.pooling_ncw_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}759 ins(%input, %fake: tensor<1x1x4xf32>, tensor<3xf32>)760 outs(%fill: tensor<1x1x2xf32>) -> tensor<1x1x2xf32>761 return %res : tensor<1x1x2xf32>762}763 764// -----765 766// CHECK-LABEL: func @pooling_nhwc_max767// CHECK: linalg.pooling_nhwc_max768// CHECK-SAME: dilations = dense<1> : tensor<2xi64>769// CHECK-SAME: strides = dense<1> : tensor<2xi64>770// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x1xf32>, memref<3x3xf32>)771// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x1xf32>)772func.func @pooling_nhwc_max(%input: memref<1x4x4x1xf32>, %fake: memref<3x3xf32>, %output: memref<1x2x2x1xf32>) {773 linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}774 ins(%input, %fake: memref<1x4x4x1xf32>, memref<3x3xf32>)775 outs(%output: memref<1x2x2x1xf32>)776 return777}778 779// -----780 781// CHECK-LABEL: func @pooling_nwc_max782// CHECK: linalg.pooling_nwc_max783// CHECK-SAME: dilations = dense<1> : tensor<1xi64>784// CHECK-SAME: strides = dense<1> : tensor<1xi64>785// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x1xf32>, memref<3xf32>)786// CHECK-SAME: outs(%{{.+}} : memref<1x2x1xf32>)787func.func @pooling_nwc_max(%input: memref<1x4x1xf32>, %fake: memref<3xf32>, %output: memref<1x2x1xf32>) {788 linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}789 ins(%input, %fake: memref<1x4x1xf32>, memref<3xf32>)790 outs(%output: memref<1x2x1xf32>)791 return792}793 794// -----795 796// CHECK-LABEL: func @pooling_nhwc_i8_max_tensor797// CHECK: %{{.+}} = linalg.pooling_nhwc_max798// CHECK-SAME: dilations = dense<1> : tensor<2xi64>799// CHECK-SAME: strides = dense<1> : tensor<2xi64>800// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xi8>, tensor<3x3xi8>)801// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xi8>) -> tensor<1x2x2x1xi8>802func.func @pooling_nhwc_i8_max_tensor(%input: tensor<1x4x4x1xi8>) -> tensor<1x2x2x1xi8> {803 %fake = tensor.empty() : tensor<3x3xi8>804 %init = tensor.empty() : tensor<1x2x2x1xi8>805 %cst = arith.constant 0 : i8806 %fill = linalg.fill ins(%cst : i8) outs(%init : tensor<1x2x2x1xi8>) -> tensor<1x2x2x1xi8>807 %res = linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}808 ins(%input, %fake: tensor<1x4x4x1xi8>, tensor<3x3xi8>)809 outs(%fill: tensor<1x2x2x1xi8>) -> tensor<1x2x2x1xi8>810 return %res : tensor<1x2x2x1xi8>811}812 813// -----814 815// CHECK-LABEL: func @pooling_nwc_i8_max_tensor816// CHECK: %{{.+}} = linalg.pooling_nwc_max817// CHECK-SAME: dilations = dense<1> : tensor<1xi64>818// CHECK-SAME: strides = dense<1> : tensor<1xi64>819// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xi8>, tensor<3xi8>)820// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xi8>) -> tensor<1x2x1xi8>821func.func @pooling_nwc_i8_max_tensor(%input: tensor<1x4x1xi8>) -> tensor<1x2x1xi8> {822 %fake = tensor.empty() : tensor<3xi8>823 %init = tensor.empty() : tensor<1x2x1xi8>824 %cst = arith.constant 0 : i8825 %fill = linalg.fill ins(%cst : i8) outs(%init : tensor<1x2x1xi8>) -> tensor<1x2x1xi8>826 %res = linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}827 ins(%input, %fake: tensor<1x4x1xi8>, tensor<3xi8>)828 outs(%fill: tensor<1x2x1xi8>) -> tensor<1x2x1xi8>829 return %res : tensor<1x2x1xi8>830}831 832// -----833 834// CHECK-LABEL: func @pooling_nhwc_i8_max835// CHECK: linalg.pooling_nhwc_max836// CHECK-SAME: dilations = dense<1> : tensor<2xi64>837// CHECK-SAME: strides = dense<1> : tensor<2xi64>838// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x1xi8>, memref<3x3xi8>)839// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x1xi8>)840func.func @pooling_nhwc_i8_max(%input: memref<1x4x4x1xi8>, %fake: memref<3x3xi8>, %output: memref<1x2x2x1xi8>) {841 linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}842 ins(%input, %fake: memref<1x4x4x1xi8>, memref<3x3xi8>)843 outs(%output: memref<1x2x2x1xi8>)844 return845}846 847// -----848 849// CHECK-LABEL: func @pooling_nwc_i8_max850// CHECK: linalg.pooling_nwc_max851// CHECK-SAME: dilations = dense<1> : tensor<1xi64>852// CHECK-SAME: strides = dense<1> : tensor<1xi64>853// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x1xi8>, memref<3xi8>)854// CHECK-SAME: outs(%{{.+}} : memref<1x2x1xi8>)855func.func @pooling_nwc_i8_max(%input: memref<1x4x1xi8>, %fake: memref<3xi8>, %output: memref<1x2x1xi8>) {856 linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}857 ins(%input, %fake: memref<1x4x1xi8>, memref<3xi8>)858 outs(%output: memref<1x2x1xi8>)859 return860}861 862// -----863 864// CHECK-LABEL: func @pooling_nhwc_i16_max_tensor865// CHECK: %{{.+}} = linalg.pooling_nhwc_max866// CHECK-SAME: dilations = dense<1> : tensor<2xi64>867// CHECK-SAME: strides = dense<1> : tensor<2xi64>868// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xi16>, tensor<3x3xi16>)869// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xi16>) -> tensor<1x2x2x1xi16>870func.func @pooling_nhwc_i16_max_tensor(%input: tensor<1x4x4x1xi16>) -> tensor<1x2x2x1xi16> {871 %fake = tensor.empty() : tensor<3x3xi16>872 %init = tensor.empty() : tensor<1x2x2x1xi16>873 %cst = arith.constant 0 : i16874 %fill = linalg.fill ins(%cst : i16) outs(%init : tensor<1x2x2x1xi16>) -> tensor<1x2x2x1xi16>875 %res = linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}876 ins(%input, %fake: tensor<1x4x4x1xi16>, tensor<3x3xi16>)877 outs(%fill: tensor<1x2x2x1xi16>) -> tensor<1x2x2x1xi16>878 return %res : tensor<1x2x2x1xi16>879}880 881// -----882 883// CHECK-LABEL: func @pooling_nwc_i16_max_tensor884// CHECK: %{{.+}} = linalg.pooling_nwc_max885// CHECK-SAME: dilations = dense<1> : tensor<1xi64>886// CHECK-SAME: strides = dense<1> : tensor<1xi64>887// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xi16>, tensor<3xi16>)888// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xi16>) -> tensor<1x2x1xi16>889func.func @pooling_nwc_i16_max_tensor(%input: tensor<1x4x1xi16>) -> tensor<1x2x1xi16> {890 %fake = tensor.empty() : tensor<3xi16>891 %init = tensor.empty() : tensor<1x2x1xi16>892 %cst = arith.constant 0 : i16893 %fill = linalg.fill ins(%cst : i16) outs(%init : tensor<1x2x1xi16>) -> tensor<1x2x1xi16>894 %res = linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}895 ins(%input, %fake: tensor<1x4x1xi16>, tensor<3xi16>)896 outs(%fill: tensor<1x2x1xi16>) -> tensor<1x2x1xi16>897 return %res : tensor<1x2x1xi16>898}899 900// -----901 902// CHECK-LABEL: func @pooling_nhwc_i16_max903// CHECK: linalg.pooling_nhwc_max904// CHECK-SAME: dilations = dense<1> : tensor<2xi64>905// CHECK-SAME: strides = dense<1> : tensor<2xi64>906// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x1xi16>, memref<3x3xi16>)907// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x1xi16>)908func.func @pooling_nhwc_i16_max(%input: memref<1x4x4x1xi16>, %fake: memref<3x3xi16>, %output: memref<1x2x2x1xi16>) {909 linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}910 ins(%input, %fake: memref<1x4x4x1xi16>, memref<3x3xi16>)911 outs(%output: memref<1x2x2x1xi16>)912 return913}914 915// -----916 917// CHECK-LABEL: func @pooling_nwc_i16_max918// CHECK: linalg.pooling_nwc_max919// CHECK-SAME: dilations = dense<1> : tensor<1xi64>920// CHECK-SAME: strides = dense<1> : tensor<1xi64>921// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x1xi16>, memref<3xi16>)922// CHECK-SAME: outs(%{{.+}} : memref<1x2x1xi16>)923func.func @pooling_nwc_i16_max(%input: memref<1x4x1xi16>, %fake: memref<3xi16>, %output: memref<1x2x1xi16>) {924 linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}925 ins(%input, %fake: memref<1x4x1xi16>, memref<3xi16>)926 outs(%output: memref<1x2x1xi16>)927 return928}929 930// -----931 932// CHECK-LABEL: func @pooling_nhwc_i32_max_tensor933// CHECK: %{{.+}} = linalg.pooling_nhwc_max934// CHECK-SAME: dilations = dense<1> : tensor<2xi64>935// CHECK-SAME: strides = dense<1> : tensor<2xi64>936// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xi32>, tensor<3x3xi32>)937// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xi32>) -> tensor<1x2x2x1xi32>938func.func @pooling_nhwc_i32_max_tensor(%input: tensor<1x4x4x1xi32>) -> tensor<1x2x2x1xi32> {939 %fake = tensor.empty() : tensor<3x3xi32>940 %init = tensor.empty() : tensor<1x2x2x1xi32>941 %cst = arith.constant 0 : i32942 %fill = linalg.fill ins(%cst : i32) outs(%init : tensor<1x2x2x1xi32>) -> tensor<1x2x2x1xi32>943 %res = linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}944 ins(%input, %fake: tensor<1x4x4x1xi32>, tensor<3x3xi32>)945 outs(%fill: tensor<1x2x2x1xi32>) -> tensor<1x2x2x1xi32>946 return %res : tensor<1x2x2x1xi32>947}948 949// -----950 951// CHECK-LABEL: func @pooling_nwc_i32_max_tensor952// CHECK: %{{.+}} = linalg.pooling_nwc_max953// CHECK-SAME: dilations = dense<1> : tensor<1xi64>954// CHECK-SAME: strides = dense<1> : tensor<1xi64>955// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xi32>, tensor<3xi32>)956// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xi32>) -> tensor<1x2x1xi32>957func.func @pooling_nwc_i32_max_tensor(%input: tensor<1x4x1xi32>) -> tensor<1x2x1xi32> {958 %fake = tensor.empty() : tensor<3xi32>959 %init = tensor.empty() : tensor<1x2x1xi32>960 %cst = arith.constant 0 : i32961 %fill = linalg.fill ins(%cst : i32) outs(%init : tensor<1x2x1xi32>) -> tensor<1x2x1xi32>962 %res = linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}963 ins(%input, %fake: tensor<1x4x1xi32>, tensor<3xi32>)964 outs(%fill: tensor<1x2x1xi32>) -> tensor<1x2x1xi32>965 return %res : tensor<1x2x1xi32>966}967 968// -----969 970// CHECK-LABEL: func @pooling_nhwc_i32_max971// CHECK: linalg.pooling_nhwc_max972// CHECK-SAME: dilations = dense<1> : tensor<2xi64>973// CHECK-SAME: strides = dense<1> : tensor<2xi64>974// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x1xi32>, memref<3x3xi32>)975// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x1xi32>)976func.func @pooling_nhwc_i32_max(%input: memref<1x4x4x1xi32>, %fake: memref<3x3xi32>, %output: memref<1x2x2x1xi32>) {977 linalg.pooling_nhwc_max {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}978 ins(%input, %fake: memref<1x4x4x1xi32>, memref<3x3xi32>)979 outs(%output: memref<1x2x2x1xi32>)980 return981}982 983// -----984 985// CHECK-LABEL: func @pooling_nwc_i32_max986// CHECK: linalg.pooling_nwc_max987// CHECK-SAME: dilations = dense<1> : tensor<1xi64>988// CHECK-SAME: strides = dense<1> : tensor<1xi64>989// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x1xi32>, memref<3xi32>)990// CHECK-SAME: outs(%{{.+}} : memref<1x2x1xi32>)991func.func @pooling_nwc_i32_max(%input: memref<1x4x1xi32>, %fake: memref<3xi32>, %output: memref<1x2x1xi32>) {992 linalg.pooling_nwc_max {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}993 ins(%input, %fake: memref<1x4x1xi32>, memref<3xi32>)994 outs(%output: memref<1x2x1xi32>)995 return996}997 998 999// -----1000 1001// CHECK-LABEL: func @pooling_nhwc_min_tensor1002// CHECK: %{{.+}} = linalg.pooling_nhwc_min1003// CHECK-SAME: dilations = dense<1> : tensor<2xi64>1004// CHECK-SAME: strides = dense<1> : tensor<2xi64>1005// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x1xf32>, tensor<3x3xf32>)1006// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>1007func.func @pooling_nhwc_min_tensor(%input: tensor<1x4x4x1xf32>) -> tensor<1x2x2x1xf32> {1008 %fake = tensor.empty() : tensor<3x3xf32>1009 %init = tensor.empty() : tensor<1x2x2x1xf32>1010 %cst = arith.constant 0.000000e+00 : f321011 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>1012 %res = linalg.pooling_nhwc_min {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}1013 ins(%input, %fake: tensor<1x4x4x1xf32>, tensor<3x3xf32>)1014 outs(%fill: tensor<1x2x2x1xf32>) -> tensor<1x2x2x1xf32>1015 return %res : tensor<1x2x2x1xf32>1016}1017 1018// -----1019 1020// CHECK-LABEL: func @pooling_nwc_min_tensor1021// CHECK: %{{.+}} = linalg.pooling_nwc_min1022// CHECK-SAME: dilations = dense<1> : tensor<1xi64>1023// CHECK-SAME: strides = dense<1> : tensor<1xi64>1024// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x1xf32>, tensor<3xf32>)1025// CHECK-SAME: outs(%{{.+}} : tensor<1x2x1xf32>) -> tensor<1x2x1xf32>1026func.func @pooling_nwc_min_tensor(%input: tensor<1x4x1xf32>) -> tensor<1x2x1xf32> {1027 %fake = tensor.empty() : tensor<3xf32>1028 %init = tensor.empty() : tensor<1x2x1xf32>1029 %cst = arith.constant 0.000000e+00 : f321030 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x1xf32>) -> tensor<1x2x1xf32>1031 %res = linalg.pooling_nwc_min {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}1032 ins(%input, %fake: tensor<1x4x1xf32>, tensor<3xf32>)1033 outs(%fill: tensor<1x2x1xf32>) -> tensor<1x2x1xf32>1034 return %res : tensor<1x2x1xf32>1035}1036 1037// -----1038 1039// CHECK-LABEL: func @pooling_nhwc_min1040// CHECK: linalg.pooling_nhwc_min1041// CHECK-SAME: dilations = dense<1> : tensor<2xi64>1042// CHECK-SAME: strides = dense<1> : tensor<2xi64>1043// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x1xf32>, memref<3x3xf32>)1044// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x1xf32>)1045func.func @pooling_nhwc_min(%input: memref<1x4x4x1xf32>, %fake: memref<3x3xf32>, %output: memref<1x2x2x1xf32>) {1046 linalg.pooling_nhwc_min {dilations = dense<1> : tensor<2xi64>, strides = dense<1> : tensor<2xi64>}1047 ins(%input, %fake: memref<1x4x4x1xf32>, memref<3x3xf32>)1048 outs(%output: memref<1x2x2x1xf32>)1049 return1050}1051 1052// -----1053 1054// CHECK-LABEL: func @pooling_nwc_min1055// CHECK: linalg.pooling_nwc_min1056// CHECK-SAME: dilations = dense<1> : tensor<1xi64>1057// CHECK-SAME: strides = dense<1> : tensor<1xi64>1058// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x1xf32>, memref<3xf32>)1059// CHECK-SAME: outs(%{{.+}} : memref<1x2x1xf32>)1060func.func @pooling_nwc_min(%input: memref<1x4x1xf32>, %fake: memref<3xf32>, %output: memref<1x2x1xf32>) {1061 linalg.pooling_nwc_min {dilations = dense<1> : tensor<1xi64>, strides = dense<1> : tensor<1xi64>}1062 ins(%input, %fake: memref<1x4x1xf32>, memref<3xf32>)1063 outs(%output: memref<1x2x1xf32>)1064 return1065}1066 1067// -----1068 1069// CHECK-LABEL: func @pooling_ndhwc_sum_tensor1070// CHECK: %{{.+}} = linalg.pooling_ndhwc_sum1071// CHECK-SAME: dilations = dense<1> : tensor<3xi64>1072// CHECK-SAME: strides = dense<1> : tensor<3xi64>1073// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x4x1xf32>, tensor<3x3x3xf32>)1074// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1075func.func @pooling_ndhwc_sum_tensor(%input: tensor<1x4x4x4x1xf32>) -> tensor<1x2x2x2x1xf32> {1076 %fake = tensor.empty() : tensor<3x3x3xf32>1077 %init = tensor.empty() : tensor<1x2x2x2x1xf32>1078 %cst = arith.constant 0.000000e+00 : f321079 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1080 %res = linalg.pooling_ndhwc_sum {dilations = dense<1> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>}1081 ins(%input, %fake: tensor<1x4x4x4x1xf32>, tensor<3x3x3xf32>)1082 outs(%fill: tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1083 return %res : tensor<1x2x2x2x1xf32>1084}1085 1086// -----1087 1088// CHECK-LABEL: func @pooling_ndhwc_sum1089// CHECK: linalg.pooling_ndhwc_sum1090// CHECK-SAME: dilations = dense<1> : tensor<3xi64>1091// CHECK-SAME: strides = dense<1> : tensor<3xi64>1092// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x4x1xf32>, memref<3x3x3xf32>)1093// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x2x1xf32>)1094func.func @pooling_ndhwc_sum(%input: memref<1x4x4x4x1xf32>, %fake: memref<3x3x3xf32>, %output: memref<1x2x2x2x1xf32>) {1095 linalg.pooling_ndhwc_sum {dilations = dense<1> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>}1096 ins(%input, %fake: memref<1x4x4x4x1xf32>, memref<3x3x3xf32>)1097 outs(%output: memref<1x2x2x2x1xf32>)1098 return1099}1100 1101// -----1102 1103// CHECK-LABEL: func @pooling_ndhwc_max_tensor1104// CHECK: %{{.+}} = linalg.pooling_ndhwc_max1105// CHECK-SAME: dilations = dense<1> : tensor<3xi64>1106// CHECK-SAME: strides = dense<1> : tensor<3xi64>1107// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x4x1xf32>, tensor<3x3x3xf32>)1108// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1109func.func @pooling_ndhwc_max_tensor(%input: tensor<1x4x4x4x1xf32>) -> tensor<1x2x2x2x1xf32> {1110 %fake = tensor.empty() : tensor<3x3x3xf32>1111 %init = tensor.empty() : tensor<1x2x2x2x1xf32>1112 %cst = arith.constant 0.000000e+00 : f321113 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1114 %res = linalg.pooling_ndhwc_max {dilations = dense<1> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>}1115 ins(%input, %fake: tensor<1x4x4x4x1xf32>, tensor<3x3x3xf32>)1116 outs(%fill: tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1117 return %res : tensor<1x2x2x2x1xf32>1118}1119 1120// -----1121 1122// CHECK-LABEL: func @pooling_ndhwc_max1123// CHECK: linalg.pooling_ndhwc_max1124// CHECK-SAME: dilations = dense<1> : tensor<3xi64>1125// CHECK-SAME: strides = dense<1> : tensor<3xi64>1126// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x4x1xf32>, memref<3x3x3xf32>)1127// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x2x1xf32>)1128func.func @pooling_ndhwc_max(%input: memref<1x4x4x4x1xf32>, %fake: memref<3x3x3xf32>, %output: memref<1x2x2x2x1xf32>) {1129 linalg.pooling_ndhwc_max {dilations = dense<1> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>}1130 ins(%input, %fake: memref<1x4x4x4x1xf32>, memref<3x3x3xf32>)1131 outs(%output: memref<1x2x2x2x1xf32>)1132 return1133}1134 1135// -----1136 1137// CHECK-LABEL: func @pooling_ndhwc_min_tensor1138// CHECK: %{{.+}} = linalg.pooling_ndhwc_min1139// CHECK-SAME: dilations = dense<1> : tensor<3xi64>1140// CHECK-SAME: strides = dense<1> : tensor<3xi64>1141// CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<1x4x4x4x1xf32>, tensor<3x3x3xf32>)1142// CHECK-SAME: outs(%{{.+}} : tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1143func.func @pooling_ndhwc_min_tensor(%input: tensor<1x4x4x4x1xf32>) -> tensor<1x2x2x2x1xf32> {1144 %fake = tensor.empty() : tensor<3x3x3xf32>1145 %init = tensor.empty() : tensor<1x2x2x2x1xf32>1146 %cst = arith.constant 0.000000e+00 : f321147 %fill = linalg.fill ins(%cst : f32) outs(%init : tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1148 %res = linalg.pooling_ndhwc_min {dilations = dense<1> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>}1149 ins(%input, %fake: tensor<1x4x4x4x1xf32>, tensor<3x3x3xf32>)1150 outs(%fill: tensor<1x2x2x2x1xf32>) -> tensor<1x2x2x2x1xf32>1151 return %res : tensor<1x2x2x2x1xf32>1152}1153 1154// -----1155 1156// CHECK-LABEL: func @pooling_ndhwc_min1157// CHECK: linalg.pooling_ndhwc_min1158// CHECK-SAME: dilations = dense<1> : tensor<3xi64>1159// CHECK-SAME: strides = dense<1> : tensor<3xi64>1160// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<1x4x4x4x1xf32>, memref<3x3x3xf32>)1161// CHECK-SAME: outs(%{{.+}} : memref<1x2x2x2x1xf32>)1162func.func @pooling_ndhwc_min(%input: memref<1x4x4x4x1xf32>, %fake: memref<3x3x3xf32>, %output: memref<1x2x2x2x1xf32>) {1163 linalg.pooling_ndhwc_min {dilations = dense<1> : tensor<3xi64>, strides = dense<1> : tensor<3xi64>}1164 ins(%input, %fake: memref<1x4x4x4x1xf32>, memref<3x3x3xf32>)1165 outs(%output: memref<1x2x2x2x1xf32>)1166 return1167}1168 1169// -----1170 1171#map0 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d0, d1 * 2, d2 * 2 + d5, d6)>1172#map1 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d4, d5, d6, d3)>1173#map2 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d0, d1, d2, d3)>1174func.func @conv_interface_wrong_input_indexing_map(1175 %arg0 : tensor<?x?x?x?xf32>, %arg2 : tensor<?x?x?x?xf32>, %arg1 : tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32> {1176 // expected-error @+1 {{unexpected input index map for convolutions}}1177 %0 = "linalg.conv_2d_nhwc_hwcf"(%arg0, %arg1, %arg2) ({1178 ^bb0(%arg3: f32, %arg4: f32, %arg5 : f32):1179 %1 = "arith.mulf"(%arg3, %arg4) : (f32, f32) -> f321180 %2 = "arith.addf"(%arg5, %1) : (f32, f32) -> f321181 "linalg.yield"(%2) : (f32) -> ()1182 }) {dilations = dense<1> : tensor<2xi64>, linalg.memoized_indexing_maps = [#map0, #map1, #map2], operandSegmentSizes = array<i32: 2, 1>, strides = dense<2> : tensor<2xi64>} : (tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>, tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>1183 return %0 : tensor<?x?x?x?xf32>1184}1185 1186// -----1187 1188#map0 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d0, d1 + d4, d2 + d5, d6)>1189#map1 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d4, d5, d6, d3, d5 + 1)>1190#map2 = affine_map<(d0, d1, d2, d3, d4, d5, d6) -> (d0, d1, d2, d3)>1191func.func @conv_interface_wrong_num_operands(1192 %arg0 : tensor<?x?x?x?xf32>, %arg1 : tensor<?x?x?x?x?xf32>, %arg2 : tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32> {1193 // expected-error @+1 {{expected output/filter indexing maps to be projected permutations}}1194 %0 = "linalg.conv_2d_nhwc_hwcf"(%arg0, %arg1, %arg2) ({1195 ^bb0(%arg3: f32, %arg4: f32, %arg5 : f32):1196 %1 = "arith.mulf"(%arg3, %arg4) : (f32, f32) -> f321197 %2 = "arith.addf"(%arg5, %1) : (f32, f32) -> f321198 "linalg.yield"(%2) : (f32) -> ()1199 }) {dilations = dense<1> : tensor<2xi64>, linalg.memoized_indexing_maps = [#map0, #map1, #map2], operandSegmentSizes = array<i32: 2, 1>, strides = dense<1> : tensor<2xi64>} : (tensor<?x?x?x?xf32>, tensor<?x?x?x?x?xf32>, tensor<?x?x?x?xf32>) -> tensor<?x?x?x?xf32>1200 return %0 : tensor<?x?x?x?xf32>1201}1202 1203// -----1204 1205func.func @batch_reduce_matmul(%arg0: tensor<8x128x256xf32>, %arg1: tensor<8x256x512xf32>, %arg2: tensor<128x512xf32>) -> tensor<128x512xf32> {1206 // CHECK: %{{.+}} = linalg.batch_reduce_matmul1207 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<8x128x256xf32>, tensor<8x256x512xf32>)1208 // CHECK-SAME: outs(%{{.+}} : tensor<128x512xf32>) -> tensor<128x512xf32>1209 %0 = linalg.batch_reduce_matmul ins(%arg0, %arg1 : tensor<8x128x256xf32>, tensor<8x256x512xf32>) outs(%arg2: tensor<128x512xf32>) -> tensor<128x512xf32>1210 return %0: tensor<128x512xf32>1211}1212 1213// -----1214 1215func.func @batch_reduce_matmul(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?xf32>) {1216 // CHECK: linalg.batch_reduce_matmul1217 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)1218 // CHECK-SAME: outs(%{{.+}} : memref<?x?xf32>)1219 linalg.batch_reduce_matmul ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?xf32>)1220 return1221}1222 1223// -----1224 1225// CHECK-LABEL: func @matmul_transpose_a_explicit1226// CHECK: linalg.matmul1227// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<5x3xf32>, memref<5x7xf32>)1228// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1229func.func @matmul_transpose_a_explicit(%arg0: memref<5x3xf32>, %arg1: memref<5x7xf32>, %arg2: memref<3x7xf32>) {1230 linalg.matmul indexing_maps = [1231 affine_map<(d0, d1, d2) -> (d2, d0)>,1232 affine_map<(d0, d1, d2) -> (d2, d1)>,1233 affine_map<(d0, d1, d2) -> (d0, d1)>1234 ]1235 ins(%arg0, %arg1 : memref<5x3xf32>, memref<5x7xf32>)1236 outs(%arg2: memref<3x7xf32>)1237 return1238}1239 1240// -----1241 1242func.func @matmul_transpose_b_explicit(%arg0: memref<3x5xf32>, %arg1: memref<7x5xf32>, %arg2: memref<3x7xf32>) {1243 linalg.matmul indexing_maps = [1244 affine_map<(d0, d1, d2) -> (d0, d2)>,1245 affine_map<(d0, d1, d2) -> (d1, d2)>,1246 affine_map<(d0, d1, d2) -> (d0, d1)>1247 ]1248 ins(%arg0, %arg1 : memref<3x5xf32>, memref<7x5xf32>)1249 outs(%arg2: memref<3x7xf32>)1250 return1251}1252 1253// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d0, d2)>1254// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d1, d2)>1255// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1256 1257// CHECK-LABEL: func.func @matmul_transpose_b_explicit(1258// CHECK-SAME: %[[VAL_0:.*]]: memref<3x5xf32>,1259// CHECK-SAME: %[[VAL_1:.*]]: memref<7x5xf32>,1260// CHECK-SAME: %[[VAL_2:.*]]: memref<3x7xf32>) {1261// CHECK: linalg.matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<3x5xf32>, memref<7x5xf32>) outs(%[[VAL_2]] : memref<3x7xf32>)1262// CHECK: return1263// CHECK: }1264 1265// -----1266 1267func.func @matmul_transpose_a_b_explicit(%arg0: memref<5x3xf32>, %arg1: memref<7x5xf32>, %arg2: memref<3x7xf32>) {1268 linalg.matmul indexing_maps = [1269 affine_map<(d0, d1, d2) -> (d2, d0)>,1270 affine_map<(d0, d1, d2) -> (d1, d2)>,1271 affine_map<(d0, d1, d2) -> (d0, d1)>1272 ]1273 ins(%arg0, %arg1 : memref<5x3xf32>, memref<7x5xf32>)1274 outs(%arg2: memref<3x7xf32>)1275 return1276}1277 1278// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d2, d0)>1279// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d1, d2)>1280// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1281 1282// CHECK-LABEL: func.func @matmul_transpose_a_b_explicit(1283// CHECK-SAME: %[[VAL_0:.*]]: memref<5x3xf32>,1284// CHECK-SAME: %[[VAL_1:.*]]: memref<7x5xf32>,1285// CHECK-SAME: %[[VAL_2:.*]]: memref<3x7xf32>) {1286// CHECK: linalg.matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<5x3xf32>, memref<7x5xf32>) outs(%[[VAL_2]] : memref<3x7xf32>)1287// CHECK: return1288// CHECK: }1289 1290// -----1291 1292func.func @matmul_bcast_a(%arg0: memref<5xf32>, %arg1: memref<5x7xf32>, %arg2: memref<3x7xf32>) {1293 linalg.matmul indexing_maps = [1294 affine_map<(d0, d1, d2) -> (d2)>,1295 affine_map<(d0, d1, d2) -> (d2, d1)>,1296 affine_map<(d0, d1, d2) -> (d0, d1)>1297 ]1298 ins(%arg0, %arg1 : memref<5xf32>, memref<5x7xf32>) outs(%arg2: memref<3x7xf32>)1299 return1300}1301 1302// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d2)>1303// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d2, d1)>1304// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1305// CHECK-LABEL: func @matmul_bcast_a1306// CHECK: linalg.matmul1307// CHECK-SAME: indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]]1308// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<5xf32>, memref<5x7xf32>)1309// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1310 1311// -----1312 1313func.func @matmul_bcast_a_dim1(%arg0: memref<5xf32>, %arg1: memref<5x7xf32>, %arg2: memref<3x7xf32>) {1314 linalg.matmul indexing_maps = [1315 affine_map<(d0, d1, d2) -> (d2)>,1316 affine_map<(d0, d1, d2) -> (d2, d1)>,1317 affine_map<(d0, d1, d2) -> (d0, d1)>1318 ]1319 ins(%arg0, %arg1 : memref<5xf32>, memref<5x7xf32>) outs(%arg2: memref<3x7xf32>)1320 return1321}1322 1323// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d2)>1324// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d2, d1)>1325// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1326// CHECK-LABEL: func @matmul_bcast_a_dim11327// CHECK: linalg.matmul1328// CHECK-SAME: indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]]1329// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<5xf32>, memref<5x7xf32>)1330// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1331 1332// -----1333 1334func.func @matmul_bcast_b(%arg0: memref<3x5xf32>, %arg1: memref<5xf32>, %arg2: memref<3x7xf32>) {1335 linalg.matmul indexing_maps = [1336 affine_map<(d0, d1, d2) -> (d0, d2)>,1337 affine_map<(d0, d1, d2) -> (d2)>,1338 affine_map<(d0, d1, d2) -> (d0, d1)>1339 ]1340 ins(%arg0, %arg1 : memref<3x5xf32>, memref<5xf32>) outs(%arg2: memref<3x7xf32>)1341 return1342}1343 1344// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d0, d2)>1345// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d2)>1346// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1347// CHECK-LABEL: func @matmul_bcast_b1348// CHECK: linalg.matmul1349// CHECK-SAME: indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]]1350// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<3x5xf32>, memref<5xf32>)1351// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1352 1353// -----1354 1355func.func @matmul_bcast_a_b(%arg0: memref<5xf32>, %arg1: memref<5xf32>, %arg2: memref<3x7xf32>) {1356 linalg.matmul indexing_maps = [1357 affine_map<(d0, d1, d2) -> (d2)>,1358 affine_map<(d0, d1, d2) -> (d2)>,1359 affine_map<(d0, d1, d2) -> (d0, d1)>1360 ]1361 ins(%arg0, %arg1 : memref<5xf32>, memref<5xf32>) outs(%arg2: memref<3x7xf32>)1362 return1363}1364 1365// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d2)>1366// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1367 1368// CHECK-LABEL: func.func @matmul_bcast_a_b(1369// CHECK-SAME: %[[VAL_0:.*]]: memref<5xf32>, %[[VAL_1:.*]]: memref<5xf32>,1370// CHECK-SAME: %[[VAL_2:.*]]: memref<3x7xf32>) {1371// CHECK: linalg.matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_0]], #[[$ATTR_1]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<5xf32>, memref<5xf32>) outs(%[[VAL_2]] : memref<3x7xf32>)1372// CHECK: return1373// CHECK: }1374 1375// -----1376 1377func.func @matmul_bcast_b_dim1(%arg0: memref<3x5xf32>, %arg1: memref<5xf32>, %arg2: memref<3x7xf32>) {1378 linalg.matmul indexing_maps = [1379 affine_map<(d0, d1, d2) -> (d0, d2)>,1380 affine_map<(d0, d1, d2) -> (d2)>,1381 affine_map<(d0, d1, d2) -> (d0, d1)>1382 ]1383 ins(%arg0, %arg1 : memref<3x5xf32>, memref<5xf32>) outs(%arg2: memref<3x7xf32>)1384 return1385}1386 1387// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d0, d2)>1388// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d2)>1389// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1390// CHECK-LABEL: func @matmul_bcast_b_dim11391// CHECK: linalg.matmul1392// CHECK-SAME: indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]]1393// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<3x5xf32>, memref<5xf32>)1394// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1395 1396// -----1397 1398func.func @dynamic_matmul_bcast_a(%arg0: memref<?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) {1399 linalg.matmul indexing_maps = [1400 affine_map<(d0, d1, d2) -> (d2)>,1401 affine_map<(d0, d1, d2) -> (d2, d1)>,1402 affine_map<(d0, d1, d2) -> (d0, d1)>1403 ]1404 ins(%arg0, %arg1 : memref<?xf32>, memref<?x?xf32>) outs(%arg2: memref<?x?xf32>)1405 return1406}1407 1408// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d2)>1409// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d2, d1)>1410// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1411 1412// CHECK-LABEL: func.func @dynamic_matmul_bcast_a(1413// CHECK-SAME: %[[VAL_0:.*]]: memref<?xf32>,1414// CHECK-SAME: %[[VAL_1:.*]]: memref<?x?xf32>,1415// CHECK-SAME: %[[VAL_2:.*]]: memref<?x?xf32>) {1416// CHECK: linalg.matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<?xf32>, memref<?x?xf32>) outs(%[[VAL_2]] : memref<?x?xf32>)1417// CHECK: return1418// CHECK: }1419 1420// -----1421 1422func.func @matmul_bcast_a_transpose_b(%arg0: memref<5xf32>, %arg1: memref<7x5xf32>, %arg2: memref<3x7xf32>) {1423 linalg.matmul indexing_maps = [1424 affine_map<(d0, d1, d2) -> (d2)>,1425 affine_map<(d0, d1, d2) -> (d1, d2)>,1426 affine_map<(d0, d1, d2) -> (d0, d1)>1427 ]1428 ins(%arg0, %arg1 : memref<5xf32>, memref<7x5xf32>) outs(%arg2: memref<3x7xf32>)1429 return1430}1431 1432// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d2)>1433// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d1, d2)>1434// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1435 1436// CHECK-LABEL: func.func @matmul_bcast_a_transpose_b(1437// CHECK-SAME: %[[VAL_0:.*]]: memref<5xf32>,1438// CHECK-SAME: %[[VAL_1:.*]]: memref<7x5xf32>,1439// CHECK-SAME: %[[VAL_2:.*]]: memref<3x7xf32>) {1440// CHECK: linalg.matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<5xf32>, memref<7x5xf32>) outs(%[[VAL_2]] : memref<3x7xf32>)1441// CHECK: return1442// CHECK: }1443 1444// -----1445 1446func.func @matmul_bcast_b_transpose_a(%arg0: memref<5x3xf32>, %arg1: memref<5xf32>, %arg2: memref<3x7xf32>) {1447 linalg.matmul indexing_maps = [1448 affine_map<(d0, d1, d2) -> (d2, d0)>,1449 affine_map<(d0, d1, d2) -> (d2)>,1450 affine_map<(d0, d1, d2) -> (d0, d1)>1451 ]1452 ins(%arg0, %arg1 : memref<5x3xf32>, memref<5xf32>) outs(%arg2: memref<3x7xf32>)1453 return1454}1455 1456// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2) -> (d2, d0)>1457// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2) -> (d2)>1458// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1459 1460// CHECK-LABEL: func.func @matmul_bcast_b_transpose_a(1461// CHECK-SAME: %[[VAL_0:.*]]: memref<5x3xf32>,1462// CHECK-SAME: %[[VAL_1:.*]]: memref<5xf32>,1463// CHECK-SAME: %[[VAL_2:.*]]: memref<3x7xf32>) {1464// CHECK: linalg.matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<5x3xf32>, memref<5xf32>) outs(%[[VAL_2]] : memref<3x7xf32>)1465// CHECK: return1466// CHECK: }1467 1468// -----1469 1470// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d3)>1471// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>1472// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1473 1474// CHECK-LABEL: func.func @batch_matmul_bcast_k_to_fill_missing_dims_A(1475// CHECK-SAME: %[[VAL_0:.*]]: memref<5xf32>,1476// CHECK-SAME: %[[VAL_1:.*]]: memref<2x5x7xf32>,1477// CHECK-SAME: %[[VAL_2:.*]]: memref<2x3x7xf32>) {1478// CHECK: linalg.batch_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<5xf32>, memref<2x5x7xf32>) outs(%[[VAL_2]] : memref<2x3x7xf32>)1479// CHECK: return1480// CHECK: }1481func.func @batch_matmul_bcast_k_to_fill_missing_dims_A(%arg0: memref<5xf32>, %arg1: memref<2x5x7xf32>, %arg2: memref<2x3x7xf32>) {1482 linalg.batch_matmul indexing_maps = [1483 affine_map<(d0, d1, d2, d3) -> (d3)>,1484 affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1485 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1486 ]1487 ins(%arg0, %arg1 : memref<5xf32>, memref<2x5x7xf32>) outs(%arg2: memref<2x3x7xf32>)1488 return1489}1490 1491// -----1492 1493// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d3)>1494// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>1495// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1496 1497// CHECK-LABEL: func.func @batch_matmul_bcast_batch_dim_A(1498// CHECK-SAME: %[[VAL_0:.*]]: memref<3x5xf32>,1499// CHECK-SAME: %[[VAL_1:.*]]: memref<2x5x7xf32>,1500// CHECK-SAME: %[[VAL_2:.*]]: memref<2x3x7xf32>) {1501// CHECK: linalg.batch_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<3x5xf32>, memref<2x5x7xf32>) outs(%[[VAL_2]] : memref<2x3x7xf32>)1502// CHECK: return1503// CHECK: }1504func.func @batch_matmul_bcast_batch_dim_A(%arg0: memref<3x5xf32>, %arg1: memref<2x5x7xf32>, %arg2: memref<2x3x7xf32>) {1505 linalg.batch_matmul indexing_maps = [1506 affine_map<(d0, d1, d2, d3) -> (d1, d3)>,1507 affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1508 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1509 ]1510 ins(%arg0, %arg1 : memref<3x5xf32>, memref<2x5x7xf32>) outs(%arg2: memref<2x3x7xf32>)1511 return1512}1513 1514// -----1515 1516// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1517// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d3)>1518// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1519 1520// CHECK-LABEL: func.func @batch_matmul_bcast_batch_and_n_dim_B(1521// CHECK-SAME: %[[VAL_0:.*]]: memref<2x3x5xf32>,1522// CHECK-SAME: %[[VAL_1:.*]]: memref<5xf32>,1523// CHECK-SAME: %[[VAL_2:.*]]: memref<2x3x7xf32>) {1524// CHECK: linalg.batch_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<2x3x5xf32>, memref<5xf32>) outs(%[[VAL_2]] : memref<2x3x7xf32>)1525// CHECK: return1526// CHECK: }1527func.func @batch_matmul_bcast_batch_and_n_dim_B(%arg0: memref<2x3x5xf32>, %arg1: memref<5xf32>, %arg2: memref<2x3x7xf32>) {1528 linalg.batch_matmul indexing_maps = [1529 affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1530 affine_map<(d0, d1, d2, d3) -> (d3)>,1531 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1532 ]1533 ins(%arg0, %arg1 : memref<2x3x5xf32>, memref<5xf32>) outs(%arg2: memref<2x3x7xf32>)1534 return1535}1536 1537// -----1538 1539// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1540// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d3, d2)>1541// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1542 1543// CHECK-LABEL: func.func @batch_matmul_bcast_batch_dim_B(1544// CHECK-SAME: %[[VAL_0:.*]]: memref<2x3x5xf32>,1545// CHECK-SAME: %[[VAL_1:.*]]: memref<5x7xf32>,1546// CHECK-SAME: %[[VAL_2:.*]]: memref<2x3x7xf32>) {1547// CHECK: linalg.batch_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<2x3x5xf32>, memref<5x7xf32>) outs(%[[VAL_2]] : memref<2x3x7xf32>)1548// CHECK: return1549// CHECK: }1550 1551func.func @batch_matmul_bcast_batch_dim_B(%arg0: memref<2x3x5xf32>, %arg1: memref<5x7xf32>, %arg2: memref<2x3x7xf32>) {1552 linalg.batch_matmul indexing_maps = [1553 affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1554 affine_map<(d0, d1, d2, d3) -> (d3, d2)>,1555 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1556 ]1557 ins(%arg0, %arg1 : memref<2x3x5xf32>, memref<5x7xf32>) outs(%arg2: memref<2x3x7xf32>)1558 return1559}1560 1561// -----1562 1563// CHECK-LABEL: func @batch_matmul_explicit_transpose_A1564// CHECK: linalg.batch_matmul1565// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<2x5x3xf32>, memref<2x5x7xf32>)1566// CHECK-SAME: outs(%{{.+}} : memref<2x3x7xf32>)1567func.func @batch_matmul_explicit_transpose_A(%arg0: memref<2x5x3xf32>, %arg1: memref<2x5x7xf32>, %arg2: memref<2x3x7xf32>) {1568 linalg.batch_matmul indexing_maps = [1569 affine_map<(d0, d1, d2, d3) -> (d0, d3, d1)>,1570 affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1571 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1572 ]1573 ins(%arg0, %arg1 : memref<2x5x3xf32>, memref<2x5x7xf32>) outs(%arg2: memref<2x3x7xf32>)1574 return1575}1576 1577// -----1578 1579// CHECK-LABEL: func @batch_matmul_explicit_transpose_B1580// CHECK: linalg.batch_matmul1581// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<2x3x5xf32>, memref<2x7x5xf32>)1582// CHECK-SAME: outs(%{{.+}} : memref<2x3x7xf32>)1583func.func @batch_matmul_explicit_transpose_B(%arg0: memref<2x3x5xf32>, %arg1: memref<2x7x5xf32>, %arg2: memref<2x3x7xf32>) {1584 linalg.batch_matmul indexing_maps = [1585 affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1586 affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>,1587 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1588 ]1589 ins(%arg0, %arg1 : memref<2x3x5xf32>, memref<2x7x5xf32>) outs(%arg2: memref<2x3x7xf32>)1590 return1591}1592 1593// -----1594 1595// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d3)>1596// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>1597// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1598 1599// CHECK-LABEL: func.func @batch_matmul_bcast_A_transpose_B(1600// CHECK-SAME: %[[VAL_0:.*]]: memref<3x5xf32>,1601// CHECK-SAME: %[[VAL_1:.*]]: memref<2x7x5xf32>,1602// CHECK-SAME: %[[VAL_2:.*]]: memref<2x3x7xf32>) {1603// CHECK: linalg.batch_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[VAL_0]], %[[VAL_1]] : memref<3x5xf32>, memref<2x7x5xf32>) outs(%[[VAL_2]] : memref<2x3x7xf32>)1604// CHECK: return1605// CHECK: }1606func.func @batch_matmul_bcast_A_transpose_B(%arg0: memref<3x5xf32>, %arg1: memref<2x7x5xf32>, %arg2: memref<2x3x7xf32>) {1607 linalg.batch_matmul indexing_maps = [1608 affine_map<(d0, d1, d2, d3) -> (d1, d3)>,1609 affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>,1610 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1611 ]1612 ins(%arg0, %arg1 : memref<3x5xf32>, memref<2x7x5xf32>) outs(%arg2: memref<2x3x7xf32>)1613 return1614}1615 1616// -----1617 1618//===----------------------------------------------------------------------===//1619// linalg.batch_reduce_matmul1620//===----------------------------------------------------------------------===//1621 1622// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d3)>1623// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>1624// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d2)>1625 1626// CHECK-LABEL: func.func @bcast_k_to_fill_missing_dims_A(1627// CHECK-SAME: %[[A:.*]]: memref<5xf32>,1628// CHECK-SAME: %[[B:.*]]: memref<2x5x7xf32>,1629// CHECK-SAME: %[[C:.*]]: memref<3x7xf32>) {1630// CHECK: linalg.batch_reduce_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[A]], %[[B]] : memref<5xf32>, memref<2x5x7xf32>) outs(%[[C]] : memref<3x7xf32>)1631// CHECK: return1632// CHECK: }1633 1634func.func @bcast_k_to_fill_missing_dims_A(%A: memref<5xf32>, %B: memref<2x5x7xf32>, %C: memref<3x7xf32>) {1635 linalg.batch_reduce_matmul indexing_maps = [1636 affine_map<(d0, d1, d2, d3) -> (d3)>,1637 affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1638 affine_map<(d0, d1, d2, d3) -> (d1, d2)>1639 ]1640 ins(%A, %B : memref<5xf32>, memref<2x5x7xf32>) outs(%C: memref<3x7xf32>)1641 return1642}1643 1644// -----1645 1646// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d3)>1647// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>1648// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d2)>1649 1650// CHECK-LABEL: func.func @bcast_batch_dim_A(1651// CHECK-SAME: %[[A:.*]]: memref<3x5xf32>,1652// CHECK-SAME: %[[B:.*]]: memref<2x5x7xf32>,1653// CHECK-SAME: %[[C:.*]]: memref<3x7xf32>) {1654// CHECK: linalg.batch_reduce_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[A]], %[[B]] : memref<3x5xf32>, memref<2x5x7xf32>) outs(%[[C]] : memref<3x7xf32>)1655// CHECK: return1656// CHECK: }1657 1658func.func @bcast_batch_dim_A(%A: memref<3x5xf32>, %B: memref<2x5x7xf32>, %C: memref<3x7xf32>) {1659 linalg.batch_reduce_matmul indexing_maps = [1660 affine_map<(d0, d1, d2, d3) -> (d1, d3)>,1661 affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1662 affine_map<(d0, d1, d2, d3) -> (d1, d2)>1663 ]1664 ins(%A, %B : memref<3x5xf32>, memref<2x5x7xf32>) outs(%C: memref<3x7xf32>)1665 return1666}1667 1668// -----1669 1670// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1671// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d3)>1672// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d2)>1673 1674// CHECK-LABEL: func.func @bcast_batch_and_n_dim_B(1675// CHECK-SAME: %[[A:.*]]: memref<2x3x5xf32>,1676// CHECK-SAME: %[[B:.*]]: memref<5xf32>,1677// CHECK-SAME: %[[C:.*]]: memref<3x7xf32>) {1678// CHECK: linalg.batch_reduce_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[A]], %[[B]] : memref<2x3x5xf32>, memref<5xf32>) outs(%[[C]] : memref<3x7xf32>)1679// CHECK: return1680// CHECK: }1681 1682func.func @bcast_batch_and_n_dim_B(%A: memref<2x3x5xf32>, %B: memref<5xf32>, %C: memref<3x7xf32>) {1683 linalg.batch_reduce_matmul indexing_maps = [1684 affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1685 affine_map<(d0, d1, d2, d3) -> (d3)>,1686 affine_map<(d0, d1, d2, d3) -> (d1, d2)>1687 ]1688 ins(%A, %B : memref<2x3x5xf32>, memref<5xf32>) outs(%C: memref<3x7xf32>)1689 return1690}1691 1692// -----1693 1694// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1695// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d3, d2)>1696// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d2)>1697 1698// CHECK-LABEL: func.func @bcast_batch_dim_B(1699// CHECK-SAME: %[[A:.*]]: memref<2x3x5xf32>,1700// CHECK-SAME: %[[B:.*]]: memref<5x7xf32>,1701// CHECK-SAME: %[[C:.*]]: memref<3x7xf32>) {1702// CHECK: linalg.batch_reduce_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[A]], %[[B]] : memref<2x3x5xf32>, memref<5x7xf32>) outs(%[[C]] : memref<3x7xf32>)1703// CHECK: return1704// CHECK: }1705 1706func.func @bcast_batch_dim_B(%A: memref<2x3x5xf32>, %B: memref<5x7xf32>, %C: memref<3x7xf32>) {1707 linalg.batch_reduce_matmul indexing_maps = [1708 affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1709 affine_map<(d0, d1, d2, d3) -> (d3, d2)>,1710 affine_map<(d0, d1, d2, d3) -> (d1, d2)>1711 ]1712 ins(%A, %B : memref<2x3x5xf32>, memref<5x7xf32>) outs(%C: memref<3x7xf32>)1713 return1714}1715 1716// -----1717 1718// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d3, d1)>1719// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>1720// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d2)>1721 1722// CHECK-LABEL: func.func @explicit_transpose_A(1723// CHECK-SAME: %[[A:.*]]: memref<2x5x3xf32>,1724// CHECK-SAME: %[[B:.*]]: memref<2x5x7xf32>,1725// CHECK-SAME: %[[C:.*]]: memref<3x7xf32>) {1726// CHECK: linalg.batch_reduce_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[A]], %[[B]] : memref<2x5x3xf32>, memref<2x5x7xf32>) outs(%[[C]] : memref<3x7xf32>)1727// CHECK: return1728// CHECK: }1729func.func @explicit_transpose_A(%A: memref<2x5x3xf32>, %B: memref<2x5x7xf32>, %C: memref<3x7xf32>) {1730 linalg.batch_reduce_matmul indexing_maps = [1731 affine_map<(d0, d1, d2, d3) -> (d0, d3, d1)>,1732 affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1733 affine_map<(d0, d1, d2, d3) -> (d1, d2)>1734 ]1735 ins(%A, %B : memref<2x5x3xf32>, memref<2x5x7xf32>) outs(%C: memref<3x7xf32>)1736 return1737}1738 1739// -----1740 1741// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1742// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>1743// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d2)>1744 1745// CHECK-LABEL: func.func @explicit_transpose_B(1746// CHECK-SAME: %[[A:.*]]: memref<2x3x5xf32>,1747// CHECK-SAME: %[[B:.*]]: memref<2x7x5xf32>,1748// CHECK-SAME: %[[C:.*]]: memref<3x7xf32>) {1749// CHECK: linalg.batch_reduce_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[A]], %[[B]] : memref<2x3x5xf32>, memref<2x7x5xf32>) outs(%[[C]] : memref<3x7xf32>)1750// CHECK: return1751// CHECK: }1752func.func @explicit_transpose_B(%A: memref<2x3x5xf32>, %B: memref<2x7x5xf32>, %C: memref<3x7xf32>) {1753 linalg.batch_reduce_matmul indexing_maps = [1754 affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1755 affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>,1756 affine_map<(d0, d1, d2, d3) -> (d1, d2)>1757 ]1758 ins(%A, %B : memref<2x3x5xf32>, memref<2x7x5xf32>) outs(%C: memref<3x7xf32>)1759 return1760}1761 1762// -----1763 1764// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d3)>1765// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>1766// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d1, d2)>1767 1768// CHECK-LABEL: func.func @bcast_A_transpose_B(1769// CHECK-SAME: %[[A:.*]]: memref<3x5xf32>,1770// CHECK-SAME: %[[B:.*]]: memref<2x7x5xf32>,1771// CHECK-SAME: %[[C:.*]]: memref<3x7xf32>) {1772// CHECK: linalg.batch_reduce_matmul indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]] ins(%[[A]], %[[B]] : memref<3x5xf32>, memref<2x7x5xf32>) outs(%[[C]] : memref<3x7xf32>)1773// CHECK: return1774// CHECK: }1775func.func @bcast_A_transpose_B(%A: memref<3x5xf32>, %B: memref<2x7x5xf32>, %C: memref<3x7xf32>) {1776 linalg.batch_reduce_matmul indexing_maps = [1777 affine_map<(d0, d1, d2, d3) -> (d1, d3)>,1778 affine_map<(d0, d1, d2, d3) -> (d0, d2, d3)>,1779 affine_map<(d0, d1, d2, d3) -> (d1, d2)>1780 ]1781 ins(%A, %B : memref<3x5xf32>, memref<2x7x5xf32>) outs(%C: memref<3x7xf32>)1782 return1783}1784 1785// -----1786 1787// CHECK: #[[$ATTR_0:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>1788// CHECK: #[[$ATTR_1:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>1789// CHECK: #[[$ATTR_2:.+]] = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>1790// CHECK-LABEL: func @contract1791// CHECK: linalg.contract1792// CHECK-SAME: indexing_maps = [#[[$ATTR_0]], #[[$ATTR_1]], #[[$ATTR_2]]]1793// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<2x3x5xf32>, memref<2x5x7xf32>)1794// CHECK-SAME: outs(%{{.+}} : memref<2x3x7xf32>)1795func.func @contract(1796 %A: memref<2x3x5xf32>, %B: memref<2x5x7xf32>, %C: memref<2x3x7xf32>) {1797 linalg.contract1798 indexing_maps = [affine_map<(d0, d1, d2, d3) -> (d0, d1, d3)>,1799 affine_map<(d0, d1, d2, d3) -> (d0, d3, d2)>,1800 affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>]1801 ins(%A, %B : memref<2x3x5xf32>, memref<2x5x7xf32>)1802 outs(%C: memref<2x3x7xf32>)1803 return1804}1805 1806// -----1807 1808// CHECK: #[[$ACCESS_A:.+]] = affine_map<(d0, d1, d2) -> (d2)>1809// CHECK: #[[$ACCESS_B:.+]] = affine_map<(d0, d1, d2) -> (d2, d1)>1810// CHECK: #[[$ACCESS_C:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1811// CHECK-LABEL: func @contract_matmul_bcast_a1812func.func @contract_matmul_bcast_a(%A: memref<5xf32>, %B: memref<5x7xf32>, %C: memref<3x7xf32>) {1813// CHECK: linalg.contract1814// CHECK-SAME: indexing_maps = [#[[$ACCESS_A]], #[[$ACCESS_B]], #[[$ACCESS_C]]]1815// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<5xf32>, memref<5x7xf32>)1816// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1817 linalg.contract1818 indexing_maps = [affine_map<(d0, d1, d2) -> (d2)>,1819 affine_map<(d0, d1, d2) -> (d2, d1)>,1820 affine_map<(d0, d1, d2) -> (d0, d1)>]1821 ins(%A, %B : memref<5xf32>, memref<5x7xf32>)1822 outs(%C: memref<3x7xf32>)1823 return1824}1825 1826// -----1827 1828// CHECK: #[[$ACCESS_A:.+]] = affine_map<(d0, d1, d2) -> (d0, d2)>1829// CHECK: #[[$ACCESS_B:.+]] = affine_map<(d0, d1, d2) -> (d2)>1830// CHECK: #[[$ACCESS_C:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1831// CHECK-LABEL: func @contract_matmul_bcast_b1832func.func @contract_matmul_bcast_b(%A: memref<3x5xf32>, %B: memref<5xf32>, %C: memref<3x7xf32>) {1833// CHECK: linalg.contract1834// CHECK-SAME: indexing_maps = [#[[$ACCESS_A]], #[[$ACCESS_B]], #[[$ACCESS_C]]]1835// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<3x5xf32>, memref<5xf32>)1836// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1837 linalg.contract1838 indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d2)>,1839 affine_map<(d0, d1, d2) -> (d2)>,1840 affine_map<(d0, d1, d2) -> (d0, d1)>]1841 ins(%A, %B : memref<3x5xf32>, memref<5xf32>)1842 outs(%C: memref<3x7xf32>)1843 return1844}1845 1846// -----1847 1848// CHECK: #[[$ACCESS_A:.+]] = affine_map<(d0, d1, d2) -> (d2)>1849// CHECK: #[[$ACCESS_B:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1850// CHECK-LABEL: func.func @contract_matmul_bcast_a_b1851func.func @contract_matmul_bcast_a_b(1852 %A: memref<5xf32>, %B: memref<5xf32>, %C: memref<3x7xf32>) {1853// CHECK: linalg.contract1854// CHECK-SAME: indexing_maps = [#[[$ACCESS_A]], #[[$ACCESS_A]], #[[$ACCESS_B]]]1855// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<5xf32>, memref<5xf32>)1856// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1857 linalg.contract1858 indexing_maps = [affine_map<(d0, d1, d2) -> (d2)>,1859 affine_map<(d0, d1, d2) -> (d2)>,1860 affine_map<(d0, d1, d2) -> (d0, d1)>]1861 ins(%A, %B : memref<5xf32>, memref<5xf32>)1862 outs(%C: memref<3x7xf32>)1863 return1864}1865 1866// -----1867 1868// CHECK: #[[$ACCESS_A:.+]] = affine_map<(d0, d1, d2) -> (d2)>1869// CHECK: #[[$ACCESS_B:.+]] = affine_map<(d0, d1, d2) -> (d1, d2)>1870// CHECK: #[[$ACCESS_C:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1871// CHECK-LABEL: func.func @contract_matmul_bcast_a_transpose_b1872func.func @contract_matmul_bcast_a_transpose_b(1873 %A: memref<5xf32>, %B: memref<7x5xf32>, %C: memref<3x7xf32>) {1874// CHECK: linalg.contract1875// CHECK-SAME: indexing_maps = [#[[$ACCESS_A]], #[[$ACCESS_B]], #[[$ACCESS_C]]]1876// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<5xf32>, memref<7x5xf32>)1877// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1878 linalg.contract1879 indexing_maps = [affine_map<(d0, d1, d2) -> (d2)>,1880 affine_map<(d0, d1, d2) -> (d1, d2)>,1881 affine_map<(d0, d1, d2) -> (d0, d1)>]1882 ins(%A, %B : memref<5xf32>, memref<7x5xf32>)1883 outs(%C: memref<3x7xf32>)1884 return1885}1886 1887// -----1888 1889// CHECK: #[[$ACCESS_A:.+]] = affine_map<(d0, d1, d2) -> (d2, d0)>1890// CHECK: #[[$ACCESS_B:.+]] = affine_map<(d0, d1, d2) -> (d2)>1891// CHECK: #[[$ACCESS_C:.+]] = affine_map<(d0, d1, d2) -> (d0, d1)>1892// CHECK-LABEL: func.func @contract_matmul_bcast_b_transpose_a1893func.func @contract_matmul_bcast_b_transpose_a(%A: memref<5x3xf32>, %B: memref<5xf32>, %C: memref<3x7xf32>) {1894// CHECK: linalg.contract1895// CHECK-SAME: indexing_maps = [#[[$ACCESS_A]], #[[$ACCESS_B]], #[[$ACCESS_C]]]1896// CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<5x3xf32>, memref<5xf32>)1897// CHECK-SAME: outs(%{{.+}} : memref<3x7xf32>)1898 linalg.contract1899 indexing_maps = [affine_map<(d0, d1, d2) -> (d2, d0)>,1900 affine_map<(d0, d1, d2) -> (d2)>,1901 affine_map<(d0, d1, d2) -> (d0, d1)>]1902 ins(%A, %B : memref<5x3xf32>, memref<5xf32>)1903 outs(%C: memref<3x7xf32>)1904 return1905}1906 1907// -----1908 1909// CHECK-LABEL: func @mmt4d1910func.func @mmt4d(%A: tensor<10x32x8x1xf32>, %B: tensor<80x32x4x1xf32>, %C: tensor<10x80x8x4xf32>) -> tensor<10x80x8x4xf32> {1911 // CHECK: %{{.+}} = linalg.mmt4d1912 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<10x32x8x1xf32>, tensor<80x32x4x1xf32>)1913 // CHECK-SAME: outs(%{{.+}} : tensor<10x80x8x4xf32>) -> tensor<10x80x8x4xf32>1914 %0 = linalg.mmt4d ins(%A, %B : tensor<10x32x8x1xf32>, tensor<80x32x4x1xf32>) outs(%C: tensor<10x80x8x4xf32>) -> tensor<10x80x8x4xf32>1915 return %0: tensor<10x80x8x4xf32>1916}1917 1918// -----1919 1920// CHECK-LABEL: func @batch_mmt4d1921func.func @batch_mmt4d(%arg0: tensor<128x10x32x8x1xf32>, %arg1: tensor<128x80x32x4x1xf32>, %arg2: tensor<128x10x80x8x4xf32>) -> tensor<128x10x80x8x4xf32> {1922 // CHECK: %{{.+}} = linalg.batch_mmt4d1923 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<128x10x32x8x1xf32>, tensor<128x80x32x4x1xf32>)1924 // CHECK-SAME: outs(%{{.+}} : tensor<128x10x80x8x4xf32>) -> tensor<128x10x80x8x4xf32>1925 %0 = linalg.batch_mmt4d ins(%arg0, %arg1 : tensor<128x10x32x8x1xf32>, tensor<128x80x32x4x1xf32>) outs(%arg2 : tensor<128x10x80x8x4xf32>) -> tensor<128x10x80x8x4xf32>1926 return %0: tensor<128x10x80x8x4xf32>1927}1928 1929// -----1930 1931// CHECK-LABEL: func @add_dynamic1932func.func @add_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1933 // CHECK: linalg.add1934 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)1935 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)1936 linalg.add ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)1937 return1938}1939 1940// -----1941 1942// CHECK-LABEL: func @add_static1943func.func @add_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>) {1944 // CHECK: linalg.add1945 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xf32>, memref<4x8x16xf32>)1946 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)1947 linalg.add ins(%arg0, %arg1 : memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg2: memref<4x8x16xf32>)1948 return1949}1950 1951// -----1952 1953// CHECK-LABEL: func @add_tensor1954func.func @add_tensor(%arg0: tensor<4x8x16xf32>, %arg1: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {1955 %0 = tensor.empty() : tensor<4x8x16xf32>1956 // CHECK: linalg.add1957 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xf32>, tensor<4x8x16xf32>)1958 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)1959 %1 = linalg.add ins(%arg0, %arg1 : tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>1960 return %1 : tensor<4x8x16xf32>1961}1962 1963// -----1964 1965// CHECK-LABEL: func @sub_dynamic1966func.func @sub_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {1967 // CHECK: linalg.sub1968 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)1969 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)1970 linalg.sub ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)1971 return1972}1973 1974// -----1975 1976// CHECK-LABEL: func @sub_static1977func.func @sub_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>) {1978 // CHECK: linalg.sub1979 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xf32>, memref<4x8x16xf32>)1980 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)1981 linalg.sub ins(%arg0, %arg1 : memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg2: memref<4x8x16xf32>)1982 return1983}1984 1985// -----1986 1987// CHECK-LABEL: func @sub_tensor1988func.func @sub_tensor(%arg0: tensor<4x8x16xf32>, %arg1: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {1989 %0 = tensor.empty() : tensor<4x8x16xf32>1990 // CHECK: linalg.sub1991 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xf32>, tensor<4x8x16xf32>)1992 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)1993 %1 = linalg.sub ins(%arg0, %arg1 : tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>1994 return %1 : tensor<4x8x16xf32>1995}1996 1997// -----1998 1999// CHECK-LABEL: func @mul_dynamic2000func.func @mul_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {2001 // CHECK: linalg.mul2002 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)2003 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)2004 linalg.mul ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)2005 return2006}2007 2008// -----2009 2010// CHECK-LABEL: func @mul_static2011func.func @mul_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>) {2012 // CHECK: linalg.mul2013 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xf32>, memref<4x8x16xf32>)2014 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)2015 linalg.mul ins(%arg0, %arg1 : memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg2: memref<4x8x16xf32>)2016 return2017}2018 2019// -----2020 2021// CHECK-LABEL: func @mul_tensor2022func.func @mul_tensor(%arg0: tensor<4x8x16xf32>, %arg1: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2023 %0 = tensor.empty() : tensor<4x8x16xf32>2024 // CHECK: linalg.mul2025 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xf32>, tensor<4x8x16xf32>)2026 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)2027 %1 = linalg.mul ins(%arg0, %arg1 : tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2028 return %1 : tensor<4x8x16xf32>2029}2030 2031// -----2032 2033// CHECK-LABEL: func @div_dynamic2034func.func @div_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {2035 // CHECK: linalg.div2036 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)2037 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)2038 linalg.div ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)2039 return2040}2041 2042// -----2043 2044// CHECK-LABEL: func @div_static2045func.func @div_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>) {2046 // CHECK: linalg.div2047 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xf32>, memref<4x8x16xf32>)2048 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)2049 linalg.div ins(%arg0, %arg1 : memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg2: memref<4x8x16xf32>)2050 return2051}2052 2053// -----2054 2055// CHECK-LABEL: func @div_tensor2056func.func @div_tensor(%arg0: tensor<4x8x16xf32>, %arg1: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2057 %0 = tensor.empty() : tensor<4x8x16xf32>2058 // CHECK: linalg.div2059 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xf32>, tensor<4x8x16xf32>)2060 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)2061 %1 = linalg.div ins(%arg0, %arg1 : tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2062 return %1 : tensor<4x8x16xf32>2063}2064 2065// -----2066 2067// CHECK-LABEL: func @div_unsigned_dynamic2068func.func @div_unsigned_dynamic(%arg0: memref<?x?x?xi32>, %arg1: memref<?x?x?xi32>, %arg2: memref<?x?x?xi32>) {2069 // CHECK: linalg.div_unsigned2070 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xi32>, memref<?x?x?xi32>)2071 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xi32>)2072 linalg.div_unsigned ins(%arg0, %arg1 : memref<?x?x?xi32>, memref<?x?x?xi32>) outs(%arg2: memref<?x?x?xi32>)2073 return2074}2075 2076// -----2077 2078// CHECK-LABEL: func @div_unsigned_static2079func.func @div_unsigned_static(%arg0: memref<4x8x16xi32>, %arg1: memref<4x8x16xi32>, %arg2: memref<4x8x16xi32>) {2080 // CHECK: linalg.div_unsigned2081 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xi32>, memref<4x8x16xi32>)2082 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xi32>)2083 linalg.div_unsigned ins(%arg0, %arg1 : memref<4x8x16xi32>, memref<4x8x16xi32>) outs(%arg2: memref<4x8x16xi32>)2084 return2085}2086 2087// -----2088 2089// CHECK-LABEL: func @div_unsigned_tensor2090func.func @div_unsigned_tensor(%arg0: tensor<4x8x16xi32>, %arg1: tensor<4x8x16xi32>) -> tensor<4x8x16xi32> {2091 %0 = tensor.empty() : tensor<4x8x16xi32>2092 // CHECK: linalg.div_unsigned2093 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xi32>, tensor<4x8x16xi32>)2094 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xi32>)2095 %1 = linalg.div_unsigned ins(%arg0, %arg1 : tensor<4x8x16xi32>, tensor<4x8x16xi32>) outs(%0: tensor<4x8x16xi32>) -> tensor<4x8x16xi32>2096 return %1 : tensor<4x8x16xi32>2097}2098 2099// -----2100 2101// CHECK-LABEL: func @exp_dynamic2102func.func @exp_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2103 // CHECK: linalg.exp2104 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2105 linalg.exp ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2106 return2107}2108 2109// -----2110 2111// CHECK-LABEL: func @exp_static2112func.func @exp_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2113 // CHECK: linalg.exp2114 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2115 linalg.exp ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2116 return2117}2118 2119// -----2120 2121// CHECK-LABEL: func @exp_tensor2122func.func @exp_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2123 %0 = tensor.empty() : tensor<4x8x16xf32>2124 // CHECK: linalg.exp2125 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2126 %1 = linalg.exp ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2127 return %1 : tensor<4x8x16xf32>2128}2129 2130// -----2131 2132// CHECK-LABEL: func @log_dynamic2133func.func @log_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2134 // CHECK: linalg.log2135 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2136 linalg.log ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2137 return2138}2139 2140// -----2141 2142// CHECK-LABEL: func @log_static2143func.func @log_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2144 // CHECK: linalg.log2145 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2146 linalg.log ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2147 return2148}2149 2150// -----2151 2152// CHECK-LABEL: func @log_tensor2153func.func @log_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2154 %0 = tensor.empty() : tensor<4x8x16xf32>2155 // CHECK: linalg.log2156 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2157 %1 = linalg.log ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2158 return %1 : tensor<4x8x16xf32>2159}2160 2161// -----2162 2163// CHECK-LABEL: func @abs_dynamic2164func.func @abs_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2165 // CHECK: linalg.abs2166 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2167 linalg.abs ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2168 return2169}2170 2171// -----2172 2173// CHECK-LABEL: func @abs_static2174func.func @abs_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2175 // CHECK: linalg.abs2176 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2177 linalg.abs ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2178 return2179}2180 2181// -----2182 2183// CHECK-LABEL: func @abs_tensor2184func.func @abs_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2185 %0 = tensor.empty() : tensor<4x8x16xf32>2186 // CHECK: linalg.abs2187 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2188 %1 = linalg.abs ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2189 return %1 : tensor<4x8x16xf32>2190}2191 2192// -----2193 2194// CHECK-LABEL: func @ceil_dynamic2195func.func @ceil_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2196 // CHECK: linalg.ceil2197 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2198 linalg.ceil ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2199 return2200}2201 2202// -----2203 2204// CHECK-LABEL: func @ceil_static2205func.func @ceil_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2206 // CHECK: linalg.ceil2207 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2208 linalg.ceil ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2209 return2210}2211 2212// -----2213 2214// CHECK-LABEL: func @ceil_tensor2215func.func @ceil_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2216 %0 = tensor.empty() : tensor<4x8x16xf32>2217 // CHECK: linalg.ceil2218 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2219 %1 = linalg.ceil ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2220 return %1 : tensor<4x8x16xf32>2221}2222 2223// -----2224 2225// CHECK-LABEL: func @floor_dynamic2226func.func @floor_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2227 // CHECK: linalg.floor2228 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2229 linalg.floor ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2230 return2231}2232 2233// -----2234 2235// CHECK-LABEL: func @floor_static2236func.func @floor_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2237 // CHECK: linalg.floor2238 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2239 linalg.floor ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2240 return2241}2242 2243// -----2244 2245// CHECK-LABEL: func @floor_tensor2246func.func @floor_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2247 %0 = tensor.empty() : tensor<4x8x16xf32>2248 // CHECK: linalg.floor2249 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2250 %1 = linalg.floor ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2251 return %1 : tensor<4x8x16xf32>2252}2253 2254// -----2255 2256// CHECK-LABEL: func @negf_dynamic2257func.func @negf_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2258 // CHECK: linalg.negf2259 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2260 linalg.negf ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2261 return2262}2263 2264// -----2265 2266// CHECK-LABEL: func @negf_static2267func.func @negf_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2268 // CHECK: linalg.negf2269 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2270 linalg.negf ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2271 return2272}2273 2274// -----2275 2276// CHECK-LABEL: func @negf_tensor2277func.func @negf_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2278 %0 = tensor.empty() : tensor<4x8x16xf32>2279 // CHECK: linalg.negf2280 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2281 %1 = linalg.negf ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2282 return %1 : tensor<4x8x16xf32>2283}2284 2285// -----2286 2287// CHECK-LABEL: func @reciprocal_dynamic2288func.func @reciprocal_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2289 // CHECK: linalg.reciprocal2290 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2291 linalg.reciprocal ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2292 return2293}2294 2295// -----2296 2297// CHECK-LABEL: func @reciprocal_static2298func.func @reciprocal_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2299 // CHECK: linalg.reciprocal2300 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2301 linalg.reciprocal ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2302 return2303}2304 2305// -----2306 2307// CHECK-LABEL: func @reciprocal_tensor2308func.func @reciprocal_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2309 %0 = tensor.empty() : tensor<4x8x16xf32>2310 // CHECK: linalg.reciprocal2311 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2312 %1 = linalg.reciprocal ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2313 return %1 : tensor<4x8x16xf32>2314}2315 2316// -----2317 2318// CHECK-LABEL: func @round_dynamic2319func.func @round_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2320 // CHECK: linalg.round2321 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2322 linalg.round ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2323 return2324}2325 2326// -----2327 2328// CHECK-LABEL: func @round_static2329func.func @round_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2330 // CHECK: linalg.round2331 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2332 linalg.round ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2333 return2334}2335 2336// -----2337 2338// CHECK-LABEL: func @round_tensor2339func.func @round_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2340 %0 = tensor.empty() : tensor<4x8x16xf32>2341 // CHECK: linalg.round2342 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2343 %1 = linalg.round ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2344 return %1 : tensor<4x8x16xf32>2345}2346 2347// -----2348 2349// CHECK-LABEL: func @sqrt_dynamic2350func.func @sqrt_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2351 // CHECK: linalg.sqrt2352 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2353 linalg.sqrt ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2354 return2355}2356 2357// -----2358 2359// CHECK-LABEL: func @sqrt_static2360func.func @sqrt_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2361 // CHECK: linalg.sqrt2362 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2363 linalg.sqrt ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2364 return2365}2366 2367// -----2368 2369// CHECK-LABEL: func @sqrt_tensor2370func.func @sqrt_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2371 %0 = tensor.empty() : tensor<4x8x16xf32>2372 // CHECK: linalg.sqrt2373 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2374 %1 = linalg.sqrt ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2375 return %1 : tensor<4x8x16xf32>2376}2377 2378// -----2379 2380// CHECK-LABEL: func @rsqrt_dynamic2381func.func @rsqrt_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2382 // CHECK: linalg.rsqrt2383 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2384 linalg.rsqrt ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2385 return2386}2387 2388// -----2389 2390// CHECK-LABEL: func @rsqrt_static2391func.func @rsqrt_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2392 // CHECK: linalg.rsqrt2393 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2394 linalg.rsqrt ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2395 return2396}2397 2398// -----2399 2400// CHECK-LABEL: func @rsqrt_tensor2401func.func @rsqrt_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2402 %0 = tensor.empty() : tensor<4x8x16xf32>2403 // CHECK: linalg.rsqrt2404 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2405 %1 = linalg.rsqrt ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2406 return %1 : tensor<4x8x16xf32>2407}2408 2409// -----2410 2411// CHECK-LABEL: func @square_dynamic2412func.func @square_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2413 // CHECK: linalg.square2414 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2415 linalg.square ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2416 return2417}2418 2419// -----2420 2421// CHECK-LABEL: func @square_static2422func.func @square_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2423 // CHECK: linalg.square2424 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2425 linalg.square ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2426 return2427}2428 2429// -----2430 2431// CHECK-LABEL: func @square_tensor2432func.func @square_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2433 %0 = tensor.empty() : tensor<4x8x16xf32>2434 // CHECK: linalg.square2435 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2436 %1 = linalg.square ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2437 return %1 : tensor<4x8x16xf32>2438}2439 2440// -----2441 2442// CHECK-LABEL: func @tanh_dynamic2443func.func @tanh_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2444 // CHECK: linalg.tanh2445 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2446 linalg.tanh ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2447 return2448}2449 2450// -----2451 2452// CHECK-LABEL: func @tanh_static2453func.func @tanh_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2454 // CHECK: linalg.tanh2455 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2456 linalg.tanh ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2457 return2458}2459 2460// -----2461 2462// CHECK-LABEL: func @tanh_tensor2463func.func @tanh_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2464 %0 = tensor.empty() : tensor<4x8x16xf32>2465 // CHECK: linalg.tanh2466 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2467 %1 = linalg.tanh ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2468 return %1 : tensor<4x8x16xf32>2469}2470 2471// -----2472 2473// CHECK-LABEL: func @erf_dynamic2474func.func @erf_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>) {2475 // CHECK: linalg.erf2476 // CHECK-SAME: ins(%{{.+}} : memref<?x?x?xf32>) outs(%{{.+}} : memref<?x?x?xf32>)2477 linalg.erf ins(%arg0 : memref<?x?x?xf32>) outs(%arg1: memref<?x?x?xf32>)2478 return2479}2480 2481// -----2482 2483// CHECK-LABEL: func @erf_static2484func.func @erf_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>) {2485 // CHECK: linalg.erf2486 // CHECK-SAME: ins(%{{.+}} : memref<4x8x16xf32>) outs(%{{.+}} : memref<4x8x16xf32>)2487 linalg.erf ins(%arg0 : memref<4x8x16xf32>) outs(%arg1: memref<4x8x16xf32>)2488 return2489}2490 2491// -----2492 2493// CHECK-LABEL: func @erf_tensor2494func.func @erf_tensor(%arg0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2495 %0 = tensor.empty() : tensor<4x8x16xf32>2496 // CHECK: linalg.erf2497 // CHECK-SAME: ins(%{{.+}} : tensor<4x8x16xf32>) outs(%{{.+}} : tensor<4x8x16xf32>)2498 %1 = linalg.erf ins(%arg0 : tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2499 return %1 : tensor<4x8x16xf32>2500}2501 2502// -----2503 2504// CHECK-LABEL: func @max_dynamic2505func.func @max_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {2506 // CHECK: linalg.max2507 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)2508 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)2509 linalg.max ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)2510 return2511}2512 2513// -----2514 2515// CHECK-LABEL: func @max_static2516func.func @max_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>) {2517 // CHECK: linalg.max2518 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xf32>, memref<4x8x16xf32>)2519 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)2520 linalg.max ins(%arg0, %arg1 : memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg2: memref<4x8x16xf32>)2521 return2522}2523 2524// -----2525 2526// CHECK-LABEL: func @max_tensor2527func.func @max_tensor(%arg0: tensor<4x8x16xf32>, %arg1: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2528 %0 = tensor.empty() : tensor<4x8x16xf32>2529 // CHECK: linalg.max2530 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xf32>, tensor<4x8x16xf32>)2531 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)2532 %1 = linalg.max ins(%arg0, %arg1 : tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2533 return %1 : tensor<4x8x16xf32>2534}2535 2536// -----2537 2538// CHECK-LABEL: func @min_dynamic2539func.func @min_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {2540 // CHECK: linalg.min2541 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)2542 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)2543 linalg.min ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)2544 return2545}2546 2547// -----2548 2549// CHECK-LABEL: func @min_static2550func.func @min_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>) {2551 // CHECK: linalg.min2552 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xf32>, memref<4x8x16xf32>)2553 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)2554 linalg.min ins(%arg0, %arg1 : memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg2: memref<4x8x16xf32>)2555 return2556}2557 2558// -----2559 2560// CHECK-LABEL: func @min_tensor2561func.func @min_tensor(%arg0: tensor<4x8x16xf32>, %arg1: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2562 %0 = tensor.empty() : tensor<4x8x16xf32>2563 // CHECK: linalg.min2564 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xf32>, tensor<4x8x16xf32>)2565 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)2566 %1 = linalg.min ins(%arg0, %arg1 : tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2567 return %1 : tensor<4x8x16xf32>2568}2569 2570// -----2571 2572// CHECK-LABEL: func @powf_dynamic2573func.func @powf_dynamic(%arg0: memref<?x?x?xf32>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>) {2574 // CHECK: linalg.powf2575 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<?x?x?xf32>, memref<?x?x?xf32>)2576 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)2577 linalg.powf ins(%arg0, %arg1 : memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg2: memref<?x?x?xf32>)2578 return2579}2580 2581// -----2582 2583// CHECK-LABEL: func @powf_static2584func.func @powf_static(%arg0: memref<4x8x16xf32>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>) {2585 // CHECK: linalg.powf2586 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : memref<4x8x16xf32>, memref<4x8x16xf32>)2587 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)2588 linalg.powf ins(%arg0, %arg1 : memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg2: memref<4x8x16xf32>)2589 return2590}2591 2592// -----2593 2594// CHECK-LABEL: func @powf_tensor2595func.func @powf_tensor(%arg0: tensor<4x8x16xf32>, %arg1: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2596 %0 = tensor.empty() : tensor<4x8x16xf32>2597 // CHECK: linalg.powf2598 // CHECK-SAME: ins(%{{.+}}, %{{.+}} : tensor<4x8x16xf32>, tensor<4x8x16xf32>)2599 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)2600 %1 = linalg.powf ins(%arg0, %arg1 : tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2601 return %1 : tensor<4x8x16xf32>2602}2603 2604// -----2605 2606// CHECK-LABEL: func @fill_tensor2607func.func @fill_tensor(%f: f32, %v: vector<2x4xf32>) -> (tensor<f32>, tensor<vector<2x4xf32>>) {2608 %e0 = tensor.empty() : tensor<f32>2609 %0 = linalg.fill ins(%f : f32) outs(%e0 : tensor<f32>) -> tensor<f32>2610 %e1 = tensor.empty() : tensor<vector<2x4xf32>>2611 %1 = linalg.fill ins(%v : vector<2x4xf32>) outs(%e1 : tensor<vector<2x4xf32>>) -> tensor<vector<2x4xf32>>2612 return %0, %1: tensor<f32>, tensor<vector<2x4xf32>>2613}2614 2615// -----2616 2617// CHECK-LABEL: func @select_dynamic2618func.func @select_dynamic(%arg0: memref<?x?x?xi1>, %arg1: memref<?x?x?xf32>, %arg2: memref<?x?x?xf32>, %arg3: memref<?x?x?xf32>) {2619 // CHECK: linalg.select2620 // CHECK-SAME: ins(%{{.+}}, %{{.+}}, %{{.+}} : memref<?x?x?xi1>, memref<?x?x?xf32>, memref<?x?x?xf32>)2621 // CHECK-SAME: outs(%{{.+}} : memref<?x?x?xf32>)2622 linalg.select ins(%arg0, %arg1, %arg2 : memref<?x?x?xi1>, memref<?x?x?xf32>, memref<?x?x?xf32>) outs(%arg3: memref<?x?x?xf32>)2623 return2624}2625 2626// -----2627 2628// CHECK-LABEL: func @select_static2629func.func @select_static(%arg0: memref<4x8x16xi1>, %arg1: memref<4x8x16xf32>, %arg2: memref<4x8x16xf32>, %arg3: memref<4x8x16xf32>) {2630 // CHECK: linalg.select2631 // CHECK-SAME: ins(%{{.+}}, %{{.+}}, %{{.+}} : memref<4x8x16xi1>, memref<4x8x16xf32>, memref<4x8x16xf32>)2632 // CHECK-SAME: outs(%{{.+}} : memref<4x8x16xf32>)2633 linalg.select ins(%arg0, %arg1, %arg2 : memref<4x8x16xi1>, memref<4x8x16xf32>, memref<4x8x16xf32>) outs(%arg3: memref<4x8x16xf32>)2634 return2635}2636 2637// -----2638 2639// CHECK-LABEL: func @select_tensor2640func.func @select_tensor(%arg0: tensor<4x8x16xi1>, %arg1: tensor<4x8x16xf32>, %arg2: tensor<4x8x16xf32>) -> tensor<4x8x16xf32> {2641 %0 = tensor.empty() : tensor<4x8x16xf32>2642 // CHECK: linalg.select2643 // CHECK-SAME: ins(%{{.+}}, %{{.+}}, %{{.+}} : tensor<4x8x16xi1>, tensor<4x8x16xf32>, tensor<4x8x16xf32>)2644 // CHECK-SAME: outs(%{{.+}} : tensor<4x8x16xf32>)2645 %1 = linalg.select ins(%arg0, %arg1, %arg2 : tensor<4x8x16xi1>, tensor<4x8x16xf32>, tensor<4x8x16xf32>) outs(%0: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>2646 return %1 : tensor<4x8x16xf32>2647}2648 2649//===----------------------------------------------------------------------===//2650// linalg.pack + linalg.unpack2651//===----------------------------------------------------------------------===//2652 2653func.func @pack_nc_to_ncnc(%source: tensor<128x256xf32>, %dest: tensor<4x16x32x16xf32>) -> tensor<128x256xf32> {2654 %0 = linalg.pack %source inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %dest : tensor<128x256xf32> -> tensor<4x16x32x16xf32>2655 %1 = tensor.empty() : tensor<128x256xf32>2656 %2 = linalg.unpack %0 inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %1 : tensor<4x16x32x16xf32> -> tensor<128x256xf32>2657 return %2 : tensor<128x256xf32>2658}2659 2660// CHECK-LABEL: func.func @pack_nc_to_ncnc(2661// CHECK-SAME: %[[SOURCE:.*]]: tensor<128x256xf32>,2662// CHECK-SAME: %[[DEST:.*]]: tensor<4x16x32x16xf32>)2663// CHECK: %[[PACKED:.*]] = linalg.pack %[[SOURCE]] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %[[DEST]] : tensor<128x256xf32> -> tensor<4x16x32x16xf32>2664// CHECK: %[[BUFF:.*]] = tensor.empty() : tensor<128x256xf32>2665// CHECK: %{{.*}} = linalg.unpack %[[PACKED]] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %[[BUFF]] : tensor<4x16x32x16xf32> -> tensor<128x256xf32>2666 2667// -----2668 2669func.func @pack_nc_to_ncnc_with_padding(%source: tensor<13x15xf32>, %dest: tensor<2x8x8x2xf32>, %padding: f32) -> tensor<13x15xf32> {2670 %0 = linalg.pack %source padding_value(%padding : f32) inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %dest : tensor<13x15xf32> -> tensor<2x8x8x2xf32>2671 %1 = tensor.empty() : tensor<13x15xf32>2672 %2 = linalg.unpack %0 inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %1 : tensor<2x8x8x2xf32> -> tensor<13x15xf32>2673 return %2 : tensor<13x15xf32>2674}2675 2676// CHECK-LABEL: func.func @pack_nc_to_ncnc_with_padding(2677// CHECK-SAME: %[[SOURCE:.*]]: tensor<13x15xf32>,2678// CHECK-SAME: %[[DEST:.*]]: tensor<2x8x8x2xf32>,2679// CHECK-SAME: %[[PADDING:.*]]: f32)2680// CHECK: %[[PACKED:.*]] = linalg.pack %[[SOURCE]] padding_value(%[[PADDING]] : f32) inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %[[DEST]] : tensor<13x15xf32> -> tensor<2x8x8x2xf32>2681// CHECK: %[[BUFF:.*]] = tensor.empty() : tensor<13x15xf32>2682// CHECK: %{{.*}} = linalg.unpack %[[PACKED]] inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %[[BUFF]] : tensor<2x8x8x2xf32> -> tensor<13x15xf32>2683 2684// -----2685 2686func.func @pack_ck_to_kcck(%source: tensor<128x256xf32>, %dest: tensor<16x4x32x16xf32>) -> tensor<128x256xf32> {2687 %0 = linalg.pack %source outer_dims_perm = [1, 0] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %dest : tensor<128x256xf32> -> tensor<16x4x32x16xf32>2688 %1 = tensor.empty() : tensor<128x256xf32>2689 %2 = linalg.unpack %0 outer_dims_perm = [1, 0] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %1 : tensor<16x4x32x16xf32> -> tensor<128x256xf32>2690 return %2 : tensor<128x256xf32>2691}2692 2693// CHECK-LABEL: func.func @pack_ck_to_kcck(2694// CHECK-SAME: %[[SOURCE:.*]]: tensor<128x256xf32>,2695// CHECK-SAME: %[[DEST:.*]]: tensor<16x4x32x16xf32>)2696// CHECK: %[[PACKED:.*]] = linalg.pack %[[SOURCE]] outer_dims_perm = [1, 0] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %[[DEST]] : tensor<128x256xf32> -> tensor<16x4x32x16xf32>2697// CHECK: %[[BUFF:.*]] = tensor.empty() : tensor<128x256xf32>2698// CHECK: %{{.*}} = linalg.unpack %[[PACKED]] outer_dims_perm = [1, 0] inner_dims_pos = [0, 1] inner_tiles = [32, 16] into %[[BUFF]] : tensor<16x4x32x16xf32> -> tensor<128x256xf32>2699 2700// -----2701 2702func.func @pad_and_pack_fully_dynamic(%source: tensor<?x?xf32>, %dest: tensor<?x?x?x?xf32>, %pad: f32, %tile_n : index, %tile_m : index) -> tensor<?x?x?x?xf32> {2703 %0 = linalg.pack %source padding_value(%pad : f32) inner_dims_pos = [0, 1] inner_tiles = [%tile_n, %tile_m] into %dest : tensor<?x?xf32> -> tensor<?x?x?x?xf32>2704 return %0 : tensor<?x?x?x?xf32>2705}2706 2707// CHECK-LABEL: func.func @pad_and_pack_fully_dynamic(2708// CHECK-SAME: %[[SOURCE:.*]]: tensor<?x?xf32>,2709// CHECK-SAME: %[[DEST:.*]]: tensor<?x?x?x?xf32>,2710// CHECK-SAME: %[[PAD:.*]]: f32,2711// CHECK-SAME: %[[TILE_N:.*]]: index,2712// CHECK-SAME: %[[TILE_M:.*]]: index)2713// CHECK: %{{.*}} = linalg.pack %[[SOURCE]] padding_value(%[[PAD]] : f32) inner_dims_pos = [0, 1] inner_tiles = [%[[TILE_N]], %[[TILE_M]]] into %[[DEST]] : tensor<?x?xf32> -> tensor<?x?x?x?xf32>2714 2715// -----2716 2717func.func @pad_and_pack_partially_dynamic(%source: tensor<?x?xf32>, %dest: tensor<?x?x8x2xf32>, %pad: f32) -> tensor<?x?x8x2xf32> {2718 %0 = linalg.pack %source padding_value(%pad : f32) inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %dest : tensor<?x?xf32> -> tensor<?x?x8x2xf32>2719 return %0 : tensor<?x?x8x2xf32>2720}2721 2722// CHECK-LABEL: func.func @pad_and_pack_partially_dynamic(2723// CHECK-SAME: %[[SOURCE:.*]]: tensor<?x?xf32>,2724// CHECK-SAME: %[[DEST:.*]]: tensor<?x?x8x2xf32>,2725// CHECK-SAME: %[[PAD:.*]]: f32)2726// CHECK: %{{.*}} = linalg.pack %[[SOURCE]] padding_value(%[[PAD]] : f32) inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %[[DEST]] : tensor<?x?xf32> -> tensor<?x?x8x2xf32>2727 2728// -----2729 2730func.func @pack_transposed_inner_dims_with_padding(%source: tensor<1x5x7xf32>, %dest: tensor<1x3x2x4x2xf32>, %pad: f32) -> tensor<1x3x2x4x2xf32> {2731 %0 = linalg.pack %source padding_value(%pad : f32) inner_dims_pos = [2, 1] inner_tiles = [4, 2] into %dest : tensor<1x5x7xf32> -> tensor<1x3x2x4x2xf32>2732 return %0 : tensor<1x3x2x4x2xf32>2733}2734 2735// CHECK-LABEL: func.func @pack_transposed_inner_dims_with_padding(2736// CHECK-SAME: %[[SOURCE:.*]]: tensor<1x5x7xf32>,2737// CHECK-SAME: %[[DEST:.*]]: tensor<1x3x2x4x2xf32>,2738// CHECK-SAME: %[[PAD:.*]]: f32)2739// CHECK: %{{.*}} = linalg.pack2740// CHECK-SAME: inner_dims_pos = [2, 1]2741// CHECK-SAME: inner_tiles = [4, 2]2742// CHECK-SAME: into %[[DEST]] : tensor<1x5x7xf32> -> tensor<1x3x2x4x2xf32>2743 2744// -----2745 2746// The function suffix "with_padding" refers to the padding that was introduced by the pack operation. But here2747// we are dropping the padding. Creating a tensor with less elements than what we started with.2748func.func @unpack_descending_inner_dims_with_padding(%source: tensor<1x3x2x4x2xf32>, %dest: tensor<1x5x7xf32>) -> tensor<1x5x7xf32> {2749 %0 = linalg.unpack %source inner_dims_pos = [2, 1] inner_tiles = [4, 2] into %dest : tensor<1x3x2x4x2xf32> -> tensor<1x5x7xf32>2750 return %0 : tensor<1x5x7xf32>2751}2752 2753// CHECK-LABEL: func.func @unpack_descending_inner_dims_with_padding(2754// CHECK-SAME: %[[SOURCE:.*]]: tensor<1x3x2x4x2xf32>,2755// CHECK-SAME: %[[DEST:.*]]: tensor<1x5x7xf32>)2756// CHECK: %{{.*}} = linalg.unpack2757// CHECK-SAME: inner_dims_pos = [2, 1]2758// CHECK-SAME: inner_tiles = [4, 2]2759// CHECK-SAME: into %[[DEST]] : tensor<1x3x2x4x2xf32> -> tensor<1x5x7xf32>2760 2761// -----2762 2763func.func @pack_non_adjacent_inner_dims(%source: tensor<20x1x12xf32>, %dest: tensor<10x1x3x4x2xf32>) -> tensor<10x1x3x4x2xf32> {2764 %0 = linalg.pack %source inner_dims_pos = [2, 0] inner_tiles = [4, 2] into %dest : tensor<20x1x12xf32> -> tensor<10x1x3x4x2xf32>2765 return %0 : tensor<10x1x3x4x2xf32>2766}2767 2768// CHECK-LABEL: func.func @pack_non_adjacent_inner_dims(2769// CHECK-SAME: %[[SOURCE:.*]]: tensor<20x1x12xf32>,2770// CHECK-SAME: %[[DEST:.*]]: tensor<10x1x3x4x2xf32>)2771// CHECK: %{{.*}} = linalg.pack2772// CHECK-SAME: inner_dims_pos = [2, 0]2773// CHECK-SAME: inner_tiles = [4, 2]2774// CHECK-SAME: into %[[DEST]] : tensor<20x1x12xf32> -> tensor<10x1x3x4x2xf32>2775 2776// -----2777 2778func.func @unpack_non_adjacent_inner_dims(%source: tensor<10x1x3x4x2xf32>, %dest: tensor<20x1x12xf32>) -> tensor<20x1x12xf32> {2779 %0 = linalg.unpack %source inner_dims_pos = [2, 0] inner_tiles = [4, 2] into %dest : tensor<10x1x3x4x2xf32> -> tensor<20x1x12xf32>2780 return %0 : tensor<20x1x12xf32>2781}2782 2783// CHECK-LABEL: func.func @unpack_non_adjacent_inner_dims(2784// CHECK-SAME: %[[SOURCE:.*]]: tensor<10x1x3x4x2xf32>,2785// CHECK-SAME: %[[DEST:.*]]: tensor<20x1x12xf32>)2786// CHECK: %{{.*}} = linalg.unpack2787// CHECK-SAME: inner_dims_pos = [2, 0]2788// CHECK-SAME: inner_tiles = [4, 2]2789// CHECK-SAME: into %[[DEST]] : tensor<10x1x3x4x2xf32> -> tensor<20x1x12xf32>2790 2791// -----2792 2793func.func @pack_implementing_transpose(%source: tensor<3x5x7xf32>, %dest: tensor<3x7x5xf32>) -> tensor<3x7x5xf32> {2794 %0 = linalg.pack %source outer_dims_perm = [0, 2, 1] inner_dims_pos = [] inner_tiles = [] into %dest : tensor<3x5x7xf32> -> tensor<3x7x5xf32>2795 return %0 : tensor<3x7x5xf32>2796}2797 2798// CHECK-LABEL: func.func @pack_implementing_transpose(2799// CHECK-SAME: %[[SOURCE:.*]]: tensor<3x5x7xf32>,2800// CHECK-SAME: %[[DEST:.*]]: tensor<3x7x5xf32>)2801// CHECK: %{{.*}} = linalg.pack2802// CHECK-SAME: outer_dims_perm = [0, 2, 1]2803// CHECK-SAME: inner_dims_pos = []2804// CHECK-SAME: inner_tiles = []2805// CHECK-SAME: into %[[DEST]] : tensor<3x5x7xf32> -> tensor<3x7x5xf32>2806 2807// -----2808 2809func.func @unpack_implementing_transpose(%source: tensor<3x7x5xf32>, %dest: tensor<3x5x7xf32>) -> tensor<3x5x7xf32> {2810 %0 = linalg.unpack %source outer_dims_perm = [0, 2, 1] inner_dims_pos = [] inner_tiles = [] into %dest : tensor<3x7x5xf32> -> tensor<3x5x7xf32>2811 return %0 : tensor<3x5x7xf32>2812}2813 2814// CHECK-LABEL: func.func @unpack_implementing_transpose(2815// CHECK-SAME: %[[SOURCE:.*]]: tensor<3x7x5xf32>,2816// CHECK-SAME: %[[DEST:.*]]: tensor<3x5x7xf32>)2817// CHECK: %{{.*}} = linalg.unpack2818// CHECK-SAME: outer_dims_perm = [0, 2, 1]2819// CHECK-SAME: inner_dims_pos = []2820// CHECK-SAME: inner_tiles = []2821// CHECK-SAME: into %[[DEST]] : tensor<3x7x5xf32> -> tensor<3x5x7xf32>2822 2823// -----2824 2825func.func @unpack_fully_dynamic(%source: tensor<?x?x?x?xf32>, %dest: tensor<?x?xf32>, %tile_n : index, %tile_m : index) -> tensor<?x?xf32> {2826 %0 = linalg.unpack %source inner_dims_pos = [0, 1] inner_tiles = [%tile_n, %tile_m] into %dest : tensor<?x?x?x?xf32> -> tensor<?x?xf32>2827 return %0 : tensor<?x?xf32>2828}2829 2830// CHECK-LABEL: func.func @unpack_fully_dynamic(2831// CHECK-SAME: %[[SOURCE:.*]]: tensor<?x?x?x?xf32>,2832// CHECK-SAME: %[[DEST:.*]]: tensor<?x?xf32>,2833// CHECK-SAME: %[[TILE_N:.*]]: index,2834// CHECK-SAME: %[[TILE_M:.*]]: index)2835// CHECK: %{{.*}} = linalg.unpack %[[SOURCE]] inner_dims_pos = [0, 1] inner_tiles = [%[[TILE_N]], %[[TILE_M]]] into %[[DEST]] : tensor<?x?x?x?xf32> -> tensor<?x?xf32>2836 2837// -----2838 2839func.func @unpack_partially_dynamic(%source: tensor<?x?x8x2xf32>, %dest: tensor<?x?xf32>) -> tensor<?x?xf32> {2840 %0 = linalg.unpack %source inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %dest : tensor<?x?x8x2xf32> -> tensor<?x?xf32>2841 return %0: tensor<?x?xf32>2842}2843 2844// CHECK-LABEL: func.func @unpack_partially_dynamic(2845// CHECK-SAME: %[[SOURCE:.*]]: tensor<?x?x8x2xf32>,2846// CHECK-SAME: %[[DEST:.*]]: tensor<?x?xf32>)2847// CHECK: %{{.*}} = linalg.unpack %[[SOURCE]] inner_dims_pos = [0, 1] inner_tiles = [8, 2] into %[[DEST]] : tensor<?x?x8x2xf32> -> tensor<?x?xf32>2848