1// RUN: mlir-opt %s -linalg-fusion | FileCheck %s 2 3func @f1(%A: memref<?x?xf32, offset: ?, strides: [?, 1]>, %B: memref<?x?xf32, offset: ?, strides: [?, 1]>, %C: memref<?x?xf32, offset: ?, strides: [?, 1]>, %D: memref<?x?xf32, offset: ?, strides: [?, 1]>, %E: memref<?x?xf32, offset: ?, strides: [?, 1]>) -> memref<?x?xf32, offset: ?, strides: [?, 1]> { 4 %c1 = constant 1 : index 5 %c0 = constant 0 : index 6 %c4 = constant 4 : index 7 %c3 = constant 3 : index 8 %c2 = constant 2 : index 9 %c40 = constant 40 : index 10 %c30 = constant 30 : index 11 %c20 = constant 20 : index 12 %0 = dim %C, %c0 : memref<?x?xf32, offset: ?, strides: [?, 1]> 13 %1 = dim %C, %c1 : memref<?x?xf32, offset: ?, strides: [?, 1]> 14 %2 = dim %D, %c1 : memref<?x?xf32, offset: ?, strides: [?, 1]> 15 linalg.matmul %A, %B, %C : (memref<?x?xf32, offset: ?, strides: [?, 1]>, memref<?x?xf32, offset: ?, strides: [?, 1]>, memref<?x?xf32, offset: ?, strides: [?, 1]>) 16 scf.for %arg5 = %c0 to %0 step %c20 { 17 scf.for %arg6 = %c0 to %2 step %c30 { 18 scf.for %arg7 = %c0 to %1 step %c40 { 19 %5 = std.subview %C[%arg5, %arg7][%c20, %c40][%c1, %c1] : memref<?x?xf32, offset: ?, strides: [?, 1]> to memref<?x?xf32, offset: ?, strides: [?, ?]> 20 %7 = std.subview %D[%arg7, %arg6][%c40, %c30][%c1, %c1]: memref<?x?xf32, offset: ?, strides: [?, 1]> to memref<?x?xf32, offset: ?, strides: [?, ?]> 21 %8 = std.subview %E[%arg5, %arg6][%c20, %c40][%c1, %c1] : memref<?x?xf32, offset: ?, strides: [?, 1]> to memref<?x?xf32, offset: ?, strides: [?, ?]> 22 %9 = dim %5, %c0 : memref<?x?xf32, offset: ?, strides: [?, ?]> 23 %10 = dim %5, %c1 : memref<?x?xf32, offset: ?, strides: [?, ?]> 24 %11 = dim %7, %c1 : memref<?x?xf32, offset: ?, strides: [?, ?]> 25 scf.for %arg8 = %c0 to %9 step %c2 { 26 scf.for %arg9 = %c0 to %11 step %c3 { 27 scf.for %arg10 = %c0 to %10 step %c4 { 28 %14 = std.subview %5[%arg8, %arg10][%c2, %c4][%c1, %c1] : memref<?x?xf32, offset: ?, strides: [?, ?]> to memref<?x?xf32, offset: ?, strides: [?, ?]> 29 %16 = std.subview %7[%arg10, %arg9][%c4, %c3][%c1, %c1]: memref<?x?xf32, offset: ?, strides: [?, ?]> to memref<?x?xf32, offset: ?, strides: [?, ?]> 30 %17 = std.subview %8[%arg8, %arg9][%c2, %c4][%c1, %c1] : memref<?x?xf32, offset: ?, strides: [?, ?]> to memref<?x?xf32, offset: ?, strides: [?, ?]> 31 linalg.matmul %14, %16, %17 : (memref<?x?xf32, offset: ?, strides: [?, ?]>, memref<?x?xf32, offset: ?, strides: [?, ?]>, memref<?x?xf32, offset: ?, strides: [?, ?]>) 32 } 33 } 34 } 35 } 36 } 37 } 38 return %E : memref<?x?xf32, offset: ?, strides: [?, 1]> 39} 40// CHECK-LABEL: func @f1 41// CHECK: (%[[A:.*]]:{{.*}}, %[[B:.*]]:{{.*}}, %[[C:.*]]:{{.*}}, %[[D:.*]]:{{.*}}, %[[E:.*]]:{{.*}}) 42// CHECK: scf.for 43// CHECK: scf.for 44// CHECK: scf.for 45// CHECK: scf.for 46// CHECK: scf.for 47// CHECK: scf.for 48// CHECK: linalg.matmul 49// CHECK: linalg.matmul 50