1// RUN: mlir-opt --test-transform-dialect-interpreter %s | FileCheck %s 2 3transform.with_pdl_patterns { 4^bb0(%arg0: !pdl.operation): 5 sequence %arg0 { 6 ^bb0(%arg1: !pdl.operation): 7 %0 = pdl_match @pdl_target in %arg1 8 %1, %loops:3 = transform.structured.tile %0 {sizes = [4, 4, 4]} 9 } 10 11 pdl.pattern @pdl_target : benefit(1) { 12 %args = operands 13 %results = types 14 %0 = operation "linalg.matmul"(%args : !pdl.range<value>) -> (%results : !pdl.range<type>) 15 rewrite %0 with "transform.dialect" 16 } 17} 18 19// CHECK-LABEL: func @tile_linalg_matmul( 20// CHECK-SAME: %[[TA:[0-9a-z]+]]: tensor<128x128xf32> 21// CHECK-SAME: %[[TB:[0-9a-z]+]]: tensor<128x128xf32> 22// CHECK-SAME: %[[TC:[0-9a-z]+]]: tensor<128x128xf32> 23// CHECK-SAME: -> tensor<128x128xf32> { 24func.func @tile_linalg_matmul( 25 %arg0: tensor<128x128xf32>, %arg1: tensor<128x128xf32>, %arg2: tensor<128x128xf32>) 26 -> tensor<128x128xf32> { 27// CHECK: %[[TD0:.*]] = scf.for {{.*}} to {{.*}} step {{.*}} iter_args(%[[TC0:.*]] = %[[TC]]) -> (tensor<128x128xf32>) { 28// CHECK: %[[TD1:.*]] = scf.for {{.*}} to {{.*}} step {{.*}} iter_args(%[[TC1:.*]] = %[[TC0]]) -> (tensor<128x128xf32>) { 29// CHECK: %[[TD2:.*]] = scf.for {{.*}} to {{.*}} step {{.*}} iter_args(%[[TC2:.*]] = %[[TC1]]) -> (tensor<128x128xf32>) { 30// CHECK: %[[sTA:.*]] = tensor.extract_slice %[[TA]][{{.*}}] : tensor<128x128xf32> to tensor<4x4xf32> 31// CHECK: %[[sTB:.*]] = tensor.extract_slice %[[TB]][{{.*}}] : tensor<128x128xf32> to tensor<4x4xf32> 32// CHECK: %[[sTC:.*]] = tensor.extract_slice %[[TC2]][{{.*}}] : tensor<128x128xf32> to tensor<4x4xf32> 33// CHECK: %[[sTD:.*]] = linalg.matmul ins(%[[sTA]], %[[sTB]] : tensor<4x4xf32>, tensor<4x4xf32>) 34// CHECK-SAME: outs(%[[sTC]] : tensor<4x4xf32>) -> tensor<4x4xf32> 35// CHECK: %[[TD:.*]] = tensor.insert_slice %[[sTD]] into %[[TC2]][{{.*}}] : tensor<4x4xf32> into tensor<128x128xf32> 36// CHECK: scf.yield %[[TD]] : tensor<128x128xf32> 37// CHECK: scf.yield %[[TD2]] : tensor<128x128xf32> 38// CHECK: scf.yield %[[TD1]] : tensor<128x128xf32> 39 %0 = linalg.matmul ins(%arg0, %arg1: tensor<128x128xf32>, tensor<128x128xf32>) 40 outs(%arg2: tensor<128x128xf32>) 41 -> tensor<128x128xf32> 42 43// CHECK: return %[[TD0]] : tensor<128x128xf32> 44 return %0 : tensor<128x128xf32> 45} 46 47