[Mlir-commits] [mlir] [mlir][SCF] Do not peel already peeled loops (PR #71900)

Andrzej WarzyƄski llvmlistbot at llvm.org
Fri Nov 17 00:46:21 PST 2023


banach-space wrote:

> Thanks! @banach-space is verifying that this works

I actually haven't been able to trigger "double" peeling in IREE, but have verified this with a small standalone repro with scalable sizes:
```mlir
func.func @matmul(%A: tensor<?x?xf32>, %B: tensor<?x?xf32>, %C: tensor<?x?xf32>) -> tensor<?x?xf32> {
  %out = linalg.matmul ins(%A, %B: tensor<?x?xf32>, tensor<?x?xf32>)
            outs(%C: tensor<?x?xf32>) -> tensor<?x?xf32>
  return %out : tensor<?x?xf32>
}

module attributes {transform.with_named_sequence} {
  transform.named_sequence @__transform_main(%arg1: !transform.any_op {transform.readonly}) {
    %matmul_0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 : (!transform.any_op) -> !transform.any_op
    %1, %loop_1, %loop_2, %loop_3 = transform.structured.tile_using_for %matmul_0 [8, [32], 1] : (!transform.any_op)
      -> (!transform.any_op, !transform.op<"scf.for">, !transform.op<"scf.for">,!transform.op<"scf.for">)
    %main_loop, %remainder_loop = transform.loop.peel %loop_2 : (!transform.op<"scf.for">) -> (!transform.op<"scf.for">, !transform.op<"scf.for">)
    // "Double" peeling - fails after this change, which is correct.
    %main_loop_2, %remainder_loop_2 = transform.loop.peel %main_loop : (!transform.op<"scf.for">) -> (!transform.op<"scf.for">, !transform.op<"scf.for">)

    transform.yield
  }
}
```

 Thanks for the fix @matthias-springer !

https://github.com/llvm/llvm-project/pull/71900


More information about the Mlir-commits mailing list