1// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2" -mlir-disable-threading=true | FileCheck %s -check-prefix=TILE-2 2// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,2" -mlir-disable-threading=true | FileCheck %s -check-prefix=TILE-02 3// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=0,0,2" -mlir-disable-threading=true | FileCheck %s -check-prefix=TILE-002 4// RUN: mlir-opt %s -linalg-tile="linalg-tile-sizes=2,3,4" -mlir-disable-threading=true | FileCheck %s -check-prefix=TILE-234 5 6// TILE-2-DAG: #[[$strided1D:.*]] = affine_map<(d0)[s0] -> (d0 + s0)> 7// TILE-02-DAG: #[[$strided1D:.*]] = affine_map<(d0)[s0] -> (d0 + s0)> 8// TILE-002-DAG: #[[$strided1D:.*]] = affine_map<(d0)[s0] -> (d0 + s0)> 9// TILE-234-DAG: #[[$strided1D:.*]] = affine_map<(d0)[s0] -> (d0 + s0)> 10 11// TILE-2-DAG: #[[$strided2D:.*]] = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)> 12// TILE-02-DAG: #[[$strided2D:.*]] = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)> 13// TILE-002-DAG: #[[$strided2D:.*]] = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)> 14// TILE-234-DAG: #[[$strided2D:.*]] = affine_map<(d0, d1)[s0, s1] -> (d0 * s1 + s0 + d1)> 15 16// TILE-2-DAG: #[[$bound_map:.*]] = affine_map<(d0)[s0] -> (2, -d0 + s0)> 17// TILE-02-DAG: #[[$bound_map:.*]] = affine_map<(d0)[s0] -> (2, -d0 + s0)> 18// TILE-002-DAG: #[[$bound_map:.*]] = affine_map<(d0)[s0] -> (2, -d0 + s0)> 19// TILE-234-DAG: #[[$bound_map_2:.*]] = affine_map<(d0)[s0] -> (2, -d0 + s0)> 20// TILE-234-DAG: #[[$bound_map_3:.*]] = affine_map<(d0)[s0] -> (3, -d0 + s0)> 21// TILE-234-DAG: #[[$bound_map_4:.*]] = affine_map<(d0)[s0] -> (4, -d0 + s0)> 22 23// TILE-2-DAG: #[[$bound_map_static:.*]] = affine_map<(d0) -> (2, -d0 + 10)> 24// TILE-02-DAG: #[[$bound_map_static:.*]] = affine_map<(d0) -> (2, -d0 + 12)> 25// TILE-002-DAG: #[[$bound_map_static:.*]] = affine_map<(d0) -> (2, -d0 + 16)> 26 27// TILE-2-DAG: #[[$stride_99_1_layout_map:.*]] = affine_map<(d0, d1)[s0] -> (d0 * 99 + s0 + d1)> 28// TILE-02-DAG: #[[$stride_99_1_layout_map:.*]] = affine_map<(d0, d1)[s0] -> (d0 * 99 + s0 + d1)> 29// TILE-234-DAG: #[[$stride_99_1_layout_map:.*]] = affine_map<(d0, d1)[s0] -> (d0 * 99 + s0 + d1)> 30 31func @matmul(%arg0: memref<?x?xf32, offset: ?, strides: [?, 1]>, 32 %arg1: memref<?x?xf32, offset: ?, strides: [?, 1]>, 33 %arg2: memref<?x?xf32, offset: ?, strides: [?, 1]>) { 34 linalg.matmul 35 ins(%arg0, %arg1: memref<?x?xf32, offset: ?, strides: [?, 1]>, 36 memref<?x?xf32, offset: ?, strides: [?, 1]>) 37 outs(%arg2: memref<?x?xf32, offset: ?, strides: [?, 1]>) 38 return 39} 40// TILE-2-LABEL: func @matmul( 41// TILE-2-DAG: %[[C0:.*]] = constant 0 : index 42// TILE-2-DAG: %[[C2:.*]] = constant 2 : index 43// TILE-2: %[[M:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 44// TILE-2: scf.for %[[I:.*]] = %{{.*}}{{.*}} to %[[M]] step %{{.*}} { 45// TILE-2: %[[localM:.*]] = dim %{{.*}}, %c0 46// TILE-2: %[[szM:.*]] = affine.min #[[$bound_map]](%[[I]])[%[[localM]]] 47// TILE-2: %[[K:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 48// TILE-2: %[[sAi:.*]] = subview %{{.*}}[%[[I]], 0] [%[[szM]], %[[K]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 49// TILE-2: %[[localK:.*]] = dim %{{.*}}, %c0 50// TILE-2: %[[szK:.*]] = affine.min #[[$bound_map]](%[[I]])[%[[localK]]] 51// TILE-2: %[[N:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 52// TILE-2: %[[sCi:.*]] = subview %{{.*}}[%[[I]], 0] [%[[szK]], %[[N]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 53// TILE-2: linalg.matmul ins(%[[sAi]]{{.*}} outs(%[[sCi]] 54 55// TILE-02-LABEL: func @matmul( 56// TILE-02-DAG: %[[C0:.*]] = constant 0 : index 57// TILE-02-DAG: %[[C2:.*]] = constant 2 : index 58// TILE-02: %[[N:.*]] = dim %arg1, %c1 : memref<?x?xf32, #[[$strided2D]]> 59// TILE-02: scf.for %[[J:.*]] = %{{.*}} to %[[N]] step %{{.*}} { 60// TILE-02: %[[K:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 61// TILE-02: %[[localN:.*]] = dim %{{.*}}, %c1 62// TILE-02: %[[szN:.*]] = affine.min #[[$bound_map]](%[[J]])[%[[localN]]] 63// TILE-02: %[[sBj:.*]] = subview %{{.*}}[0, %[[J]]] [%[[K]], %[[szN]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 64// TILE-02: %[[M:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 65// TILE-02: %[[localK:.*]] = dim %{{.*}}, %c1 66// TILE-02: %[[szK:.*]] = affine.min #[[$bound_map]](%[[J]])[%[[localK]]] 67// TILE-02: %[[sCj:.*]] = subview %{{.*}}[0, %[[J]]] [%[[M]], %[[szK]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 68// TILE-02: linalg.matmul ins(%{{.*}}, %[[sBj]]{{.*}} outs(%[[sCj]] 69 70// TILE-002-LABEL: func @matmul( 71// TILE-002-DAG: %[[C0:.*]] = constant 0 : index 72// TILE-002-DAG: %[[C2:.*]] = constant 2 : index 73// TILE-002: %[[ubK:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 74// TILE-002: scf.for %[[K:.*]] = %{{.*}}{{.*}} to %[[ubK]] step %{{.*}} { 75// TILE-002: %[[M:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 76// TILE-002: %[[localK:.*]] = dim %{{.*}}, %c1 77// TILE-002: %[[szK:.*]] = affine.min #[[$bound_map]](%[[K]])[%[[localK]]] 78// TILE-002: %[[sAj:.*]] = subview %{{.*}}[0, %[[K]]] [%[[M]], %[[szK]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 79// TILE-002: %[[localK:.*]] = dim %{{.*}}, %c0 80// TILE-002: %[[szK:.*]] = affine.min #[[$bound_map]](%[[K]])[%[[localK]]] 81// TILE-002: %[[N:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 82// TILE-002: %[[sBj:.*]] = subview %{{.*}}[%[[K]], 0] [%[[szK]], %[[N]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 83// TILE-002: linalg.matmul ins(%[[sAj]], %[[sBj]]{{.*}} outs(%{{.*}} 84 85// TILE-234-LABEL: func @matmul( 86// TILE-234-DAG: %[[C0:.*]] = constant 0 : index 87// TILE-234-DAG: %[[C2:.*]] = constant 2 : index 88// TILE-234-DAG: %[[C3:.*]] = constant 3 : index 89// TILE-234-DAG: %[[C4:.*]] = constant 4 : index 90// TILE-234: %[[ubM:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 91// TILE-234: %[[ubK:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 92// TILE-234: %[[ubN:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 93// TILE-234: scf.for %[[I:.*]] = %{{.*}}{{.*}} to %[[ubM]] step %{{.*}} { 94// TILE-234: scf.for %[[J:.*]] = %{{.*}}{{.*}} to %[[ubN]] step %{{.*}} { 95// TILE-234: scf.for %[[K:.*]] = %{{.*}}{{.*}} to %[[ubK]] step %{{.*}} { 96// TILE-234: %[[localM:.*]] = dim %{{.*}}, %c0 97// TILE-234: %[[szM:.*]] = affine.min #[[$bound_map_2]](%[[I]])[%[[localM]]] 98// TILE-234: %[[localK:.*]] = dim %{{.*}}, %c1 99// TILE-234: %[[szK:.*]] = affine.min #[[$bound_map_4]](%[[K]])[%[[localK]]] 100// TILE-234: %[[sAik:.*]] = subview %{{.*}}[%[[I]], %[[K]]] [%[[szM]], %[[szK]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 101// TILE-234: %[[localK:.*]] = dim %{{.*}}, %c0 102// TILE-234: %[[szK:.*]] = affine.min #[[$bound_map_4]](%[[K]])[%[[localK]]] 103// TILE-234: %[[localN:.*]] = dim %{{.*}}, %c1 104// TILE-234: %[[szN:.*]] = affine.min #[[$bound_map_3]](%[[J]])[%[[localN]]] 105// TILE-234: %[[sBkj:.*]] = subview %{{.*}}[%[[K]], %[[J]]] [%[[szK]], %[[szN]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 106// TILE-234: %[[localM:.*]] = dim %{{.*}}, %c0 107// TILE-234: %[[szM:.*]] = affine.min #[[$bound_map_2]](%[[I]])[%[[localM]]] 108// TILE-234: %[[localN:.*]] = dim %{{.*}}, %c1 109// TILE-234: %[[szN:.*]] = affine.min #[[$bound_map_3]](%[[J]])[%[[localN]]] 110// TILE-234: %[[sCij:.*]] = subview %{{.*}}[%[[I]], %[[J]]] [%[[szM]], %[[szN]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 111// 112// TILE-234: linalg.matmul ins(%[[sAik]], %[[sBkj]]{{.*}} outs(%[[sCij]] 113 114// When the buffer shapes are known at compile time, it is possible to avoid 115// the "min" in subview size computation. This test uses buffer sizes divisible 116// by respective tile sizes (M=10 divisble by 2, N=12 divisible by 2 and 3, 117// K=16 divisble by 2 and 4). 118func @matmul_static(%arg0: memref<10x16xf32, offset: ?, strides: [?, 1]>, 119 %arg1: memref<16x12xf32, offset: ?, strides: [?, 1]>, 120 %arg2: memref<10x12xf32, offset: ?, strides: [?, 1]>) { 121 linalg.matmul 122 ins(%arg0, %arg1: memref<10x16xf32, offset: ?, strides: [?, 1]>, 123 memref<16x12xf32, offset: ?, strides: [?, 1]>) 124 outs(%arg2: memref<10x12xf32, offset: ?, strides: [?, 1]>) 125 return 126} 127// TILE-2-LABEL: func @matmul_static( 128// TILE-2-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref 129// TILE-2-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref 130// TILE-2-SAME: %[[ARG2:[0-9a-zA-Z]*]]: memref 131// TILE-2-DAG: %[[C0:.*]] = constant 0 : index 132// TILE-2-DAG: %[[C2:.*]] = constant 2 : index 133// TILE-2-DAG: %[[M:.*]] = constant 10 : index 134// TILE-2: scf.for %[[I:.*]] = %{{.*}} to %[[M]] step %{{.*}} { 135// TILE-2: %[[MIN2:.*]] = affine.min #[[$bound_map_static]](%[[I]]) 136// TILE-2: %[[sAi:.*]] = subview %{{.*}}[%[[I]], 0] [%[[MIN2]], 16] [1, 1] : memref<10x16xf32, #[[$strided2D]]> to memref<?x16xf32, #[[$strided2D]]> 137// TILE-2: %[[MIN22:.*]] = affine.min #[[$bound_map_static]](%[[I]]) 138// TILE-2: %[[sCi:.*]] = subview %{{.*}}[%[[I]], 0] [%[[MIN22]], 12] [1, 1] : memref<10x12xf32, #[[$strided2D]]> to memref<?x12xf32, #[[$strided2D]]> 139// TILE-2: linalg.matmul ins(%[[sAi]], %{{.*}}{{.*}} outs(%[[sCi]] 140 141// TILE-02-LABEL: func @matmul_static( 142// TILE-02-DAG: %[[C0:.*]] = constant 0 : index 143// TILE-02-DAG: %[[C2:.*]] = constant 2 : index 144// TILE-02-DAG: %[[N:.*]] = constant 12 : index 145// TILE-02: scf.for %[[J:.*]] = %{{.*}} to %[[N]] step %{{.*}} { 146// TILE-02: %[[MIN2:.*]] = affine.min #[[$bound_map_static]](%[[J]]) 147// TILE-02: %[[sBj:.*]] = subview %{{.*}}[0, %[[J]]] [16, %[[MIN2]]] [1, 1] : memref<16x12xf32, #[[$strided2D]]> to memref<16x?xf32, #[[$strided2D]]> 148// TILE-02: %[[MIN22:.*]] = affine.min #[[$bound_map_static]](%[[J]]) 149// TILE-02: %[[sCj:.*]] = subview %{{.*}}[0, %[[J]]] [10, %[[MIN22]]] [1, 1] : memref<10x12xf32, #[[$strided2D]]> to memref<10x?xf32, #[[$strided2D]]> 150// TILE-02: linalg.matmul ins(%{{.*}}, %[[sBj]]{{.*}} outs(%[[sCj]] 151 152// TILE-002-LABEL: func @matmul_static( 153// TILE-002-DAG: %[[C0:.*]] = constant 0 : index 154// TILE-002-DAG: %[[C2:.*]] = constant 2 : index 155// TILE-002-DAG: %[[C16:.*]] = constant 16 : index 156// TILE-002: scf.for %[[K:.*]] = %{{.*}}{{.*}} to %[[C16]] step %{{.*}} { 157// TILE-002: %[[MIN2:.*]] = affine.min #[[$bound_map_static]](%[[K]]) 158// TILE-002: %[[sAj:.*]] = subview %{{.*}}[0, %[[K]]] [10, %[[MIN2]]] [1, 1] : memref<10x16xf32, #[[$strided2D]]> to memref<10x?xf32, #[[$strided2D]]> 159// TILE-002: %[[MIN22:.*]] = affine.min #[[$bound_map_static]](%[[K]]) 160// TILE-002: %[[sBj:.*]] = subview %{{.*}}[%[[K]], 0] [%[[MIN22]], 12] [1, 1] : memref<16x12xf32, #[[$strided2D]]> to memref<?x12xf32, #[[$strided2D]]> 161// TILE-002: linalg.matmul ins(%[[sAj]], %[[sBj]]{{.*}} outs(%{{.*}} 162 163// TILE-234-LABEL: func @matmul_static( 164// TILE-234-DAG: %[[C0:.*]] = constant 0 : index 165// TILE-234-DAG: %[[C2:.*]] = constant 2 : index 166// TILE-234-DAG: %[[C3:.*]] = constant 3 : index 167// TILE-234-DAG: %[[C4:.*]] = constant 4 : index 168// TILE-234-DAG: %[[C10:.*]] = constant 10 : index 169// TILE-234-DAG: %[[C16:.*]] = constant 16 : index 170// TILE-234-DAG: %[[C12:.*]] = constant 12 : index 171// TILE-234: scf.for %[[I:.*]] = %{{.*}}{{.*}} to %[[C10]] step %{{.*}} { 172// TILE-234: scf.for %[[J:.*]] = %{{.*}}{{.*}} to %[[C12]] step %{{.*}} { 173// TILE-234: scf.for %[[K:.*]] = %{{.*}}{{.*}} to %[[C16]] step %{{.*}} { 174// TILE-234: %[[sAik:.*]] = subview %{{.*}}[%[[I]], %[[K]]] [%{{.*}}, %{{.*}}] [1, 1] : memref<10x16xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 175// TILE-234: %[[sBkj:.*]] = subview %{{.*}}[%[[K]], %[[J]]] [%{{.*}}, %{{.*}}] [1, 1] : memref<16x12xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 176// TILE-234: %[[sCij:.*]] = subview %{{.*}}[%[[I]], %[[J]]] [%{{.*}}, %{{.*}}] [1, 1] : memref<10x12xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 177// 178// TILE-234: linalg.matmul ins(%[[sAik]], %[[sBkj]]{{.*}} outs(%[[sCij]] 179 180func @matvec(%arg0: memref<?x?xf32, offset: ?, strides: [?, 1]>, %arg1: memref<?xf32, offset: ?, strides: [1]>, %arg2: memref<?xf32, offset: ?, strides: [1]>) { 181 linalg.matvec 182 ins(%arg0, %arg1: memref<?x?xf32, offset: ?, strides: [?, 1]>, 183 memref<?xf32, offset: ?, strides: [1]>) 184 outs(%arg2: memref<?xf32, offset: ?, strides: [1]>) 185 return 186} 187// TILE-2-LABEL: func @matvec( 188// TILE-2-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref 189// TILE-2-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref 190// TILE-2-SAME: %[[ARG2:[0-9a-zA-Z]*]]: memref 191// TILE-2-DAG: %[[C0:.*]] = constant 0 : index 192// TILE-2-DAG: %[[C2:.*]] = constant 2 : index 193// TILE-2: %[[M:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 194// TILE-2: scf.for %[[I:.*]] = %{{.*}}{{.*}} to %[[M]] step %{{.*}} { 195// TILE-2: %[[localM:.*]] = dim %[[ARG0]], %c0 196// TILE-2: %[[szM:.*]] = affine.min #[[$bound_map]](%[[I]])[%[[localM]]] 197// TILE-2: %[[N:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 198// TILE-2: %[[sAi:.*]] = subview %{{.*}}[%[[I]], 0] [%[[szM]], %[[N]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 199// TILE-2: %[[localN:.*]] = dim %{{.*}}, %c0 200// TILE-2: %[[szN:.*]] = affine.min #[[$bound_map]](%[[I]])[%[[localN]]] 201// TILE-2: %[[sCi:.*]] = subview %{{.*}}[%[[I]]] [%[[szN]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 202// TILE-2: linalg.matvec ins(%[[sAi]], %{{.*}} outs(%[[sCi]] 203 204// TILE-02-LABEL: func @matvec( 205// TILE-02-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref 206// TILE-02-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref 207// TILE-02-SAME: %[[ARG2:[0-9a-zA-Z]*]]: memref 208// TILE-02-DAG: %[[C0:.*]] = constant 0 : index 209// TILE-02-DAG: %[[C2:.*]] = constant 2 : index 210// TILE-02: %[[K:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 211// TILE-02: scf.for %[[J:.*]] = %{{.*}}{{.*}} to %[[K]] step %{{.*}} { 212// TILE-02: %[[M:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 213// TILE-02: %[[localN:.*]] = dim %{{.*}}, %c1 214// TILE-02: %[[szN:.*]] = affine.min #[[$bound_map]](%[[J]])[%[[localN]]] 215// TILE-02: %[[sAj:.*]] = subview %{{.*}}[0, %[[J]]] [%[[M]], %[[szN]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 216// TILE-02: %[[localN:.*]] = dim %{{.*}}, %c0 217// TILE-02: %[[szN:.*]] = affine.min #[[$bound_map]](%[[J]])[%[[localN]]] 218// TILE-02: %[[sBj:.*]] = subview %{{.*}}[%[[J]]] [%[[szN]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 219// TILE-02: linalg.matvec ins(%[[sAj]], %[[sBj]]{{.*}} outs(%{{.*}} 220 221// TILE-002-LABEL: func @matvec( 222// TILE-002-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref 223// TILE-002-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref 224// TILE-002-SAME: %[[ARG2:[0-9a-zA-Z]*]]: memref 225// TILE-002-NOT: scf.for 226 227// TILE-234-LABEL: func @matvec( 228// TILE-234-SAME: %[[ARG0:[0-9a-zA-Z]*]]: memref 229// TILE-234-SAME: %[[ARG1:[0-9a-zA-Z]*]]: memref 230// TILE-234-SAME: %[[ARG2:[0-9a-zA-Z]*]]: memref 231// TILE-234-DAG: %[[C0:.*]] = constant 0 : index 232// TILE-234-DAG: %[[C2:.*]] = constant 2 : index 233// TILE-234-DAG: %[[C3:.*]] = constant 3 : index 234// TILE-234: %[[M:.*]] = dim %{{.*}}, %c0 : memref<?x?xf32, #[[$strided2D]]> 235// TILE-234: %[[K:.*]] = dim %{{.*}}, %c1 : memref<?x?xf32, #[[$strided2D]]> 236// TILE-234: scf.for %[[I:.*]] = %{{.*}}{{.*}} to %[[M]] step %{{.*}} { 237// TILE-234: scf.for %[[J:.*]] = %{{.*}}{{.*}} to %[[K]] step %{{.*}} { 238// TILE-234: %[[localM:.*]] = dim %{{.*}}, %c0 239// TILE-234: %[[szM:.*]] = affine.min #[[$bound_map_2]](%[[I]])[%[[localM]]] 240// TILE-234: %[[localN:.*]] = dim %{{.*}}, %c1 241// TILE-234: %[[szN:.*]] = affine.min #[[$bound_map_3]](%[[J]])[%[[localN]]] 242// TILE-234: %[[sAij:.*]] = subview %{{.*}}[%[[I]], %[[J]]] [%[[szM]], %[[szN]]] [1, 1] : memref<?x?xf32, #[[$strided2D]]> to memref<?x?xf32, #[[$strided2D]]> 243// TILE-234: %[[localN:.*]] = dim %{{.*}}, %c0 244// TILE-234: %[[szN:.*]] = affine.min #[[$bound_map_3]](%[[J]])[%[[localN]]] 245// TILE-234: %[[sBj:.*]] = subview %{{.*}}[%[[J]]] [%[[szN]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 246// TILE-234: %[[localM:.*]] = dim %{{.*}}, %c0 247// TILE-234: %[[szM:.*]] = affine.min #[[$bound_map_2]](%[[I]])[%[[localM]]] 248// TILE-234: %[[sCi:.*]] = subview %{{.*}}[%[[I]]] [%[[szM]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 249// 250// TILE-234: linalg.matvec ins(%[[sAij]], %[[sBj]]{{.*}} outs(%[[sCi]] 251 252func @dot(%arg0: memref<?xf32, offset: ?, strides: [1]>, %arg1: memref<?xf32, offset: ?, strides: [1]>, %arg2: memref<f32>) { 253 linalg.dot 254 ins(%arg0, %arg1: memref<?xf32, offset: ?, strides: [1]>, memref<?xf32, offset: ?, strides: [1]>) 255 outs(%arg2: memref<f32>) 256 return 257} 258// TILE-2-LABEL: func @dot( 259// TILE-2-DAG: %[[C0:.*]] = constant 0 : index 260// TILE-2-DAG: %[[C2:.*]] = constant 2 : index 261// TILE-2: %[[M:.*]] = dim %{{.*}}, %c0 : memref<?xf32, #[[$strided1D]]> 262// TILE-2: scf.for %[[I:.*]] = %{{.*}}{{.*}} to %[[M]] step %{{.*}} { 263// TILE-2: %[[localM:.*]] = dim %{{.*}}, %c0 264// TILE-2: %[[szM:.*]] = affine.min #[[$bound_map]](%[[I]])[%[[localM]]] 265// TILE-2: %[[sAi:.*]] = subview %{{.*}}[%[[I]]] [%[[szM]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 266// TILE-2: %[[localM:.*]] = dim %{{.*}}, %c0 267// TILE-2: %[[szM:.*]] = affine.min #[[$bound_map]](%[[I]])[%[[localM]]] 268// TILE-2: %[[sBi:.*]] = subview %{{.*}}[%[[I]]] [%[[szM]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 269// TILE-2: linalg.dot ins(%[[sAi]], %[[sBi]]{{.*}} outs( 270 271// TILE-02-LABEL: func @dot( 272// TILE-02-NOT: scf.for 273 274// TILE-002-LABEL: func @dot( 275// TILE-002-NOT: scf.for 276 277// TILE-234-LABEL: func @dot( 278// TILE-234-DAG: %[[C0:.*]] = constant 0 : index 279// TILE-234-DAG: %[[C2:.*]] = constant 2 : index 280// TILE-234: %[[ubK:.*]] = dim %{{.*}}, %c0 : memref<?xf32, #[[$strided1D]]> 281// TILE-234: scf.for %[[I:.*]] = %{{.*}} to %[[ubK]] step %{{.*}} { 282// TILE-234: %[[localM:.*]] = dim %{{.*}}, %c0 283// TILE-234: %[[szM:.*]] = affine.min #[[$bound_map_2]](%[[I]])[%[[localM]]] 284// TILE-234: %[[sAi:.*]] = subview %{{.*}}[%[[I]]] [%[[szM]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 285// TILE-234: %[[localM:.*]] = dim %{{.*}}, %c0 286// TILE-234: %[[szM:.*]] = affine.min #[[$bound_map_2]](%[[I]])[%[[localM]]] 287// TILE-234: %[[sBi:.*]] = subview %{{.*}}[%[[I]]] [%[[szM]]] [1] : memref<?xf32, #[[$strided1D]]> to memref<?xf32, #[[$strided1D]]> 288// TILE-234: linalg.dot ins(%[[sAi]], %[[sBi]]{{.*}} outs( 289 290func @fill_static(%arg0: memref<127x99xf32>, %arg1: f32) { 291 linalg.fill(%arg0, %arg1) : memref<127x99xf32>, f32 292 return 293} 294// TILE-2-LABEL: func @fill_static 295// TILE-2: for 296// TILE-2-NOT: for 297// TILE-2: subview{{.*}} : memref<127x99xf32> 298// TILE-2: linalg.fill{{.*}} : memref<?x99xf32, #[[$stride_99_1_layout_map]]>, f32 299 300// TILE-02-LABEL: func @fill_static 301// TILE-02: for 302// TILE-02-NOT: for 303// TILE-02: subview{{.*}} : memref<127x99xf32> 304// TILE-02: linalg.fill{{.*}} : memref<127x?xf32, #[[$stride_99_1_layout_map]]>, f32 305 306// TILE-002-LABEL: func @fill_static 307// TILE-002-NOT: for 308// TILE-002: linalg.fill{{.*}} memref<127x99xf32>, f32 309 310// TILE-234-LABEL: func @fill_static 311// TILE-234: for 312// TILE-234: for 313// TILE-234-NOT: for 314// TILE-234: subview{{.*}} : memref<127x99xf32> 315// TILE-234: linalg.fill{{.*}} : memref<?x?xf32, #[[$stride_99_1_layout_map]]>, f32 316 317 318func @fill(%arg0: memref<?x?xf32, offset: ?, strides: [?, 1]>, %arg1: f32) { 319 linalg.fill(%arg0, %arg1) : memref<?x?xf32, offset: ?, strides: [?, 1]>, f32 320 return 321} 322// TILE-2-LABEL: func @fill 323// TILE-2: for 324// TILE-2-NOT: for 325// TILE-2: fill{{.*}} f32 326 327// TILE-02-LABEL: func @fill 328// TILE-02: for 329// TILE-02-NOT: for 330// TILE-02: fill{{.*}} f32 331 332// TILE-002-LABEL: func @fill 333// TILE-002-NOT: for 334// TILE-002: fill{{.*}} f32 335 336// TILE-234-LABEL: func @fill 337// TILE-234: for 338// TILE-234: for 339// TILE-234-NOT: for 340// TILE-234: fill{{.*}} f32 341 342#id_2d = affine_map<(i, j) -> (i, j)> 343#pointwise_2d_trait = { 344 args_in = 2, 345 args_out = 1, 346 indexing_maps = [#id_2d, #id_2d, #id_2d], 347 iterator_types = ["parallel", "parallel"] 348} 349 350func @pointwise(%arg0: memref<?x?xf32, offset: ?, strides: [?, 1]>, %arg1: memref<?x?xf32, offset: ?, strides: [?, 1]>, 351 %arg2: memref<?x?xf32, offset: ?, strides: [?, 1]>) { 352 linalg.generic #pointwise_2d_trait 353 ins(%arg0, %arg1 : memref<?x?xf32, offset: ?, strides: [?, 1]>, memref<?x?xf32, offset: ?, strides: [?, 1]>) 354 outs(%arg2 : memref<?x?xf32, offset: ?, strides: [?, 1]>) { 355 ^bb0(%arg4: f32, %arg5: f32, %arg6: f32): // no predecessors 356 %4 = addf %arg4, %arg5 : f32 357 linalg.yield %4 : f32 358 } 359 return 360} 361// TILE-2-LABEL: func @pointwise 362// TILE-2: for 363// TILE-2-NOT: for 364// TILE-2: linalg.generic 365 366// TILE-02-LABEL: func @pointwise 367// TILE-02: for 368// TILE-02-NOT: for 369// TILE-02: linalg.generic 370 371// TILE-002-LABEL: func @pointwise 372// TILE-002-NOT: for 373// TILE-002: linalg.generic 374 375// TILE-234-LABEL: func @pointwise 376// TILE-234: for 377// TILE-234: for 378// TILE-234-NOT: for 379// TILE-234: linalg.generic 380