Closed
Description
Minimal example:
func.func @gemm(%arg0 : memref<?x?xf32>, %arg1 : memref<?x?xf32>,
%arg2 : memref<?x?xf32>) {
linalg.matmul ins(%arg0, %arg1 : memref<?x?xf32>, memref<?x?xf32>)
outs(%arg2 : memref<?x?xf32>)
return
}
module attributes {transform.with_named_sequence} {
transform.named_sequence @__transform_main(%arg1 : !transform.any_op {transform.readonly}) {
%matmul = transform.structured.match ops{["linalg.matmul"]} in %arg1
: (!transform.any_op) -> !transform.any_op
transform.structured.convert_to_loops %matmul : !transform.any_op
transform.yield
}
}
Via mlir-opt test.mlir --transform-interpreter
this gets transformed into:
func.func @gemm(%arg0: memref<?x?xf32>, %arg1: memref<?x?xf32>, %arg2: memref<?x?xf32>) {
// constants abbreviated
scf.for %arg3 = %c0_9 to %dim step %c1_10 {
// constants abbreviated
scf.for %arg4 = %c0_11 to %dim_4 step %c1_12 {
// constants abbreviated
scf.for %arg5 = %c0_13 to %dim_0 step %c1_14 {
// constants abbreviated
%9 = arith.mulf %2, %5 : f32
%10 = arith.addf %8, %9 : f32
%11 = affine.apply #map(%arg3, %arg4, %arg5)
%12 = affine.apply #map2(%arg3, %arg4, %arg5)
memref.store %10, %arg2[%11, %12] : memref<?x?xf32>
}
}
}
linalg.matmul ins(%arg0, %arg1 : memref<?x?xf32>, memref<?x?xf32>) outs(%arg2 : memref<?x?xf32>)
return
}
With the (old) target linalg.matmul
still standing.